Beispiel #1
0
        public override void Setup(object data = null)
        {
            base.Setup(data);

            RoomInfo roomInfo = data as RoomInfo;

            this.roomInfo = roomInfo;

            if (roomInfo == null)
            {
                throw new UnityException($"EnterRoomView: need setup parameter typeof RoomInfo");
            }

            roomNameText.text = resourceService.GetString(roomInfo.roomData.nameId);
            listView.Setup(new ListView <Data.InventoryItem> .ListViewData {
                dataList = ravenhillGameModeService.FilterCollectableForRoom(roomInfo)
            });

            UpdateUnlockLevelText(roomInfo);
            UpdateButtons(roomInfo);

            marketAdView.Setup(resourceService.marketItems.RandomElement());
            roomInfoView.Setup(roomInfo);

            INetRoom netRoom = new NetRoom(roomInfo.id, ravenhillGameModeService.roomMode);

            bestResultView.Setup(netService.GetBestRoomScore(netRoom));
            myBestResultView.Setup(netService.GetPlayerBestRoomScore(netRoom));
            closeBigButton.SetListener(Close, engine.GetService <IAudioService>());
        }
Beispiel #2
0
        public override void Setup(object data = null)
        {
            base.Setup(data);

            session = data as SearchSession;
            if (session == null)
            {
                throw new ArgumentException($"ExitRoomView.Setup() required argument of type {typeof(SearchSession).Name}");
            }

            roomNameText.text = resourceService.GetString(session.roomData.nameId);


            Debug.Log($"session drop list {session.roomDropList.Count}".Colored(ColorType.yellow));

            InventoryItemListView.ListViewData listViewData = new InventoryItemListView.ListViewData {
                dataList = session.roomDropList
            };
            listView.Setup(listViewData);

            if (session.roomDropList.Count == 0)
            {
                notFoundAnyItemsInfoObject?.ActivateSelf();
            }
            else
            {
                notFoundAnyItemsInfoObject?.DeactivateSelf();
            }

            if (session.searchStatus == SearchStatus.success)
            {
                searchStatusText.text = resourceService.GetString("status_success");
                engine.GetService <IAudioService>().PlaySound(SoundType.room_success, GetComponent <AudioSource>());
            }
            else
            {
                searchStatusText.text = resourceService.GetString("status_fail");
                engine.GetService <IAudioService>().PlaySound(SoundType.room_fail, GetComponent <AudioSource>());
            }

            if (session.searchStatus == SearchStatus.success)
            {
                expSilverRewardParent.ActivateSelf();
                expRewardCountText.SetValue(0, ravenhillGameModeService.GetModifiedExpCount(session.roomId, session.roomData.expReward));
                silverRewardCountText.SetValue(0, ravenhillGameModeService.GetModifiedSilverCount(session.roomId, session.roomData.silverReward));
            }
            else
            {
                expSilverRewardParent.DeactivateSelf();
            }

            marketAdItemView.Setup(resourceService.marketItems.RandomElement());

            roomInfoView.Setup(session.roomInfo);

            INetRoom netRoom = new NetRoom(session.roomId, session.RoomMode);

            bestRoomScore.Setup(netService.GetBestRoomScore(netRoom));
            myBestRoomScore.Setup(netService.GetPlayerBestRoomScore(netRoom));
            currentScoreView.Setup(session);

            timeText.text = Utility.FormatMS(session.searchTime);

            closeBigButton.SetListener(Close, engine.GetService <IAudioService>());
        }
Beispiel #3
0
        protected override async Task OnMessage(MessageEventArgs e)
        {
            using (StreamReader sr = new StreamReader(e.Data))
            {
                string      json = sr.ReadToEnd();
                NetInfoBase bas  = JsonConvert.DeserializeObject <NetInfoBase>(json);
                string      data = bas.JsonData;
                if (this.OnGameData != null)
                {
                    this.OnGameData(this, bas);
                }
                switch ((RoomOrderType)bas.OrderType)
                {
                case RoomOrderType.连接到房间:
                {
                    var    obj    = JsonConvert.DeserializeAnonymousType(data, new { roomid = "", pid = "" });
                    string pid    = obj.pid;
                    string roomid = obj.roomid;
                    //找到对应房间
                    GameRoom room = Management.GetRoom(roomid);
                    if (room == null)
                    {
                        return;
                    }
                    //判断是否添加玩家到房间
                    Player p = Management.GetOnlinePlayer(pid);
                    if (!room.HasPlayer(pid))
                    {
                        room.AddPlayer(p);
                        p.RoomWhich = room;
                    }
                    //绑定玩家到会话
                    this.BindPlayer = p;
                    RoomBinding(p.RoomWhich);
                    p.SetRoomWebSok(this);
                    //创建房间实体类
                    NetRoom nr = new NetRoom(room);
                    //广播房间信息
                    room.BroadCast(JsonConvert.SerializeObject(nr), RoomOrderType.回送房间信息);
                    Log.Print("玩家" + this.BindPlayer.Name + "成功连接到房间");
                    break;
                }

                case RoomOrderType.玩家准备:
                {
                    this.BindRoom.SetReady(this.BindPlayer);
                    this.BindPlayer.LastSendRoomData("", RoomOrderType.玩家准备, this.BindPlayer.PlayerID);
                    this.BindPlayer.NextSendRoomData("", RoomOrderType.玩家准备, this.BindPlayer.PlayerID);
                    break;
                }

                case RoomOrderType.踢出玩家:
                {
                    var pid = bas.Tag;
                    this.BindRoom.BroadCast("", RoomOrderType.踢出玩家, pid);
                    //将玩家从房间删除
                    this.BindRoom.RemovePlayer(pid);
                    break;
                }
                }
            }
        }