Exemplo n.º 1
0
        public Panelhandler(Lib.UserInputManager manager, UserInputKey key, KeyPointAction onOpen, KeyPointAction onClose,
                            bool blockEnv = true)
        {
            var openhandler      = new KeyHandler(Layer.Ui, BlockType.None);
            var closehandler     = new KeyHandler(Layer.Ui, BlockType.All);
            var openBlockhandler = blockEnv ? new PointerKeyHandler(Layer.Ui, BlockType.All) : null;

            openhandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(closehandler);
                manager.RegisterPointerhandler(openBlockhandler);
                manager.UnregisterKeyhandler(openhandler);
            });

            if (null != onOpen)
            {
                openhandler.BindKeyAction(key, onOpen);
            }

            closehandler.BindKeyAction(key, (data) =>
            {
                manager.RegisterKeyhandler(openhandler);
                manager.UnregisterKeyhandler(closehandler);
                manager.UnregisterPointerhandler(openBlockhandler);
            });
            if (null != onClose)
            {
                closehandler.BindKeyAction(key, onClose);
            }

            manager.RegisterKeyhandler(openhandler);
        }
Exemplo n.º 2
0
 public void RegisterSpecialCmdKeyInput(KeyHandler keyHandler, UserCmd userCmd)
 {
     keyHandler.BindKeyAction(UserInputKey.Switch1, (data) => userCmd.CurWeapon = (int)EWeaponSlotType.PrimeWeapon);
     keyHandler.BindKeyAction(UserInputKey.Switch3, (data) => userCmd.CurWeapon = (int)EWeaponSlotType.PistolWeapon);
     keyHandler.BindKeyAction(UserInputKey.Switch4, (data) => userCmd.CurWeapon = (int)EWeaponSlotType.MeleeWeapon);
     keyHandler.BindKeyAction(UserInputKey.Switch5, (data) => userCmd.CurWeapon = (int)EWeaponSlotType.ThrowingWeapon);
     keyHandler.BindKeyAction(UserInputKey.Switch6, (data) => userCmd.CurWeapon = (int)EWeaponSlotType.TacticWeapon);
 }
Exemplo n.º 3
0
 private void InitKey()
 {
     _openKeyHandler = new KeyHandler(Layer.Env, BlockType.None);
     _openKeyHandler.BindKeyAction(UserInputKey.ShowRecord, (data) => { _adapter.Enable = true; });
     _adapter.RegisterOpenKey(_openKeyHandler);
     _keyHandler = new KeyHandler(UiConstant.recordWindowKeyBlockLayer, BlockType.All);
     _keyHandler.BindKeyAction(UserInputKey.HideRecord, (data) => { _adapter.Enable = false; });
     _keyHandler.BindKeyAction(UserInputKey.HideWindow, (data) => { _adapter.Enable = false; });
 }
Exemplo n.º 4
0
 private void InitKey()
 {
     _openKeyHandler = new KeyHandler(UiConstant.userCmdKeyLayer, BlockType.None);
     _openKeyHandler.BindKeyAction(UserInputKey.OpenBag, (data) => { _adapter.Enable = true; });
     _adapter.RegisterOpenKey(_openKeyHandler);
     keyReveiver = new KeyHandler(UiConstant.userCmdUIKeyLayer, BlockType.All);
     keyReveiver.BindKeyAction(UserInputKey.OpenBag, (data) => { _adapter.Enable = false; });
     keyReveiver.BindKeyAction(UserInputKey.HideWindow, (data) => { _adapter.Enable = false; });
     _pointerKeyHandler = new PointerKeyHandler(UiConstant.userCmdUIKeyLayer, BlockType.All);
 }
