//被踢下线 void OnMsgKick(Request request) { NetManager.Close(); Transform root = GameObject.Find("Root").transform; Transform canvas = root.Find("Canvas"); Transform panel = canvas.Find("Panel"); Transform tip = canvas.Find("Tip"); for (int i = 0; i < panel.childCount; i++) { var child = panel.GetChild(i); PanelManager.Close(child.name); string[] name = child.name.Split('('); PanelManager.Close(name[0]); Debug.Log(name[0]); } for (int i = 0; i < tip.childCount; i++) { var child = tip.GetChild(i); string[] name = child.name.Split('('); PanelManager.Close(name[0]); Debug.Log(name[0]); } SceneManager.LoadSceneAsync("LoginMenu"); PanelManager.Open <LoginPanel>(); PanelManager.Open <TipPanel>("被踢下线"); }
/// <summary> /// 客户端收到出牌的协议,进行同步 /// </summary> /// <param name="msgBase"></param> public void OnMsgChuPai(MsgBase msgBase) { MsgChuPai msg = (MsgChuPai)msgBase; Debug.Log("PlayerId: " + msg.id); gamePanel.PlayerStateText = "玩家" + msg.id + "出牌"; if (msg.paiIndex == -1)//胡的情况 { Gender gender = players[msg.id].gender; switch (gender) { case Gender.Female: Audio.PlayCue(Audio.audioHuFemale); break; case Gender.Male: Audio.PlayCue(Audio.audioHuMale); break; } Debug.Log("胡牌成功!"); PanelManager.Open <GameoverPanel>(msg.id, client_id, -1); PanelManager.Close("GamePanel"); } else { players[msg.id].DiscardPai(msg.paiIndex); gamePanel.HandPaiCount = new int[] { (int)gamePanel.numToDir[msg.id], players[msg.id].handPai.Count }; } }
public static void EnterBattle(MsgEnterBattle msg) { BattleManager.Reset(); PanelManager.Close("RoomPanel"); PanelManager.Close("ResultPanel"); for (int i = 0; i < msg.tanks.Length; i++) { GenerateTank(msg.tanks[i]); } }
public void OnclickBT() { if (!GameObject.FindGameObjectWithTag("PANEL")) { SkillPanel skillPanel = Instantiate(skillPrefab, transform.parent.parent).GetComponent <SkillPanel>(); } else { PanelManager game = GameObject.FindGameObjectWithTag("PANEL").GetComponent <PanelManager>(); game.Close(); SkillPanel skillPanel = Instantiate(skillPrefab, transform.parent.parent).GetComponent <SkillPanel>(); } }
public void OnclickSetting() { if (!GameObject.FindGameObjectWithTag("PANEL")) { SettingPanel chrarter = Instantiate(settingPrefab, transform.parent.parent).GetComponent <SettingPanel>(); } else { PanelManager game = GameObject.FindGameObjectWithTag("PANEL").GetComponent <PanelManager>(); game.Close(); SettingPanel chrarter = Instantiate(settingPrefab, transform.parent.parent).GetComponent <SettingPanel>(); } }
public void OnclickItem() { if (!GameObject.FindGameObjectWithTag("PANEL")) { ChrarterPanel chrarter = Instantiate(chararcterPrefab, transform.parent.parent).GetComponent <ChrarterPanel>(); } else { PanelManager game = GameObject.FindGameObjectWithTag("PANEL").GetComponent <PanelManager>(); game.Close(); ChrarterPanel chrarter = Instantiate(chararcterPrefab, transform.parent.parent).GetComponent <ChrarterPanel>(); } }
public void OnclickQuest() { if (!GameObject.FindGameObjectWithTag("PANEL")) { QuestPanel chrarter = Instantiate(questPrefab, transform.parent.parent).GetComponent <QuestPanel>(); } else { PanelManager game = GameObject.FindGameObjectWithTag("PANEL").GetComponent <PanelManager>(); game.Close(); QuestPanel chrarter = Instantiate(questPrefab, transform.parent.parent).GetComponent <QuestPanel>(); } }
//收到战斗结束协议 public static void OnMsgBattleResult(MsgBase msgBase) { MsgBattleResult msg = (MsgBattleResult)msgBase; //判断显示胜利还是失败 bool isWin = false; BaseTank tank = GetCtrlTank(); if (tank != null && tank.camp == msg.winCamp) { isWin = true; } //显示界面 PanelManager.Open <ResultPanel>(isWin); //关闭界面 PanelManager.Close("AimPanel"); }
public void OnMsgQuit(MsgBase msgBase) { MsgQuit msg = (MsgQuit)msgBase; useQuitButton = msg.isQuit; if (msg.isQuit) { NetManager.Close(); Application.Quit(); } else { PanelManager.Open <TipPanel>("有人退出,游戏被迫中止!"); PanelManager.Open <GameoverPanel>(-1, client_id, msg.id); PanelManager.Close("GamePanel"); //直接平局 } }
//开始战斗 public static void EnterBattle(MsgEnterBattle msg) { //重置 BattleManager.Reset(); //关闭界面 PanelManager.Close("RoomPanel"); //可以放到房间系统的监听中 PanelManager.Close("ResultPanel"); PanelManager.Close("KillPanel"); PanelManager.Close("BattlePanel"); PanelManager.Close("AimPanel"); //产生坦克 for (int i = 0; i < msg.tanks.Length; i++) { GenerateTank(msg.tanks[i]); } //打开界面 PanelManager.Open <BattlePanel>(); PanelManager.Open <AimPanel>(); }
/// <summary> /// 客户端处理发牌协议 /// </summary> /// <param name="msgBase"></param> public void OnMsgFaPai(MsgBase msgBase) { Debug.Log("can receive msgFaPai"); MsgFaPai msg = (MsgFaPai)msgBase; nowTurnid = msg.id; if (msg.paiId == -1) { Debug.Log("没牌了,游戏结束"); PanelManager.Open <GameoverPanel>(-1, client_id, -1); PanelManager.Close("GamePanel"); return; } gamePanel.TurnText = msg.turnNum; //设置现在是第几轮了 gamePanel.TurnLight(msg.id); //切换灯光 if (msg.id == client_id) //如果是玩家,就显示出牌/发动技能/胡的按钮 { gamePanel.ChuPaiButton = true; if (msg.isHu) { gamePanel.HuButton = true; } if (msg.canSkill) { gamePanel.SkillButton = true; } } CreatePai(msg.paiId, msg.id); players[msg.id].SynHandPai(); //调整牌的顺序 players[msg.id].PlacePai(); //调整牌的位置 gamePanel.HandPaiCount = new int[] { (int)gamePanel.numToDir[msg.id], players[msg.id].handPai.Count }; gamePanel.PlayerStateText = "玩家" + (msg.id + 1) + "出牌"; isChuPai = true; //开始计时,玩家出牌 StartTimeCount(); }
//关闭 public void Close() { string name = this.GetType().ToString(); PanelManager.Close(name); }