Esempio n. 1
0
 private void EnterBattle(TcpEnterBattleMessage bm)
 {
     Debug.Log("进入战场");
     BattleData.Instance.UpdateBattleInfo(bm.Seed, bm.BattleUserInfos);
     //  LoadScene 战场场景
     SceneManager.LoadSceneAsync(1);
 }
Esempio n. 2
0
    public void CreateBattle()
    {
        int randSeed = UnityEngine.Random.Range(0, 100);

        ThreadPool.QueueUserWorkItem((obj) =>
        {
            dic_battleUserUid = new Dictionary <int, int>();
            dic_udp           = new Dictionary <int, ServerClientUdp>();
            dic_battleReady   = new Dictionary <int, bool>();

            int userBattleID = 1;

            TcpEnterBattleMessage bm = new TcpEnterBattleMessage(randSeed);
            foreach (MatchUserInfo info in group)
            {
                dic_battleUserUid[info.uid] = userBattleID;

                ServerClientUdp clientUdp = new ServerClientUdp(info.conn.GetIP(), info.uid, HandleMsg);
                clientUdp.StartClientUdp();
                dic_udp[userBattleID]         = clientUdp;
                dic_battleReady[userBattleID] = false;

                BattleUserInfo _bUser = new BattleUserInfo(info.uid, userBattleID);
                bm.Add(_bUser);
                userBattleID++;
            }

            foreach (MatchUserInfo info in group)
            {
                //  发送BattleEnterMessage
                Protocol p = new Protocol(bm);
                info.conn.Send(new Protocol(bm));
            }
        });
    }
Esempio n. 3
0
    private void OnMatchBack(Protocol protocol)
    {
        TcpEnterBattleMessage mm = protocol.Decode <TcpEnterBattleMessage>();

        Debug.Log("接收服务器发送的匹配完成信息" + mm.ToString());
        //  根据服务器发来的匹配信息,进入游戏
        //  ......
        ClientGlobal.Instance.AddAction(() => {
            EnterBattle(mm);
        });
    }