Exemplo n.º 5
0
        public void InitKeyBinding()
        {
//            var handler = new Keyhandler(UiConstant.maxMapWindowLayer, BlockType.None);
//            handler.AddAction(UserInputKey.ShowMaxMap, (data) =>
//            {
//                if (root != null)
//                {
//                    ShowMap(!adapter.Enable);
//                }
//            });
//            //adapter.RegisterKeyReceive(handler);
//            adapter.RegisterOpenKey(handler);

            //            DynamicKeyReceive();
            _pointerKeyHandler = new PointerKeyHandler(UiConstant.maxMapWindowPointBlockLayer, BlockType.All);
            keyReceive         = new KeyHandler(UiConstant.maxMapWindowKeyBlockLayer, BlockType.All);
            keyReceive.BindKeyAction(UserInputKey.ChangeMapRate, OnChangeMapRate);
            keyReceive.BindKeyAction(UserInputKey.AddMark, (data) =>
            {
                if (MapLevel.Min.Equals(adapter.MapLevel) == false)
                {
                    Vector2 markPos = adapter.CurPlayerPos;
                    adapter.SendMarkMessage(markPos);
                }
            });
            keyReceive.BindKeyAction(UserInputKey.MouseAddMark, (data) =>
            {
                Vector2 hitPoint  = Vector2.zero;
                Vector2 hitPoint1 = Vector2.zero;
                if (MapLevel.Min.Equals(adapter.MapLevel) == false)
                {
                    if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rootRectTf, Input.mousePosition, uiCamera, out hitPoint1))
                    {
//                        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapBgRectTran, Input.mousePosition, uiCamera, out hitPoint))
//                        {
                        var markPos = _centerPos + hitPoint1 / rate;
                        adapter.SendMarkMessage(markPos);
//                        }
                    }
                }
            });
            keyReceive.BindKeyAction(UserInputKey.LocationCurPlay, OnLocationCurPlay);

//            keyReceive.AddAction(UserInputKey.HideWindow, (data) =>
//            {
//                if (adapter.Enable)
//                {
//                    ShowMap(!adapter.Enable);
//                }
//            });
        }
Exemplo n.º 6
0
 private void InitKeyBinding()
 {
     keyReveiver = new KeyHandler(UiConstant.splitWindowKeyBlockLayer, BlockType.All);
     keyReveiver.BindKeyAction(UserInputKey.SplitProp, (data) =>
     {
         if (!_viewModel.splitBtnInteractable)
         {
             return;
         }
         SendMessage();
         HideWindow();
     });
     keyReveiver.BindKeyAction(UserInputKey.HideWindow, (data) => { HideWindow(); });
 }
Exemplo n.º 7
0
        private void InitKeyhandler(UserInputContext context)
        {
            var keyHandler = new KeyHandler(Layer.Env + 2, BlockType.None);

            keyHandler.BindKeyAction(UserInputKey.LockCursor, (data) =>
            {
                //暂时屏蔽
                _contexts.ui.uI.IsShowCrossHair = true;
            });
            keyHandler.BindKeyAction(UserInputKey.UnlockCursor, (data) =>
            {
                //暂时屏蔽
                _contexts.ui.uI.IsShowCrossHair = false;
            });
            context.userInputManager.Instance.RegisterKeyhandler(keyHandler);
        }
Exemplo n.º 8
0
 void DynamicKeyBinding()
 {
     //保证 菜单界面打开的时候 打不开大地图界面
     _pointerKeyHandler = new PointerKeyHandler(UiConstant.menuWindowPointBlockLayer, BlockType.All);
     keyReceive         = new KeyHandler(UiConstant.menuWindowKeyBlockLayer, BlockType.All);
     keyReceive.BindKeyAction(UserInputKey.OpenMenu, (data) =>
     {
         ShowMenu(false);
     });
 }
Exemplo n.º 9
0
        public void InitKeyBinding()
        {
            var handler = new KeyHandler(UiConstant.menuWindowLayer, BlockType.None);

            handler.BindKeyAction(UserInputKey.OpenMenu, (data) =>
            {
                ShowMenu(true);
            });
            menuUiAdapter.RegisterOpenKey(handler);
            DynamicKeyBinding();
        }
