|
|
@@ -66,6 +66,7 @@ export class GameCtr extends Component {
|
|
|
|
|
|
public roomId: number = 1
|
|
|
public gameId: number = 1
|
|
|
+ public resetNum: number = 1
|
|
|
|
|
|
private gameInfo: any = null
|
|
|
private historyInfo: any[] = []
|
|
|
@@ -112,6 +113,16 @@ export class GameCtr extends Component {
|
|
|
|
|
|
init() {
|
|
|
|
|
|
+ let roomId = (new URLSearchParams(location.search)).get('roomId')
|
|
|
+ if(roomId != null)
|
|
|
+ {
|
|
|
+ this.roomId = Number(roomId)
|
|
|
+ console.log('get roomId from URL:'+roomId)
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ console.log('use defult roomId')
|
|
|
+ }
|
|
|
+
|
|
|
const roomUrl = `https://airpg1.izouma.com/api/room/${this.roomId}`
|
|
|
|
|
|
fetch(roomUrl)
|
|
|
@@ -146,6 +157,8 @@ export class GameCtr extends Component {
|
|
|
console.log(data)
|
|
|
const historyUrl = `https://airpg1.izouma.com/api/game/${this.gameId}/history`
|
|
|
this.gameInfo = data
|
|
|
+ this.resetNum = data.resetNum
|
|
|
+
|
|
|
fetch(historyUrl)
|
|
|
.then((response) => {
|
|
|
if (!response.ok) {
|
|
|
@@ -200,7 +213,7 @@ export class GameCtr extends Component {
|
|
|
|
|
|
|
|
|
start() {
|
|
|
- // this.startResetAnimation()
|
|
|
+ this.startResetAnimation()
|
|
|
// this.scheduleOnce(() => { this.accessTargetComponent() }, 0.1)
|
|
|
this.scheduleOnce(() => { this.init() }, 1)
|
|
|
this.processCtr.init(this)
|
|
|
@@ -331,8 +344,9 @@ export class GameCtr extends Component {
|
|
|
this.storyPannelCtr.storyContent = data.data
|
|
|
this.storyPannelCtr.isOnProcess = true;
|
|
|
|
|
|
- //初始化后第一次收到剧情,直接展示剧情
|
|
|
- if (this.storyActionStatus == 0) {
|
|
|
+ //0:初始化后第一次收到剧情,直接展示剧情
|
|
|
+ //3:接收到了最后一次剧情展示后清除队列
|
|
|
+ if (this.storyActionStatus == 0 ||this.storyActionStatus == 3 ) {
|
|
|
if (this.storyPannelCtr) {
|
|
|
this.storyPannelCtr.updateStory(data.data)
|
|
|
} else {
|
|
|
@@ -342,7 +356,7 @@ export class GameCtr extends Component {
|
|
|
this.noticeCtr.updateText(this.noticeStr)
|
|
|
} else if (this.storyActionStatus == 2) {
|
|
|
this.optionsAppearAction()
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//处理收到选项事件
|
|
|
@@ -385,7 +399,7 @@ export class GameCtr extends Component {
|
|
|
handleNewPlayer(data: any) {
|
|
|
|
|
|
this.player.push(data.data)
|
|
|
- let playerIndex = this.player.length
|
|
|
+ let playerIndex = this.player.length -1
|
|
|
|
|
|
if (playerIndex === 8) {
|
|
|
return
|
|
|
@@ -394,6 +408,7 @@ export class GameCtr extends Component {
|
|
|
const role: Node = this.roleCtr.node.getChildByName(rolePannelName)
|
|
|
role.active = true
|
|
|
|
|
|
+ console.log('new player@!!!!!!:'+data.data)
|
|
|
this.roleCtr.newPlayer(role, this.player[playerIndex])
|
|
|
|
|
|
this.roleNodes[data.data.name] = role
|
|
|
@@ -466,7 +481,7 @@ export class GameCtr extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //隐藏剧情面板
|
|
|
+ //隐藏上边剧情面板
|
|
|
tween(this.storyPannelCtr.node.parent.getComponent(UIOpacity))
|
|
|
.to(1, { opacity: 0 })
|
|
|
.call(() => {
|
|
|
@@ -614,7 +629,7 @@ export class GameCtr extends Component {
|
|
|
}
|
|
|
|
|
|
this.titlePannel.getChildByName("text_title").getComponent(Label).string = this.gameInfo.name
|
|
|
- this.titlePannel.getChildByName("text_gameNo").getComponent(Label).string = "No." + this.gameId
|
|
|
+ this.titlePannel.getChildByName("text_gameNo").getComponent(Label).string = "No." + (this.resetNum+1)
|
|
|
// 计算日期差(结果单位为毫秒)
|
|
|
const lastHistoryDate = new Date(lastHistory.date)
|
|
|
const firstHistoryDate = new Date(firstHistory.date)
|
|
|
@@ -636,7 +651,7 @@ export class GameCtr extends Component {
|
|
|
this.exchangeTime()
|
|
|
}
|
|
|
this.titlePannel.getChildByName("text_title").getComponent(Label).string = this.gameInfo.name
|
|
|
- this.titlePannel.getChildByName("text_gameNo").getComponent(Label).string = "No." + this.gameId
|
|
|
+ this.titlePannel.getChildByName("text_gameNo").getComponent(Label).string = "No." + (this.resetNum+1)
|
|
|
// 计算日期差(结果单位为毫秒)
|
|
|
const lastHistoryDate = new Date(data.data.date)
|
|
|
const firstHistoryDate = new Date(this.historyInfo[0].date)
|