Example #1
0
        private void OnRoomInfo(Packet packet)
        {
            this._root.CloseModalWait();

            _DTO_room_info_detail dto = (( _PACKET_ROOM_ACMD_ROOM_INFO )packet).dto;

            GComboBox maps = this._root["map"].asComboBox;

            maps.value = dto.map;

            GComboBox heros = this._root["hero"].asComboBox;

            _DTO_player_info[] players = dto.players;
            GList t1 = this._root["t1"].asCom["list"].asList;
            GList t2 = this._root["t2"].asCom["list"].asList;

            t1.RemoveChildrenToPool();
            t2.RemoveChildrenToPool();
            for (int i = 0; i < players.Length; i++)
            {
                _DTO_player_info infoDto = players[i];
                GComponent       item    = infoDto.team == 0 ? t1.AddItemFromPool().asCom : t2.AddItemFromPool().asCom;
                item.GetController("c1").selectedIndex = 0;
                item["name"].asTextField.text          = infoDto.name;
                item.GetController("c1").selectedIndex = infoDto.ready ? 1 : 0;
                if (infoDto.uid == CUser.id)
                {
                    heros.value = infoDto.cid;
                }
            }
            this._root["name"].asTextField.text = dto.name;

            GButton fightBtn = this._root["fightBtn"].asButton;

            if (dto.host == CUser.id)
            {
                this._root.GetController("c1").selectedIndex = 0;
                bool isAllPlayerReady = this.IsAllPlayerReady(dto);
                if (isAllPlayerReady)
                {
                    fightBtn.grayed    = false;
                    fightBtn.touchable = true;
                }
                else
                {
                    fightBtn.grayed    = true;
                    fightBtn.touchable = false;
                }
            }
            else
            {
                this._root.GetController("c1").selectedIndex = 1;
            }
        }
Example #2
0
        private bool IsAllPlayerReady(_DTO_room_info_detail dto)
        {
            _DTO_player_info[] players = dto.players;
            int count = players.Length;

            for (int i = 0; i < count; i++)
            {
                if (players[i].uid == dto.host)
                {
                    continue;
                }
                if (!players[i].ready)
                {
                    return(false);
                }
            }
            return(true);
        }