Exemplo n.º 10
0
        private void InitKeyReveiver()
        {
            var keyhandler = new KeyHandler(UiConstant.chatWindowLayer, BlockType.None);

            keyhandler.BindKeyAction(UserInputKey.SendChatMessage, (data) =>
            {
                if (ChatListState != EUIChatListState.Send)
                {
                    SwitchToSendState();
                }
            });
            _switchKeyHandler = new KeyHandler(UiConstant.chatWindowKeyBlockLayer, BlockType.All);
            _switchKeyHandler.BindKeyAction(UserInputKey.SendChatMessage, (data) => { SendMessage(); });
            _switchKeyHandler.BindKeyAction(UserInputKey.SwitchChatChannel, (data) =>
            {
                SwitchChannel();
                UpdateChannel();
            });

            _chatState.RegisterOpenKey(keyhandler);
        }
Exemplo n.º 11
0
 private void InitKeyReveiver()
 {
     keyReveiver = new KeyHandler(UiConstant.weaponBagWindowKeyBlockLayer, BlockType.All);
     for (int i = 0; i < _haveBagForIndexList.Count; i++)
     {
         if (_haveBagForIndexList[i])
         {
             var index = i - 1;
             keyReveiver.BindKeyAction(UserInputKey.Switch1 + index,
                                       (data) => {
                 btnGroupTab.SetSelect(index);
                 CloseView();
             });
             keyReveiver.BindKeyAction(UserInputKey.HideWindow,
                                       (data) => {
                 CloseView();
             });
         }
     }
     _pointerKeyHandler = new PointerKeyHandler(UiConstant.weaponBagWindowKeyBlockLayer, BlockType.All);
 }
Exemplo n.º 12
0
        private void RegisterKeyBinding()
        {
            // 虽然是Ui但是其实层级应该是Env
            var keyreciever = new KeyHandler(Layer.Env, BlockType.None);

            keyreciever.BindKeyAction(UserInputKey.PickUp, OnAction);
            _pickUpUiAdapter.RegisterKeyhandler(keyreciever);

            var pointerhandler = new PointerKeyHandler(Layer.Env, BlockType.None);

            pointerhandler.BindPointAction(UserInputKey.PickUpTip, SetCastData);
            _pickUpUiAdapter.RegisterPointerhandler(pointerhandler);
        }
Exemplo n.º 13
0
 private void InitOpenKeyReveiver()
 {
     _openKeyHandler = new KeyHandler(UiConstant.weaponBagWindowLayer, BlockType.None);
     _openKeyHandler.BindKeyAction(UserInputKey.OpenWeaponBag, (data) =>
     {
         if (_adapter.CanOpenBag)
         {
             SwitchWeaponBagViewShow();
         }
     });
     _adapter.RegisterOpenKey(_openKeyHandler);
     //_adapter.RegisterKeyReceive(openKeyhandler);
 }
        public UnityVehicleCmdGenerator(UserInputManager.Lib.UserInputManager manager)
        {
            _lastCmd      = new VehicleCmd();
            _inputManager = manager;
            // 界面不会影响车辆控制
            var keyhandler = new KeyHandler(Layer.Ui, BlockType.None);

            _inputManager.RegisterKeyhandler(keyhandler);
            keyhandler.BindKeyAction(UserInputKey.MoveVertical, data => _lastCmd.MoveVertical     = data.Axis);
            keyhandler.BindKeyAction(UserInputKey.MoveHorizontal, data => _lastCmd.MoveHorizontal = data.Axis);
            keyhandler.BindKeyAction(UserInputKey.VehicleSpeedUp, data => _lastCmd.IsSpeedup      = true);
            keyhandler.BindKeyAction(UserInputKey.VehicleBrake, data => _lastCmd.IsHandbrake      = true);
            keyhandler.BindKeyAction(UserInputKey.VehicleHorn, data => _lastCmd.IsHornOn          = true);

            keyhandler.BindKeyAction(UserInputKey.VehicleLeftShift, data => _lastCmd.IsLeftShift   = true);
            keyhandler.BindKeyAction(UserInputKey.VehicleRightShift, data => _lastCmd.IsRightShift = true);
            keyhandler.BindKeyAction(UserInputKey.VehicleStunt, data => _lastCmd.IsStunt           = true);
        }
