Пример #1
0
        public override void ProcessMessage(ConnectBase conn, ByteBuffer data)
        {
            int moduleId = data.readByte();

            switch (moduleId)
            {
            case LOAD:
            {
                int type      = data.readByte();
                int roomId    = data.readInt();
                int seed      = data.readInt();
                int frequency = data.readByte();
                int stairs    = data.readInt();
                int size      = data.readByte();
                List <BattlePlayerData> others = new List <BattlePlayerData>();
                for (int i = 0; i < size; ++i)
                {
                    BattlePlayerData player = new BattlePlayerData();
                    player.PlayerId   = data.readInt();
                    player.IsRobot    = data.readBoolean();
                    player.PlayerName = data.readUTF();
                    player.SceneId    = data.readByte();
                    player.HeroId     = data.readByte();
                    player.HP         = 5;
                    others.Add(player);
                }
                if (type == 1)
                {
                    BattleManager.GetInst().LoadDouble(roomId, seed, frequency, stairs, others);
                }
                else if (type == 2)
                {
                    BattleManager.GetInst().LoadFive(roomId, seed, frequency, stairs, others);
                }

                break;
            }

            case START:
            {
                BattleManager.GetInst().BattleStart();
                SocketHandler.GetInst().UdpStart();
                break;
            }

            case SYNC_HP:
            {
                int playerId = data.readInt();
                int hp       = data.readByte();
                BattleManager.GetInst().SyncHp(playerId, hp);
                break;
            }

            case GET_ITEM:
            {
                int playerId = data.readInt();
                int item     = data.readByte();
                BattleManager.GetInst().EnqueueSkill(playerId, item);
                break;
            }

            case RELEASE_SKILL:
            {
                int  fromId = data.readInt();
                int  toId   = data.readInt();
                int  type   = data.readByte();
                bool bMain  = data.readBoolean();
                BattleManager.GetInst().ReleaseSkill(fromId, toId, type);
                if (!bMain)
                {
                    BattleManager.GetInst().DequeueSkill(fromId);
                }
                break;
            }

            case RESULT:
            {
                BattleManager.GetInst().IsBattleRun = false;
                int playerId = data.readInt();
                BattleManager.GetInst().DisableHero(playerId);
                BattleResultPanel.GetInst().ShowPanel(playerId);
                break;
            }

            case HERO_FAILED:
            {
                int playerId = data.readInt();
                BattleManager.GetInst().SetFailed(playerId);
                break;
            }
            }
        }
Пример #2
0
 private void Awake()
 {
     _inst = this;
     BackBtn.onClick.AddListener(BackToMainScene);
 }