コード例 #1
0
 void DynamicKeyBinding()
 {
     //保证 菜单界面打开的时候 打不开大地图界面
     _pointerKeyHandler = new PointerKeyHandler(UiConstant.menuWindowPointBlockLayer, BlockType.All);
     keyReceive         = new KeyHandler(UiConstant.menuWindowKeyBlockLayer, BlockType.All);
     keyReceive.BindKeyAction(UserInputKey.OpenMenu, (data) =>
     {
         ShowMenu(false);
     });
 }
コード例 #2
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);
 }
コード例 #3
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);
        }
コード例 #4
0
ファイル: CommonMap.cs プロジェクト: yangfan111/CsharpCode
        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);
//                }
//            });
        }
コード例 #5
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);
 }
コード例 #6
0
        public void InitKeyBinding()
        {
            var handler = new PointerKeyHandler(UiConstant.maxMapWindowLayer, BlockType.None);

            handler.BindPointAction(UserInputKey.PickUpTip, (data) =>
            {
                var pointerData = data as PointerData;

                var type = pointerData.IdList[0];
                switch ((ECastDataType)type)
                {
                case ECastDataType.Player:
                    selectedPlayerId = PlayerCastData.EntityId(pointerData.IdList);
                    //Debug.Log(selectedPlayerId);
                    break;

                default: selectedPlayerId = 0;
                    break;
                }
            });
            playerInfoUIAdapter.RegisterPointerReceive(handler);
        }
コード例 #7
0
 private void IniTKeyHandler()
 {
     _pointerKeyHandler = new PointerKeyHandler(UiConstant.specicalCmdKeyLayer - 1, BlockType.All);
     _keyHandler        = new KeyHandler(UiConstant.specicalCmdKeyLayer - 1, BlockType.All);
 }
コード例 #8
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);
        }
コード例 #9
0
ファイル: UIAdapter.cs プロジェクト: yangfan111/CsharpCode
 public void UnRegisterPointerReceive(PointerKeyHandler pointReceive)
 {
     UserInputManager.Instance.UnregisterPointerhandler(pointReceive);
 }
コード例 #10
0
 public void RegisterPointerhandler(PointerKeyHandler handler)
 {
     userInputManager.RegisterPointerhandler(handler);
 }
コード例 #11
0
 private void IniTKeyHandler()
 {
     _pointerKeyHandler = new PointerKeyHandler(Layer.Env, BlockType.All);
     _keyHandler        = new KeyHandler(Layer.Env, BlockType.All);
 }