Exemplo n.º 15
0
        private void InitKeyBinding()
        {
            var handler = new KeyHandler(UiConstant.maxMapWindowLayer, BlockType.None);

            handler.BindKeyAction(UserInputKey.ShowMaxMap, (data) =>
            {
                ShowMap(!_adapter.Enable);
            });
            _adapter.RegisterOpenKey(handler);

            keyReceive = new KeyHandler(UiConstant.maxMapWindowKeyBlockLayer, BlockType.All);
            keyReceive.BindKeyAction(UserInputKey.HideWindow, (data) =>
            {
                if (_adapter.Enable)
                {
                    ShowMap(!_adapter.Enable);
                }
            });
        }
Exemplo n.º 16
0
        private void InitKeyBinding()
        {
            var handler = new KeyHandler(UiConstant.rangingWindowLayer, BlockType.None);

            handler.BindKeyAction(UserInputKey.CheckRanging, (data) =>
            {
                Debug.Log("CheckRanging..........................");
                var selfPlayer = adapter.GetPlayerEntity();
                if (selfPlayer.gamePlay.IsObserving())
                {
                    return;
                }
                var playerTrans = selfPlayer.characterContoller.Value.transform;

                var cameraPos     = selfPlayer.cameraObj.MainCamera.transform.position;
                var cameraForword = selfPlayer.cameraObj.MainCamera.transform.forward;

                RaycastHit hit;
                int bricksLayer = LayerMask.NameToLayer("Player");  //不检测player层级的东西
                int layerMask   = 1 << bricksLayer;
                layerMask       = ~layerMask;
                if (Physics.Raycast(cameraPos, cameraForword, out hit, int.MaxValue, layerMask))
                {
                    var hitPos   = hit.point;
                    var distance = Vector3.Distance(hitPos, playerTrans.position);
                    distance     = Mathf.Max(distance, 1);
                    //Debug.Log("name:" + hit.collider.gameObject.name);

                    if (adapter.RangeInfo == null)
                    {
                        adapter.RangeInfo = new RangingInfo((long)distance, hitPos);
                    }
                    else
                    {
                        adapter.RangeInfo.distance   = (long)distance;
                        adapter.RangeInfo.contactPos = hitPos;
                    }
                }
                RefreshGui();
            });
            adapter.RegisterKeyReceive(handler);
        }
