Browse Source

添加观战,观战中断线踢出

master
cristianoxin 5 months ago
parent
commit
4903383d39
  1. 8
      assets/10001/language/en/language.json
  2. 20
      assets/10001/language/in/language.json
  3. 5940
      assets/10001/prefab/TeenPattieGame.prefab
  4. 4
      assets/10001/src/GameConst10001.ts
  5. 7
      assets/10001/src/game/TeenPattieCommData.ts
  6. 8
      assets/10001/src/game/TeenPattieGameEntity.ts
  7. 82
      assets/10001/src/game/logic/TeenPattieGameBottomLogic.ts
  8. 29
      assets/10001/src/game/logic/TeenPattiePlayerLogic.ts
  9. 13
      assets/10001/src/game/logic/TeenpattieFaPaiEffectLogic.ts
  10. 13
      assets/10001/src/game/system/TeenPattieGameSystem.ts
  11. 67
      assets/10001/src/game/system/TeenpattieGameProxySystem.ts
  12. 2
      assets/10001/src/tool/TeenPattieEventType.ts

8
assets/10001/language/en/language.json

@ -343,6 +343,14 @@
"des":"{0}已退出游戏",
"value":"{0} Exited the game"
},
"game.tip.awaitNextStart":{
"des":"请等待下一轮比赛开始",
"value":"Please wait for the next round to start"
},
"game.tip.watching":{
"des":"正在观战中",
"value":"Watching"
},
"game.tip.exitRoom":{
"des":"退出房间",
"value":"Exit the room"

20
assets/10001/language/in/language.json

@ -330,6 +330,26 @@
"des":"现在退出游戏,将输掉本局游戏",
"value":"अब बाहर जाने से इस राउंड में हार"
},
"game.tip.WatchBattle":{
"des":"{0}正在观战",
"value":"{0} खेल अब देख रहा है"
},
"game.tip.JoinedGame":{
"des":"{0}已加入游戏",
"value":"{0} खेल में शामिल हुआ"
},
"game.tip.quitGame":{
"des":"{0}已退出游戏",
"value":"{0} खेल से बाहर हो गया"
},
"game.tip.awaitNextStart":{
"des":"请等待下一轮比赛开始",
"value":"कृपया प्रारंभ करने के लिए अगले राउन्ड के लिए इंतजार करें"
},
"game.tip.watching":{
"des":"正在观战中",
"value":"देख रहा है"
},
"game.tip.exitRoom":{
"des":"退出房间",
"value":"कमरे से बाहर निकलें"

5940
assets/10001/prefab/TeenPattieGame.prefab

File diff suppressed because it is too large

4
assets/10001/src/GameConst10001.ts

@ -20,8 +20,8 @@ export enum GameNetCode{
RoomWait = 10001023,// 房间等待倒计时
GameRecord = 10001024, // 玩家自己看牌返回
WatchToDown = 10001025, // 主动观战转坐下
NotifyWatchToDown = 1000132, // 通知玩家观战转坐下
NotifyDownToWatch = 1000133, // 通知玩家坐下转观战
NotifyWatchToDown = 10001026, // 通知玩家观战转坐下
NotifyDownToWatch = 10001027, // 通知玩家坐下转观战
}
export enum GamePanelConst{

7
assets/10001/src/game/TeenPattieCommData.ts

@ -36,11 +36,14 @@ export class TeenPattieCommData{
public totalPlayer:number = 6;
/**自己的ID */
public playerSeatId:number = 2;
public playerSeatId:number = 0;
/**自己的ID */
// public get playerSeatId():number{
// return this.playerSeatId;
// }
/**同步服务器座位 */
public chagedIndex:number = 1;
/**
*
*/
@ -170,5 +173,7 @@ export class TeenPattieCommData{
/**是否正在观战 */
public isCurrWatch:boolean = true;
/**是否在当前游戏中 */
public isCurrGame:boolean = true;
}

8
assets/10001/src/game/TeenPattieGameEntity.ts

@ -28,7 +28,7 @@ export class TeenPattieGameEntity extends Component{
Message.remove(SocketConst.CONNECTED,this.reconnect, this);
}
private OnGameExit(param): void {
private OnGameExit(param?:any): void {
TeenPattieCommData.getInstance().clearCommData();
UIManager.getInstance().hide(GamePanelConst.Game_Main_Panel_TeenPattie);
UIManager.getInstance().clearAllByLayer(UILayerIndex.TopLayer);
@ -41,7 +41,11 @@ export class TeenPattieGameEntity extends Component{
private reconnect(){
if(Network.getInstance().isOpen){
console.log("断线重连")
this.init();
if(SystemParams.getInstance().getValue("isWatch") == 1){
this.OnGameExit();
}else{
this.init();
}
}
}

82
assets/10001/src/game/logic/TeenPattieGameBottomLogic.ts

@ -13,6 +13,8 @@ import { Game10001Res } from "../../comm/Game10001Res";
export class TeenPattieGameBottomLogic extends Component {
private btnNode:Node;
private qipaiBtn: Button;
private qipaiBtnSp: Sprite;
private bipaiBtn: Button;
@ -37,6 +39,9 @@ export class TeenPattieGameBottomLogic extends Component {
private xiazhulabel: Label
private rollNum: TeenPattieRollNumComponent;
/**等待提示 */
private actBanker:Label;
private playerSelfData: any;
private qipaiID: any[] = [];
@ -49,28 +54,30 @@ export class TeenPattieGameBottomLogic extends Component {
showEffect:TeenPattieShowEffectLogic;
onLoad(): void {
this.qipaiBtn = find("qipaiBtn", this.node)?.getComponent(Button)
this.qipaiBtnSp = find("qipaiBtn", this.node)?.getComponent(Sprite)
this.bipaiBtn = find("bipaiBtn", this.node)?.getComponent(Button)
this.bipaiBtnSp = find("bipaiBtn", this.node)?.getComponent(Sprite)
this.genpaiBtn = find("genpaiBtn", this.node)?.getComponent(Button)
this.genpaiBtnSp = find("genpaiBtn", this.node)?.getComponent(Sprite)
this.genpaiText = find("genpaiBtn/Label", this.node)?.getComponent(Label);
this.jiazhuBtn = find("jiazhuBtn", this.node)?.getComponent(Button)
this.jiazhuBtnSp = find("jiazhuBtn", this.node)?.getComponent(Sprite)
this.jiazhuText = find("jiazhuBtn/Label",this.node)?.getComponent(Label)
this.xiazhu = find("xiazhu", this.node)
this.genpaiBtnNum = find("genpaiBtn/numLabel", this.node)?.getComponent(Label);
this.jiazhuBtnNum = find("jiazhuBtn/numLabel", this.node)?.getComponent(Label);
this.btnNode = find("btn",this.node);
this.qipaiBtn = find("qipaiBtn", this.btnNode)?.getComponent(Button)
this.qipaiBtnSp = find("qipaiBtn", this.btnNode)?.getComponent(Sprite)
this.bipaiBtn = find("bipaiBtn", this.btnNode)?.getComponent(Button)
this.bipaiBtnSp = find("bipaiBtn", this.btnNode)?.getComponent(Sprite)
this.genpaiBtn = find("genpaiBtn", this.btnNode)?.getComponent(Button)
this.genpaiBtnSp = find("genpaiBtn", this.btnNode)?.getComponent(Sprite)
this.genpaiText = find("genpaiBtn/Label", this.btnNode)?.getComponent(Label);
this.jiazhuBtn = find("jiazhuBtn", this.btnNode)?.getComponent(Button)
this.jiazhuBtnSp = find("jiazhuBtn", this.btnNode)?.getComponent(Sprite)
this.jiazhuText = find("jiazhuBtn/Label",this.btnNode)?.getComponent(Label)
this.xiazhu = find("xiazhu", this.btnNode)
this.genpaiBtnNum = find("genpaiBtn/numLabel", this.btnNode)?.getComponent(Label);
this.jiazhuBtnNum = find("jiazhuBtn/numLabel", this.btnNode)?.getComponent(Label);
this.xiazhulabel = find("Label", this.xiazhu)?.getComponent(Label);
this.rollNum = find("Label", this.xiazhu)?.getComponent(TeenPattieRollNumComponent);
if (!this.rollNum) this.rollNum = find("Label", this.xiazhu)?.addComponent(TeenPattieRollNumComponent);
this.qipaiBtnLabel = find("qipaiBtn/Label", this.node)?.getComponent(LabelOutline);
this.bipaiBtnLabel = find("bipaiBtn/Label", this.node)?.getComponent(LabelOutline);
this.genpaiBtnLabel = find("genpaiBtn/Label", this.node)?.getComponent(LabelOutline);
this.jiazhuBtnLabel = find("jiazhuBtn/Label", this.node)?.getComponent(LabelOutline);
this.qipaiBtnLabel = find("qipaiBtn/Label", this.btnNode)?.getComponent(LabelOutline);
this.bipaiBtnLabel = find("bipaiBtn/Label", this.btnNode)?.getComponent(LabelOutline);
this.genpaiBtnLabel = find("genpaiBtn/Label", this.btnNode)?.getComponent(LabelOutline);
this.jiazhuBtnLabel = find("jiazhuBtn/Label", this.btnNode)?.getComponent(LabelOutline);
this.actBanker = find("actBanker",this.node)?.getComponent(Label);
this.currLabel = 0;
@ -99,6 +106,7 @@ export class TeenPattieGameBottomLogic extends Component {
Message.add(TeenPattieEventType.Refresh, this.refresh, this);
Message.add(TeenPattieEventType.SeeXiaZhu, this.seeXiaZhu, this);
Message.add(TeenPattieEventType.NextGame, this.nextGame, this);
Message.add(TeenPattieEventType.SetCurrGameStatus, this.playerCurrStatus, this);
Message.add("hideShop",this.recoverGame,this);
}
@ -116,9 +124,49 @@ export class TeenPattieGameBottomLogic extends Component {
Message.remove(TeenPattieEventType.Refresh, this.refresh, this);
Message.remove(TeenPattieEventType.SeeXiaZhu, this.seeXiaZhu, this);
Message.remove(TeenPattieEventType.NextGame, this.nextGame, this);
Message.remove(TeenPattieEventType.SetCurrGameStatus, this.playerCurrStatus, this);
Message.remove("hideShop",this.recoverGame,this);
}
private original:string = "";
private effectNum:number = 6;
private tipsEffectNum:number = 0;
private upDataNum:number = 0;
protected lateUpdate(dt: number): void {
if(!this.actBanker.node.active) return;
this.upDataNum += dt;
if(this.upDataNum >= 1){
this.upDataNum = 0;
if(this.tipsEffectNum >= this.effectNum){
this.tipsEffectNum = 0;
this.actBanker.string = this.original;
}
this.tipsEffectNum++;
this.actBanker.string += "·";
}
}
/**玩家当前状态 */
private playerCurrStatus(){
let str:string = "";
let isShow:boolean = false;
if(TeenPattieCommData.getInstance().isCurrWatch && !isShow){
str = Game10001Res.getInstance().getString("game.tip.watching");
isShow = true;
}
if(!TeenPattieCommData.getInstance().isCurrGame && !isShow){
str = Game10001Res.getInstance().getString("game.tip.awaitNextStart");
isShow = true;
}
if(this.original != str){
this.original = str;
this.actBanker.string = str;
}
if(this.btnNode && this.btnNode.isValid) this.btnNode.active = !isShow;
if(this.actBanker && this.actBanker.isValid && this.actBanker.node && this.actBanker.node.isValid) this.actBanker.node.active = isShow;
}
/**获取玩家自己的数据 */
private getPlayerSelfData(value) {
this.playerSelfData = value;

29
assets/10001/src/game/logic/TeenPattiePlayerLogic.ts

@ -19,6 +19,7 @@ import { AudioManager, GameUtils, I18Manager, LoaderManager, Message, Network, S
import { BundleName, GameNetCode, GamePanelConst, GameSound, GameStatus, PlayerStatus } from "../../GameConst10001";
import { TeenPattieGameStaticSystem } from "../system/TeenPattieGameStaticSystem";
import { Game10001Res } from "../../comm/Game10001Res";
import { UserData } from "../../sdk/GameVO";
export class TeenPattiePlayerLogic extends Component {
/** 下注随机坐标范围 x y width height*/
@ -191,7 +192,8 @@ export class TeenPattiePlayerLogic extends Component {
}
private destroyEvent(){
this.clearTimer();
this.seeBtn?.node?.off(Button.EventType.CLICK,this.onClickSeeBtn,this);
if(this.seeBtn && this.seeBtn.isValid) this.seeBtn?.node?.off(Button.EventType.CLICK,this.onClickSeeBtn,this);
if(this.jia && this.jia.isValid) this.jia?.off(Node.EventType.TOUCH_END,this.onWatchToDown,this);
Message.remove(TeenPattieEventType.GameStart, this.reStart, this);
Message.remove(TeenPattieEventType.GameStartFaPai, this.startFaPai, this);
@ -247,7 +249,8 @@ export class TeenPattiePlayerLogic extends Component {
}
//初始化事件
private initEvent() {
this.seeBtn?.node?.on(Button.EventType.CLICK,this.onClickSeeBtn,this);
if(this.seeBtn && this.seeBtn.isValid) this.seeBtn?.node?.on(Button.EventType.CLICK,this.onClickSeeBtn,this);
if(this.jia && this.jia.isValid) this.jia?.on(Node.EventType.TOUCH_END,this.onWatchToDown,this);
Message.add(TeenPattieEventType.GameStart, this.reStart, this);
Message.add(TeenPattieEventType.GameStartFaPai, this.startFaPai, this);
@ -268,10 +271,24 @@ export class TeenPattiePlayerLogic extends Component {
Message.add(TeenPattieEventType.GamePause,this.pauseOnCountDownProgress,this);
Message.add(TeenPattieEventType.GameRecover,this.recoverOnCountDownProgress,this);
}
/**主动观战转坐下 */
private onWatchToDown(){
const allPlayer = TeenPattieCommData.getInstance().allPlayerData;
for(const item of allPlayer){
if(item.Uid == UserData.userId) return;
}
const total:number = TeenPattieCommData.getInstance().totalPlayer;
let index:number=this.seat_id - TeenPattieCommData.getInstance().chagedIndex;
if(index > total)index=index - total;
else if(index <= 0)index=index + total;
Network.getInstance().send(GameNetCode.WatchToDown,{seatId:index});
}
//桌子显示加号
private showJia(status: boolean) {
this.own.active = !status;
// this.jia.active = status;
this.jia.active = status;
}
private tw: Tween<Node>;
@ -547,7 +564,6 @@ export class TeenPattiePlayerLogic extends Component {
this.seen.active = false;
this.pack.active = false;
if((this.data?.SeatId != this.playerSeatId) || !this.data?.SeatId || !this.playerSeatId) return;
this.showFaPaiEffect.setFrist(this.faPai.bankerSeatId);
}
/**发牌结束 */
private faPaiEffevtEnd(){
@ -721,7 +737,7 @@ export class TeenPattiePlayerLogic extends Component {
let allPlayer = TeenPattieCommData.getInstance().allPlayerData;
let allPlayerId = TeenPattieCommData.getInstance().allPlayerId;
for (let i = 0; i < allPlayer.length; i++) {
if (allPlayer[i].SeatId == this.data?.seatId) {
if (allPlayer[i].SeatId == this.data?.SeatId) {
allPlayer.splice(i, 1);
allPlayerId.splice(i,1);
// TeenPattieCommData.getInstance().allPlayerId = allPlayerId;
@ -789,7 +805,8 @@ export class TeenPattiePlayerLogic extends Component {
const url = `res/cards/texture/poker_bg_common`;
let spriteFrame: SpriteFrame = await LoaderManager.getInstance().getType(`${BundleName.BundleName}`, url, SpriteFrame) as SpriteFrame;
if (owner.cardList[i].isValid) owner.cardList[i].spriteFrame = spriteFrame;
if(owner.data?.SeatId != owner.playerSeatId){
// if(owner.data?.SeatId != owner.playerSeatId){
if(owner.seat_id != 3){
if (owner.cardList[i].isValid && owner.cardList[i].node.isValid && owner.cardList[i].node.isValid) owner.cardList[i].node.setScale(v3(0.4,0.4));
}
}

13
assets/10001/src/game/logic/TeenpattieFaPaiEffectLogic.ts

@ -36,6 +36,11 @@ export class TeenpattieFaPaiEffectLogic extends Component{
this.getCoinNodeWorldPosition();
}
protected start(): void {
Message.add(TeenPattieEventType.GameStartFaPai,this.startFaPai,this);
}
/**牌的世界坐标位置 */
private getCoinNodeWorldPosition(){
const total:number = TeenPattieCommData.getInstance().totalPlayer;
@ -80,6 +85,12 @@ export class TeenpattieFaPaiEffectLogic extends Component{
onDestroy(): void {
this.stopMove();
Message.remove(TeenPattieEventType.GameStartFaPai,this.startFaPai,this);
}
private startFaPai(value:any){
if (!value) return;
this.setFrist(value.bankerSeatId);
}
/**
@ -126,7 +137,7 @@ export class TeenpattieFaPaiEffectLogic extends Component{
}
/**当前玩家总数 */
private playerTotal:number = 5;
private playerTotal:number = 6;
/**
*
*

13
assets/10001/src/game/system/TeenPattieGameSystem.ts

@ -64,7 +64,7 @@ export class TeenPattieGameSystem extends Component{
this._playerlist.push(playerLogic);
playerLogic.targetRange=[0,0,betNode.width - choumaUITran.width,betNode.height - choumaUITran.height];
playerLogic.setChouma(chouma,betN);
if(i==3){
if(i==3 && SystemParams.getInstance().getValue("isWatch") == 1){
playerLogic?.setData(data);
}
}
@ -135,6 +135,17 @@ export class TeenPattieGameSystem extends Component{
}
return playerSet;
}
/**根据服务器座位查找 */
public getPlayerDataSeatId(seatId:number):TeenPattiePlayerLogic{
let playerSet:TeenPattiePlayerLogic=null
for(let i=0;i<this._playerlist.length;i++){
if(this._playerlist[i].data?.SeatId == seatId){
playerSet = this._playerlist[i];
break
}
}
return playerSet;
}
/**清理所有玩家数据 */
public clearAllPlayerByData(){
for(let i=0;i<this._playerlist.length;i++){

67
assets/10001/src/game/system/TeenpattieGameProxySystem.ts

@ -1,6 +1,6 @@
import { Component, find } from "cc";
import { I18Manager, Message, Network, Sleep, UIManager, UIWindowMessage } from "../../sdk/API";
import { I18Manager, Message, Network, Sleep, SystemParams, UIManager, UIWindowMessage } from "../../sdk/API";
import { TeenPattieEventType } from "../../tool/TeenPattieEventType";
import { TeenPattieCommData } from "../TeenPattieCommData";
import { TeenPattieUpLayerLogic } from "../logic/TeenPattieUpLayerLogic";
@ -14,7 +14,6 @@ import { TeenPattiePathTool } from "../../tool/TeenPattiePathTool";
export class TeenpattieGameProxySystem extends Component {
/**当前出牌玩家ID */
private currChuPaiId: number;
private chagedIndex:number;
static upPlayer: TeenPattieUpLayerLogic;
static gameSystem:TeenPattieGameSystem;
@ -90,6 +89,10 @@ export class TeenpattieGameProxySystem extends Component {
this.resData = null;
Message.send(TeenPattieEventType.GameMatchTips,false);
Message.send(TeenPattieEventType.NextGame);
if(!TeenPattieCommData.getInstance().isCurrWatch){
TeenPattieCommData.getInstance().isCurrGame = true;
Message.send(TeenPattieEventType.SetCurrGameStatus);
}
this.isForceCompare = false;
TeenpattieGameProxySystem.upPlayer?.startCutDown(true,value.data);
Message.send(TeenPattieEventType.GameStart);
@ -135,6 +138,8 @@ export class TeenpattieGameProxySystem extends Component {
console.warn("当前玩家自己的ID为:",TeenPattieCommData.getInstance().playerSeatId);
/**所有玩家数据 */
const allData = value.data.data.seats;
/**所有观战玩家数据 */
const watchData = value.data.data.watchPlayerList;
//当前房间最小下注额
TeenPattieCommData.getInstance().gameBaseBet = value.data.data.curBaseBetNum;
@ -144,9 +149,16 @@ export class TeenpattieGameProxySystem extends Component {
TeenpattieGameProxySystem.gameSystem.clearAllPlayerByData();
if(value.data.data.ownCards) TeenPattieCommData.getInstance()._allKanPlayerCard.push(value.data.data.ownCards);
if(value.data.data.ownCards){
TeenPattieCommData.getInstance()._allKanPlayerCard.push(value.data.data.ownCards);
TeenPattieCommData.getInstance().isCurrGame = true;
}else{
TeenPattieCommData.getInstance().isCurrGame = false;
}
this.chagedIndex =userPlayer >= 3 ? -(userPlayer - 3) : (3 - userPlayer)
TeenPattieCommData.getInstance().isCurrWatch = false;
TeenPattieCommData.getInstance().chagedIndex =userPlayer >= 3 ? -(userPlayer - 3) : (3 - userPlayer)
for(let key in allData){
let data:any= allData[key];
let index:number = this.getPlayerIndex(data?.SeatId);
@ -154,6 +166,13 @@ export class TeenpattieGameProxySystem extends Component {
TeenPattieCommData.getInstance().allPlayerId.push(data?.SeatId);
TeenPattieCommData.getInstance()._allPlayerData.push(data);
}
for(let key in watchData){
let data:any= watchData[key];
TeenPattieCommData.getInstance().allWatchPlayerData.push(data);
if(data.Uid == UserData.userId){
TeenPattieCommData.getInstance().isCurrWatch = true;
}
}
Message.send(TeenPattieEventType.CurrRound, value.data.data.gameRound);
Message.send(TeenPattieEventType.BetTotal,value.data.data.betTotal);
@ -168,6 +187,7 @@ export class TeenpattieGameProxySystem extends Component {
return;
}
Message.send(TeenPattieEventType.SetCurrGameStatus);
//当前正在出牌的玩家
if(value.data.data.time <= 0) return;
const data = {
@ -179,7 +199,7 @@ export class TeenpattieGameProxySystem extends Component {
}
private getPlayerIndex(seatId:number):number{
const total:number = TeenPattieCommData.getInstance().totalPlayer;
let index:number=seatId + this.chagedIndex
let index:number=seatId + TeenPattieCommData.getInstance().chagedIndex;
if(index > total)index=index - total;
else if(index <= 0)index=index + total;
return index;
@ -209,6 +229,7 @@ export class TeenpattieGameProxySystem extends Component {
if(!this.isResetSeat) return;
this.isResetSeat = false;
TeenpattieGameProxySystem.gameSystem.clearAllPlayerByData();
const allData:any[] = TeenPattieCommData.getInstance().allPlayerData;
for(const item of allData){
item.status = 1;
@ -417,11 +438,12 @@ export class TeenpattieGameProxySystem extends Component {
/**玩家退出 */
private onPlayerOut(value: any) {
let index:number = this.getPlayerIndex(value.data.seatId)
// let index:number = this.getPlayerIndex(value.data.seatId)
const index:number = value.data.seatId;
console.warn("玩家退出ID", index);
const playerLogic:TeenPattiePlayerLogic=TeenpattieGameProxySystem.gameSystem.getPlayerBySeatId(index)
const playerLogic:TeenPattiePlayerLogic=TeenpattieGameProxySystem.gameSystem.getPlayerDataSeatId(index)
if(playerLogic){
if(index == 3){
if(index == TeenPattieCommData.getInstance().playerSeatId){
TeenPattieCommData.getInstance().isCloseRoom = true;
console.log("**onPlayerOut*****GameExit***");
Message.send(TeenPattieEventType.GameExit);
@ -452,18 +474,18 @@ export class TeenpattieGameProxySystem extends Component {
/**通知玩家观战转坐下 */
private notifyWatchToDown(data:any){
console.warn("通知玩家观战转坐下")
// this.watchToDown(data);
this.watchToDown(data.data);
}
/**通知玩家坐下转观战 */
private notifyDownToWatch(data:any){
console.warn("通知玩家坐下转观战")
// this.downToWatch(data.seatId);
this.downToWatch(data.data.seatId);
}
/**主动观战转坐下 */
private watchToDown(data:any){
for(const [index,item] of TeenPattieCommData.getInstance().allWatchPlayerData.entries()){
if(item.uid == data.uid){
if(item.Uid == data.uid){
item.SeatId = data.seatId;
TeenPattieCommData.getInstance().allPlayerId.push(item?.SeatId);
TeenPattieCommData.getInstance()._allPlayerData.push(item);
@ -472,12 +494,14 @@ export class TeenpattieGameProxySystem extends Component {
const ind:number = this.getPlayerIndex(item?.SeatId);
this.setPlayerJoinData(ind,item);
if(item.uid == UserData.userId){
if(item.Uid == UserData.userId){
TeenPattieCommData.getInstance().playerSeatId = item.SeatId;
TeenPattieCommData.getInstance().isCurrWatch = false;
SystemParams.getInstance().setValue("isWatch",0);
Message.send(TeenPattieEventType.SetCurrGameStatus);
const userPlayer = item?.SeatId;
this.chagedIndex =userPlayer >= 3 ? -(userPlayer - 3) : (3 - userPlayer);
TeenPattieCommData.getInstance().chagedIndex =userPlayer >= 3 ? -(userPlayer - 3) : (3 - userPlayer);
this.isResetSeat = true;
}else{
@ -489,16 +513,23 @@ export class TeenpattieGameProxySystem extends Component {
}
}
/**玩家坐下转观战 */
private downToWatch(chairId:number){
private downToWatch(seatId:number){
for(const [index,item] of TeenPattieCommData.getInstance().allPlayerData.entries()){
if(item.chairId == chairId){
if(item.uid == UserData.userId){
if(item.SeatId == seatId){
if(item.Uid == UserData.userId){
TeenPattieCommData.getInstance().isCurrWatch = true;
TeenPattieCommData.getInstance().playerSeatId = 0;
TeenPattieCommData.getInstance().playerSeatId = -1;
SystemParams.getInstance().setValue("isWatch",1);
Message.send(TeenPattieEventType.SetCurrGameStatus);
}
item.SeatId = 0;
item.SeatId = -1;
TeenPattieCommData.getInstance().allWatchPlayerData.push(item);
TeenPattieCommData.getInstance()._allPlayerData.splice(index,1);
TeenPattieCommData.getInstance().allPlayerId.splice(index,1);
const playerLogic:TeenPattiePlayerLogic=TeenpattieGameProxySystem.gameSystem.getPlayerDataSeatId(item.SeatId)
if(playerLogic){
playerLogic.clearPlayerData()
}
const str:string = TeenPattiePathTool.formatString(Game10001Res.getInstance().getString("game.tip.WatchBattle"),item.nickname);
window["Toast"]?.getInstance().showToast(str);

2
assets/10001/src/tool/TeenPattieEventType.ts

@ -57,4 +57,6 @@ export enum TeenPattieEventType{
GameRecover = "GameRecover",
/**退出游戏 */
GameExit = "GameExit",
/**设置当前玩家状态 */
SetCurrGameStatus = "SetCurrGameStatus",
}
Loading…
Cancel
Save