コード例 #1
0
ファイル: Room.cs プロジェクト: innocence-ze/Server
    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);
    }
コード例 #2
0
ファイル: Room.cs プロジェクト: cocos56/TanksWar
    //开战
    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);
    }
コード例 #3
0
ファイル: BattleManager.cs プロジェクト: Severn17/UnityLearn
 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]);
     }
 }
コード例 #4
0
 //开始战斗
 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>();
 }
コード例 #5
0
    //收到进入战斗协议
    public static void OnMsgEnterBattle(MsgBase msgBase)
    {
        MsgEnterBattle msg = (MsgEnterBattle)msgBase;

        EnterBattle(msg);
    }