Example #1
0
        public override void OnOperationRequest(OperationRequest request, SendParameters sendParameters, MobaPeer peer)
        {
            MobaServer.LogInfo("处理选人界面的聊天请求");

            int        playerId = UserManager.GetPlayer(peer.Username).Identification;
            SelectRoom room     = Caches.Select.GetRoomByPlayerId(playerId);

            if (room == null)
            {
                MobaServer.LogError(">>>>> 异常:玩家找不到房间 TalkInSelectHandler");
                return;
            }

            // 将聊天内容发给所有客户端 测试方便
            room.Brocast(OperationCode.TalkInSelect, request.Parameters);
        }
Example #2
0
        private void OnChat(MOBAClient client, string text)
        {
            //给当前客户端所在的房间内的所有人发一条消息
            PlayerModel playerModel = playerCache.GetPlayerModel(client);

            if (playerModel == null)
            {
                return;
            }
            SelectRoom selectRoom = selectCache.GetRoom(playerModel.Id);

            if (selectRoom != null)
            {
                string str = string.Format("{0}:{1}", playerModel.Name, text);
                selectRoom.Broadcast(OperationCode.SelectCode, OpSelect.Chat, 0, "有玩家发言了", null, str);
            }
        }
Example #3
0
        /// <summary>
        /// 聊天,给房间所有人发聊天信息
        /// </summary>
        /// <param name="client"></param>
        /// <param name="text"></param>
        private void onTalk(MobaClient client, string text)
        {
            //服务器输出到日志文件的日志
            //MobaApplication.LogInfo(text);
            //给当前客户端所在的房间内所有人发一条消息
            PlayerModel player = playerCache.GetModel(client);

            if (player == null)
            {
                return;
            }

            SelectRoom room = selectCache.GetRoom(player.Id);
            //角色名:说了什么
            string str = string.Format("{0} : {1}", player.Name, text);

            room.Brocast(OpCode.SelectCode, OpSelect.Talk, 0, "有玩家发言了", null, str);
        }
Example #4
0
        private void OnTalk(MobaClient client, string context)
        {
            //给房间内的当前客户端所有人发一条消息:context
            PlayerModel player = playerCache.GetModel(client);

            if (player == null)
            {
                return;
            }
            SelectRoom room = selectCache.GetRoom(player.Id);

            if (room == null)
            {
                return;
            }
            string str = string.Format("{0} : {1}", player.Name, context);

            room.Brocast(OpCode.SelectCode, OpSelect.Talk, 0, "有玩家发言了", null, str);
        }
Example #5
0
        private void Create(List <int> teamOne, List <int> teamTwo)
        {
            SelectRoom room;

            if (!roomCache.TryPop(out room))
            {
                room = new SelectRoom();
                //设置唯一区域号
                room.SetArea(index.GetAndAdd());
            }

            room.Init(teamOne, teamTwo);

            foreach (int i in teamOne)
            {
                userIdToRoomId.TryAdd(i, room.GetArea());
            }
            foreach (int i in teamTwo)
            {
                userIdToRoomId.TryAdd(i, room.GetArea());
            }
            roomIdMap.TryAdd(room.GetArea(), room);
        }
Example #6
0
        /// <summary>
        /// 玩家确认选择
        /// </summary>
        /// <param name="client"></param>
        private void onReady(MobaClient client)
        {
            int        playerId = playerCache.GetId(client);
            SelectRoom room     = selectCache.Ready(playerId);

            if (room == null)
            {
                //告诉他自己确认失败
                Send(client, OpCode.SelectCode, OpSelect.Ready, -1, "确认失败");
                return;
            }
            //告诉房间所有人此人确认选择了
            room.Brocast(OpCode.SelectCode, OpSelect.Ready, 0, "有人确认选择了", null, playerId);
            //判断是否全部准备了 如果全部准备了 就开始战斗
            if (room.IsAllReady)
            {
                //TODO
                this.StartFightEvent(room.team1Dict.Values.ToList(), room.team2Dict.Values.ToList());
                //给客户端发送消息 准备战斗 切换场景
                room.Brocast(OpCode.SelectCode, OpSelect.StartFight, 0, "准备进入战斗场景", null);
                //销毁房间
                selectCache.Destroy(room.Id);
            }
        }
 private void Button_Click(int index)
 {
     Menu.Hide();
     SelectRoom?.Invoke(index);
 }
Example #8
0
        public void Update()
        {
            if (vrPlaying)
            {
                if (Api.IsCloseButtonPressed)
                {
                    StartCoroutine(StopXR());
                    Exit?.Invoke();
                }

                if (Api.IsGearButtonPressed)
                {
                    Api.ScanDeviceParams();
                }

                Api.UpdateScreenParams();

                var doRaycast = (Bear.activeInHierarchy && !avatarAwake) || Menu.gameObject.activeInHierarchy;

                if (doRaycast)
                {
                    // See if we are looking at the bear
                    var        progressDelta = 0f;
                    RaycastHit hit;
                    if (Physics.Raycast(Cam.transform.position, Cam.transform.forward, out hit))
                    {
                        progressDelta = (1 / ProgressSpeed) * Time.deltaTime;
                    }
                    if (progressDelta > 0)
                    {
                        if (progress < 1)
                        {
                            progress = Mathf.Clamp01(progress + progressDelta);
                            if (GazeProgress)
                            {
                                GazeProgress.fillAmount = progress;
                            }
                            if (progress == 1)
                            {
                                GazeProgress.fillAmount = 0;
                                if (hit.collider.gameObject == Bear)
                                {
                                    Bootstrap.Facade.SendNotification(StoryMediator.Notifications.AvatarClicked);
                                    avatarAwake = true;
                                }
                                else
                                {
                                    var menuItem = Array.IndexOf(MenuColliders, hit.collider.gameObject);
                                    if (menuItem > 0)
                                    {
                                        SelectRoom?.Invoke(menuItem);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        progress = 0;
                    }
                }

                if (Spinner.activeInHierarchy)
                {
                    Spinner.transform.Rotate(Vector3.forward, SpinnerRotateSpeed * Time.deltaTime);
                }
#if UNITY_EDITOR
                var mouseDelta = lastMousePos - Input.mousePosition;
                lastMousePos = Input.mousePosition;
                var rotate = new Vector3(mouseDelta.y, -mouseDelta.x, 0) * Time.deltaTime * MouseRotateSpeed;
                CamRoot.transform.Rotate(rotate);

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    StopXR();
                    Exit?.Invoke();
                }
#endif
            }
        }
 static void SelectRoom()
 {
     MainLogic.SelectRoom selectRoom = new SelectRoom();
     selectRoom.RoomSelect();
 }