public bool StartBattle() { if (!CanStartBattle()) { return(false); } status = Status.FIGHT; ResetPlayers(); MsgEnterBattle msg = new MsgEnterBattle { mapId = 1, tanks = new TankInfo[playerDic.Count] }; int i = 0; foreach (string id in playerDic.Keys) { Player player = PlayerManager.GetPlayer(id); if (player != null) { msg.tanks[i] = PlayerToTankInfo(player); } i++; } Broadcast(msg); return(true); }
//开战 public bool StartBattle() { if (!CanStartBattle()) { return(false); } //状态 status = Status.FIGHT; //玩家战斗属性 ResetPlayers(); //返回数据 MsgEnterBattle msg = new MsgEnterBattle(); msg.mapId = 1; msg.tanks = new TankInfo[playerIds.Count]; int i = 0; foreach (string id in playerIds.Keys) { Player player = PlayerManager.GetPlayer(id); msg.tanks[i] = PlayerToTankInfo(player); i++; } Broadcast(msg); return(true); }
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 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>(); }
//收到进入战斗协议 public static void OnMsgEnterBattle(MsgBase msgBase) { MsgEnterBattle msg = (MsgEnterBattle)msgBase; EnterBattle(msg); }