Exemplo n.º 17
0
        //这里所有的操作层级都设置为Env,如果有特殊遮挡需求请修改层级并修改这段注释
        public void BeginReceiveUserInput(UserInputManager.Lib.UserInputManager manager)
        {
            userInputManager = manager;
            #region Env keyhandler

            // 有UI打开的情况下,不能开枪, 不能瞄准
            _specialKeyHandler = new KeyHandler(UiConstant.specicalCmdKeyLayer, BlockType.None);
            for (int i = 0; i < inputMapperList.Count; i++)
            {
                inputMapperList[i].RegisterSpecialCmdKeyInput(_specialKeyHandler, userCmd);
            }
            _specialKeyHandler.BindKeyAction(UserInputKey.Fire, (data) => userCmd.IsLeftAttack         = true);
            _specialKeyHandler.BindKeyAction(UserInputKey.RightAttack, (data) => userCmd.IsRightAttack = true);
            _specialKeyHandler.BindKeyAction(UserInputKey.CameraFocus, (data) => userCmd.IsCameraFocus = true);
            userInputManager.RegisterKeyhandler(_specialKeyHandler);

            _keyHandler = new KeyHandler(UiConstant.userCmdKeyLayer, BlockType.None);
            for (int i = 0; i < inputMapperList.Count; i++)
            {
                inputMapperList[i].RegisterEnvKeyInput(_keyHandler, userCmd);
            }
            _keyHandler.BindKeyAction(UserInputKey.SwitchFireMode, (data) => userCmd.IsSwitchFireMode = true);
            _keyHandler.BindKeyAction(UserInputKey.DrawWeapon, (data) => userCmd.IsDrawWeapon         = true);
            _keyHandler.BindKeyAction(UserInputKey.Throwing, (data) => userCmd.IsThrowing             = true);
            _keyHandler.BindKeyAction(UserInputKey.FirstPerson, (data) => userCmd.ChangeCamera        = true);
            _keyHandler.BindKeyAction(UserInputKey.FreeCamera, (data) => userCmd.IsCameraFree         = true);
            _keyHandler.BindKeyAction(UserInputKey.Jump, (data) => userCmd.IsJump     = true);
            _keyHandler.BindKeyAction(UserInputKey.Crouch, (data) => userCmd.IsCrouch = true);
            _keyHandler.BindKeyAction(UserInputKey.Prone, (data) => userCmd.IsProne   = true);
            //keyhandler.AddAction(UserInputKey.Injured, (data) => userCmd.BeState = 2);
            //keyhandler.AddAction(UserInputKey.Swim, (data) => userCmd.BeState = 1);
            _keyHandler.BindKeyAction(UserInputKey.Reload, (data) => userCmd.IsReload             = true);
            _keyHandler.BindKeyAction(UserInputKey.PeekLeft, (data) => userCmd.IsPeekLeft         = true);
            _keyHandler.BindKeyAction(UserInputKey.PeekRight, (data) => userCmd.IsPeekRight       = true);
            _keyHandler.BindKeyAction(UserInputKey.SwitchWeapon, (data) => userCmd.IsSwitchWeapon = true);
            _keyHandler.BindKeyAction(UserInputKey.DropWeapon, (data) => userCmd.IsDropWeapon     = true);
            _keyHandler.BindKeyAction(UserInputKey.Switch1, data => userCmd.SwitchNumber          = 1);
            _keyHandler.BindKeyAction(UserInputKey.Switch7, data => userCmd.SwitchNumber          = 7);
            _keyHandler.BindKeyAction(UserInputKey.IsPDown, data => userCmd.IsPDown               = true);
            _keyHandler.BindKeyAction(UserInputKey.IsYDown, data => userCmd.IsYDown               = true);
            _keyHandler.BindKeyAction(UserInputKey.AddMark, data => userCmd.IsAddMark             = true);
            _keyHandler.BindKeyAction(UserInputKey.BreathHold, data => userCmd.IsHoldBreath       = true);
            _keyHandler.BindKeyAction(UserInputKey.SwitchAutoRun, data => userCmd.IsSwitchAutoRun = true);
            _keyHandler.BindKeyAction(UserInputKey.IsCDown, data => userCmd.IsCDown               = true);
            _keyHandler.BindKeyAction(UserInputKey.IsSpaceDown, data => userCmd.IsSpaceDown       = true);
            _keyHandler.BindKeyAction(UserInputKey.HoldF, data => userCmd.IsF = true);
            _keyHandler.BindKeyAction(UserInputKey.SprayPaint, data => userCmd.IsSprayPaint = true);
            _keyHandler.BindKeyAction(UserInputKey.ScopeIn, data => userCmd.IsScopeIn       = true);
            _keyHandler.BindKeyAction(UserInputKey.ScopeOut, data => userCmd.IsScopeOut     = true);
            userInputManager.RegisterKeyhandler(_keyHandler);

            #endregion
            _bioSpecialKeyHandler = new KeyHandler(UiConstant.specicalCmdKeyLayer, BlockType.None);
            _bioSpecialKeyHandler.BindKeyAction(UserInputKey.Fire, (data) => userCmd.IsLeftAttack         = true);
            _bioSpecialKeyHandler.BindKeyAction(UserInputKey.RightAttack, (data) => userCmd.IsRightAttack = true);
            _bioSpecialKeyHandler.BindKeyAction(UserInputKey.CameraFocus, (data) => userCmd.IsCameraFocus = true);

            _bioKeyHandler = new KeyHandler(UiConstant.userCmdKeyLayer, BlockType.None);
            _bioKeyHandler.BindKeyAction(UserInputKey.Throwing, (data) => userCmd.IsThrowing         = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.FreeCamera, (data) => userCmd.IsCameraFree     = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.Jump, (data) => userCmd.IsJump                 = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.Crouch, (data) => userCmd.IsCrouch             = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.Prone, (data) => userCmd.IsProne               = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.IsPDown, data => userCmd.IsPDown               = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.IsYDown, data => userCmd.IsYDown               = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.AddMark, data => userCmd.IsAddMark             = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.BreathHold, data => userCmd.IsHoldBreath       = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.SwitchAutoRun, data => userCmd.IsSwitchAutoRun = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.IsCDown, data => userCmd.IsCDown               = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.IsSpaceDown, data => userCmd.IsSpaceDown       = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.HoldF, data => userCmd.IsF = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.SprayPaint, data => userCmd.IsSprayPaint = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.ScopeIn, data => userCmd.IsScopeIn       = true);
            _bioKeyHandler.BindKeyAction(UserInputKey.ScopeOut, data => userCmd.IsScopeOut     = true);
            #region bioMain


            #endregion

            #region Ui Keyreciever

            _uKeyHandler = new KeyHandler(UiConstant.userCmdUIKeyLayer, BlockType.None);
            _uKeyHandler.BindKeyAction(UserInputKey.MoveHorizontal, (data) => userCmd.MoveHorizontal = data.Axis);
            _uKeyHandler.BindKeyAction(UserInputKey.MoveVertical, (data) => userCmd.MoveVertical     = data.Axis);
            _uKeyHandler.BindKeyAction(UserInputKey.MoveUpDown, (data) => userCmd.MoveUpDown         = data.Axis);
            _uKeyHandler.BindKeyAction(UserInputKey.Run, (data) => userCmd.IsRun             = true);
            _uKeyHandler.BindKeyAction(UserInputKey.IsTabDown, data => userCmd.IsTabDown     = true);
            _uKeyHandler.BindKeyAction(UserInputKey.SlightWalk, data => userCmd.IsSlightWalk = true);
            userInputManager.RegisterKeyhandler(_uKeyHandler);

            #endregion

#if UNITYEDITOR
            foreach (var mockCmd in mockCmdList)
            {
                mockCmd(userCmd);
            }
#endif

            var pointerhandler = new PointerKeyHandler(UiConstant.userCmdPointLayer, BlockType.None);
            pointerhandler.BindPointAction(UserInputKey.Yaw, (keyData) =>
            {
                var pointerData = keyData as PointerData;
                for (int i = 0; i < yaws.Length - 1; i++)
                {
                    yaws[i] = yaws[i + 1];
                }
                yaws[yaws.Length - 1] = pointerData.MouseX;
                float total           = 0;
                for (int i = yaws.Length - 1; i >= Math.Max(0, yaws.Length - BigMapDebug.SmoothFactor); i--)
                {
                    total = total + yaws[i];
                }
                total = total / (float)BigMapDebug.SmoothFactor;
                //Debug.LogFormat("deltaYaw is {0}, deltaTime {1}", total, Time.deltaTime);
#if UNITYEDITOR
                if (!Cursor.visible)
                {
                    userCmd.DeltaYaw = total;
                }
#else
                userCmd.DeltaYaw = total;
#endif
            });
            pointerhandler.BindPointAction(UserInputKey.Pitch, (keyData) =>
            {
                var pointerData = keyData as PointerData;
                for (int i = 0; i < pitchs.Length - 1; i++)
                {
                    pitchs[i] = pitchs[i + 1];
                }
                pitchs[pitchs.Length - 1] = pointerData.MouseY;
                float total = 0;
                for (int i = pitchs.Length - 1; i >= Math.Max(0, pitchs.Length - BigMapDebug.SmoothFactor); i--)
                {
                    total = total + pitchs[i];
                }
                total = total / (float)BigMapDebug.SmoothFactor;
#if UNITYEDITOR
                if (!Cursor.visible)
                {
                    userCmd.DeltaPitch = -total;
                }
#else
                userCmd.DeltaPitch = -total;
#endif
            });

            userInputManager.RegisterPointerhandler(pointerhandler);
        }
Exemplo n.º 18
0
 private void InitKey()
 {
     _keyHandler = new KeyHandler(Layer.System, BlockType.None);
     _keyHandler.BindKeyAction(UserInputKey.ShowDebug, (data) => { _adapter.Enable = !_adapter.Enable; });
     _adapter.RegisterKeyReceive(_keyHandler);
 }