|
@@ -77,7 +77,7 @@ export class GameCtr extends Component {
|
|
|
private initOptionsPosition: Vec3 = null
|
|
private initOptionsPosition: Vec3 = null
|
|
|
|
|
|
|
|
//剧情布局变化状态:0:展示剧情 ,1:出现选项框 2:已选选项下方展示剧情,3:已选移除剧情上移出现选项框
|
|
//剧情布局变化状态:0:展示剧情 ,1:出现选项框 2:已选选项下方展示剧情,3:已选移除剧情上移出现选项框
|
|
|
- private storyActionStatus: number = 0
|
|
|
|
|
|
|
+ public storyActionStatus: number = 0
|
|
|
|
|
|
|
|
//重启动画
|
|
//重启动画
|
|
|
@property({ type: Label })
|
|
@property({ type: Label })
|
|
@@ -127,26 +127,27 @@ export class GameCtr extends Component {
|
|
|
public bg2AudioSource: AudioSource = null!
|
|
public bg2AudioSource: AudioSource = null!
|
|
|
private isPlayBgm1 = true
|
|
private isPlayBgm1 = true
|
|
|
|
|
|
|
|
- public originUrl:string = null
|
|
|
|
|
- public hostName:string = null
|
|
|
|
|
|
|
+ public originUrl: string = null
|
|
|
|
|
+ public hostName: string = null
|
|
|
|
|
|
|
|
- private globalUrl:string = 'https://airpg1.izouma.com'
|
|
|
|
|
- private globalHostname:string = 'airpg1.izouma.com'
|
|
|
|
|
|
|
+ private globalUrl: string = 'https://airpg1.izouma.com'
|
|
|
|
|
+ private globalHostname: string = 'airpg1.izouma.com'
|
|
|
|
|
|
|
|
- private moveNum:number = 1
|
|
|
|
|
|
|
+ private moveNum: number = 1
|
|
|
|
|
+
|
|
|
|
|
+ private lastVote:number[] = [0,0,0,0]
|
|
|
|
|
|
|
|
init() {
|
|
init() {
|
|
|
//播放第一个背景音乐
|
|
//播放第一个背景音乐
|
|
|
this.bg1AudioSource.play()
|
|
this.bg1AudioSource.play()
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
console.log(location.href)
|
|
console.log(location.href)
|
|
|
-
|
|
|
|
|
- if(location.hostname === 'localhost')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (location.hostname === 'localhost') {
|
|
|
this.originUrl = this.globalUrl
|
|
this.originUrl = this.globalUrl
|
|
|
this.hostName = this.globalHostname
|
|
this.hostName = this.globalHostname
|
|
|
}
|
|
}
|
|
|
- else{
|
|
|
|
|
|
|
+ else {
|
|
|
this.originUrl = location.origin
|
|
this.originUrl = location.origin
|
|
|
this.hostName = location.hostname
|
|
this.hostName = location.hostname
|
|
|
}
|
|
}
|
|
@@ -159,7 +160,7 @@ export class GameCtr extends Component {
|
|
|
console.log("use defult roomId")
|
|
console.log("use defult roomId")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
const roomUrl = `${this.originUrl}/api/room/${this.roomId}`
|
|
const roomUrl = `${this.originUrl}/api/room/${this.roomId}`
|
|
|
console.log(roomUrl)
|
|
console.log(roomUrl)
|
|
|
fetch(roomUrl)
|
|
fetch(roomUrl)
|
|
@@ -290,7 +291,7 @@ export class GameCtr extends Component {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- update(deltaTime: number) {}
|
|
|
|
|
|
|
+ update(deltaTime: number) { }
|
|
|
|
|
|
|
|
onButtonClick() {
|
|
onButtonClick() {
|
|
|
//director.loadScene(director.getScene().name);
|
|
//director.loadScene(director.getScene().name);
|
|
@@ -404,13 +405,37 @@ export class GameCtr extends Component {
|
|
|
|
|
|
|
|
if (this.storyActionStatus === 0 || this.storyActionStatus === 3) {
|
|
if (this.storyActionStatus === 0 || this.storyActionStatus === 3) {
|
|
|
this.optionsAppearAction()
|
|
this.optionsAppearAction()
|
|
|
|
|
+
|
|
|
|
|
+ //重置记票
|
|
|
|
|
+ this.lastVote = [0,0,0,0]
|
|
|
|
|
+ }else
|
|
|
|
|
+ {
|
|
|
|
|
+ console.log('handleOptions处理失败'+' storyActionStatus'+this.storyActionStatus)
|
|
|
|
|
+ this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
console.log('handleOptions处理完成处理下一个')
|
|
console.log('handleOptions处理完成处理下一个')
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //处理投票进度
|
|
|
|
|
+ handleVotes(data: any) {
|
|
|
|
|
+ let vote:number[] = data.data
|
|
|
|
|
+ if (this.realStart && Math.max(...vote) > 0 && JSON.stringify(this.lastVote) !== JSON.stringify(vote)) {
|
|
|
|
|
+
|
|
|
|
|
+ // console.log("this22222"+this+" processCtr!!!!!"+this.processCtr)
|
|
|
|
|
+ this.optionsCtr.showVotes(vote,this.lastVote, this.processCtr)
|
|
|
|
|
+ this.lastVote = vote
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ console.log('handle votes do nothing:' + this.realStart + " " + this.storyActionStatus + " " + Math.max(...(data.data as number[])))
|
|
|
|
|
+ this.processCtr.doneProcessing()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//处理收到被选项事件
|
|
//处理收到被选项事件
|
|
|
handleVoteResul(data: any) {
|
|
handleVoteResul(data: any) {
|
|
|
if (this.realStart) {
|
|
if (this.realStart) {
|
|
@@ -424,9 +449,12 @@ export class GameCtr extends Component {
|
|
|
if (this.storyActionStatus === 1) {
|
|
if (this.storyActionStatus === 1) {
|
|
|
this.optionsAppearAction()
|
|
this.optionsAppearAction()
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ console.log('handleVoteResul处理失败'+' storyActionStatus'+this.storyActionStatus)
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- console.log('handleVoteResul处理完成处理下一个')
|
|
|
|
|
-
|
|
|
|
|
|
|
+ console.log('handleVoteResul未处理')
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -449,7 +477,6 @@ export class GameCtr extends Component {
|
|
|
this.roleNodes[data.data.name] = role
|
|
this.roleNodes[data.data.name] = role
|
|
|
|
|
|
|
|
console.log('handleNewPlayer处理完成处理下一个')
|
|
console.log('handleNewPlayer处理完成处理下一个')
|
|
|
-
|
|
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -466,13 +493,12 @@ export class GameCtr extends Component {
|
|
|
console.log("处理开始前的status")
|
|
console.log("处理开始前的status")
|
|
|
this.historyInfo.push(data.data)
|
|
this.historyInfo.push(data.data)
|
|
|
this.updateGame(this.gameInfo, this.historyInfo)
|
|
this.updateGame(this.gameInfo, this.historyInfo)
|
|
|
-
|
|
|
|
|
console.log('handleStateResul处理完成处理下一个')
|
|
console.log('handleStateResul处理完成处理下一个')
|
|
|
|
|
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- else{
|
|
|
|
|
|
|
+ else {
|
|
|
console.log("处理开始后的status完成,处理下一个")
|
|
console.log("处理开始后的status完成,处理下一个")
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
@@ -482,24 +508,13 @@ export class GameCtr extends Component {
|
|
|
//处理重置
|
|
//处理重置
|
|
|
handleReset(data: any) {
|
|
handleReset(data: any) {
|
|
|
//director.reset()
|
|
//director.reset()
|
|
|
|
|
+ console.log("处理重置消息")
|
|
|
|
|
+
|
|
|
director.loadScene("game")
|
|
director.loadScene("game")
|
|
|
this.processCtr.doneProcessing()
|
|
this.processCtr.doneProcessing()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //处理投票进度
|
|
|
|
|
- handleVotes(data: any) {
|
|
|
|
|
- if(this.realStart && this.storyActionStatus == 1 && Math.max(...(data.data as number[]))>0)
|
|
|
|
|
- {
|
|
|
|
|
- let votes:number[] = data.data
|
|
|
|
|
- this.optionsCtr.showVotes(votes,this.processCtr)
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- console.log('handle votes do nothing:'+this.realStart+" "+this.storyActionStatus+" "+Math.max(...(data.data as number[])))
|
|
|
|
|
- this.processCtr.doneProcessing()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//处理所有剧情、选项的移动逻辑
|
|
//处理所有剧情、选项的移动逻辑
|
|
|
optionsAppearAction() {
|
|
optionsAppearAction() {
|
|
|
console.log("storyActionStatus:" + this.storyActionStatus)
|
|
console.log("storyActionStatus:" + this.storyActionStatus)
|
|
@@ -513,33 +528,27 @@ export class GameCtr extends Component {
|
|
|
tween(this.storyPannelCtr.node)
|
|
tween(this.storyPannelCtr.node)
|
|
|
.by(0.5, { position: new Vec3(0, storyUI.height - this.storyHeight, 0) })
|
|
.by(0.5, { position: new Vec3(0, storyUI.height - this.storyHeight, 0) })
|
|
|
.call(() => {
|
|
.call(() => {
|
|
|
- this.optionsCtr.setOptions(this.optionsLabel)
|
|
|
|
|
|
|
+ this.optionsCtr.setOptions(this.optionsLabel,this)
|
|
|
|
|
|
|
|
- //此处需要额外处理死亡,因为前一步有演示播放攻击动画,不排除死亡名单中有攻击后自然死亡角色
|
|
|
|
|
|
|
+ //此处需要额外处理死亡,因为前一步有演示播放攻击动画,不排除死亡名单中有攻击后自然死亡角色,最后一个死亡的没啥用,暂没处理
|
|
|
this.roleCtr.dealDeath(this.roleNodes)
|
|
this.roleCtr.dealDeath(this.roleNodes)
|
|
|
})
|
|
})
|
|
|
.start()
|
|
.start()
|
|
|
} else {
|
|
} else {
|
|
|
- this.optionsCtr.setOptions(this.optionsLabel)
|
|
|
|
|
|
|
+ this.optionsCtr.setOptions(this.optionsLabel,this)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
this.playShowOptionsOneShot()
|
|
this.playShowOptionsOneShot()
|
|
|
- console.log("展示选项处理完成,处理下一个")
|
|
|
|
|
- this.processCtr.doneProcessing()
|
|
|
|
|
- this.storyActionStatus = 1
|
|
|
|
|
|
|
+
|
|
|
} else if (this.storyActionStatus === 1) {
|
|
} else if (this.storyActionStatus === 1) {
|
|
|
//选中备选项
|
|
//选中备选项
|
|
|
this.optionsCtr.resetVotes()
|
|
this.optionsCtr.resetVotes()
|
|
|
|
|
|
|
|
console.log("selectedOptionNum:" + this.selectedOptionNum)
|
|
console.log("selectedOptionNum:" + this.selectedOptionNum)
|
|
|
- this.optionsCtr.selectOption(this.selectedOptionNum + 1)
|
|
|
|
|
this.playSelectedOneShot()
|
|
this.playSelectedOneShot()
|
|
|
-
|
|
|
|
|
- console.log("选中选项处理完成,处理下一个")
|
|
|
|
|
-
|
|
|
|
|
- this.processCtr.doneProcessing()
|
|
|
|
|
- this.storyActionStatus = 2
|
|
|
|
|
|
|
+ this.optionsCtr.selectOption(this.selectedOptionNum + 1,this)
|
|
|
|
|
+
|
|
|
} else if (this.storyActionStatus === 2) {
|
|
} else if (this.storyActionStatus === 2) {
|
|
|
this.scheduleOnce(() => {
|
|
this.scheduleOnce(() => {
|
|
|
// 隐藏未被选中选项
|
|
// 隐藏未被选中选项
|
|
@@ -604,12 +613,11 @@ export class GameCtr extends Component {
|
|
|
|
|
|
|
|
//顶部备选项消失
|
|
//顶部备选项消失
|
|
|
tween(selectedOption.getComponent(UIOpacity))
|
|
tween(selectedOption.getComponent(UIOpacity))
|
|
|
- .to(0.5, { opacity: 0 })
|
|
|
|
|
|
|
+ .to(0.5, { opacity: 1 })
|
|
|
.call(() => {
|
|
.call(() => {
|
|
|
//重置选项位置与透明度
|
|
//重置选项位置与透明度
|
|
|
this.optionsCtr.node.position = this.initOptionsPosition
|
|
this.optionsCtr.node.position = this.initOptionsPosition
|
|
|
- // this.optionsCtr.node.getComponent(UIOpacity).opacity = 0
|
|
|
|
|
- // this.optionsCtr.node.getChildByName()
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// 这是被选中的选项
|
|
// 这是被选中的选项
|
|
|
selectedOption.getChildByName("text_option").getComponent(Label).color = Color.WHITE
|
|
selectedOption.getChildByName("text_option").getComponent(Label).color = Color.WHITE
|
|
@@ -619,7 +627,7 @@ export class GameCtr extends Component {
|
|
|
if (spriteComponent) {
|
|
if (spriteComponent) {
|
|
|
spriteComponent.spriteFrame = this.optionsCtr.notSelectedSprite.spriteFrame
|
|
spriteComponent.spriteFrame = this.optionsCtr.notSelectedSprite.spriteFrame
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//剧情上移开始展示
|
|
//剧情上移开始展示
|
|
|
tween(this.storyPannelCtr.node)
|
|
tween(this.storyPannelCtr.node)
|
|
|
.to(0.2, { position: new Vec3(0, 0, 0) })
|
|
.to(0.2, { position: new Vec3(0, 0, 0) })
|
|
@@ -627,8 +635,8 @@ export class GameCtr extends Component {
|
|
|
this.storyActionStatus = 0
|
|
this.storyActionStatus = 0
|
|
|
this.optionsAppearAction()
|
|
this.optionsAppearAction()
|
|
|
|
|
|
|
|
- console.log("剧情上移处理完成,处理下一个")
|
|
|
|
|
- this.processCtr.doneProcessing()
|
|
|
|
|
|
|
+ // console.log("剧情上移处理完成,处理下一个")
|
|
|
|
|
+ // this.processCtr.doneProcessing()
|
|
|
})
|
|
})
|
|
|
.start()
|
|
.start()
|
|
|
})
|
|
})
|
|
@@ -647,7 +655,7 @@ export class GameCtr extends Component {
|
|
|
//初始化剧情!!!
|
|
//初始化剧情!!!
|
|
|
//触发剧情框文字
|
|
//触发剧情框文字
|
|
|
if (this.storyPannelCtr) {
|
|
if (this.storyPannelCtr) {
|
|
|
- // this.storyPannelCtr.updateStory(lastHistory.plot)
|
|
|
|
|
|
|
+ // this.storyPannelCtr.updateStory(lastHistory.plot)
|
|
|
} else {
|
|
} else {
|
|
|
console.log("plot error")
|
|
console.log("plot error")
|
|
|
}
|
|
}
|
|
@@ -682,7 +690,7 @@ export class GameCtr extends Component {
|
|
|
this.roleNodes[this.player[i].name] = role
|
|
this.roleNodes[this.player[i].name] = role
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
throw new Error("gameInfo or historyInfo is null")
|
|
throw new Error("gameInfo or historyInfo is null")
|
|
|
}
|
|
}
|