private void InitKey() { openKeyReceiver = new KeyReceiver(UiConstant.userCmdKeyLayer, BlockType.None); openKeyReceiver.AddAction(UserInputKey.OpenBag, (data) => { _adapter.Enable = true; }); _adapter.RegisterOpenKey(openKeyReceiver); keyReveiver = new KeyReceiver(UiConstant.userCmdUIKeyLayer, BlockType.All); keyReveiver.AddAction(UserInputKey.OpenBag, (data) => { _adapter.Enable = false; }); pointerReceiver = new PointerReceiver(UiConstant.userCmdUIKeyLayer, BlockType.All); }
void DynamicKeyBinding() { //保证 菜单界面打开的时候 打不开大地图界面 pointerReceiver = new PointerReceiver(UiConstant.menuWindowPointBlockLayer, BlockType.All); keyReceive = new KeyReceiver(UiConstant.menuWindowKeyBlockLayer, BlockType.All); keyReceive.AddAction(UserInputKey.OpenMenu, (data) => { ShowMenu(false); }); }
private void InitKey() { openKeyReceiver = new KeyReceiver(UiConstant.paintWindowLayer, BlockType.None); openKeyReceiver.AddAction(UserInputKey.F1, (data) => { _adapter.Enable = true; }); //_adapter.RegisterKeyReceive(openKeyReceiver); _adapter.RegisterOpenKey(openKeyReceiver); keyReveiver = new KeyReceiver(UiConstant.paintWindowKeyBlockLayer, BlockType.All); keyReveiver.AddAction(UserInputKey.F1, (data) => { _adapter.Enable = false; }); pointerReceiver = new PointerReceiver(UiConstant.paintWindowKeyBlockLayer, BlockType.All); }
public void InitKeyBinding() { //屏幕所有操作 pointerReceiver = new PointerReceiver(UiConstant.noticeWindowPointBlockLayer, BlockType.All); //屏蔽所有操作 keyReceive = new KeyReceiver(UiConstant.noticeWindowKeyBlockLayer, BlockType.All); keyReceive.AddAction(UserInputKey.HideWindow, (data) => { HideWindow(); }); }
public void InitKeyBinding() { var receiver = new KeyReceiver(UiConstant.maxMapWindowLayer, BlockType.None); receiver.AddAction(UserInputKey.ShowMaxMap, (data) => { if (root != null) { ShowMap(!adapter.Enable); } }); //adapter.RegisterKeyReceive(receiver); adapter.RegisterOpenKey(receiver); // DynamicKeyReceive(); pointerReceiver = new PointerReceiver(UiConstant.maxMapWindowPointBlockLayer, BlockType.All); keyReceive = new KeyReceiver(UiConstant.maxMapWindowKeyBlockLayer, BlockType.All); keyReceive.AddAction(UserInputKey.ChangeMapRate, OnChangeMapRate); keyReceive.AddAction(UserInputKey.AddMark, (data) => { if (MapLevel.Min.Equals(adapter.MapLevel) == false) { Vector2 markPos = adapter.CurPlayerPos; adapter.SendMarkMessage(markPos); } }); keyReceive.AddAction(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.AddAction(UserInputKey.LocationCurPlay, OnLocationCurPlay); keyReceive.AddAction(UserInputKey.HideWindow, (data) => { if (adapter.Enable) { ShowMap(!adapter.Enable); } }); }
private void RegisterKeyBinding() { // 虽然是Ui但是其实层级应该是Env var keyreciever = new KeyReceiver(Layer.Env, BlockType.None); keyreciever.AddAction(UserInputKey.PickUp, OnAction); _pickUpUiAdapter.RegisterKeyReceiver(keyreciever); var pointerReceiver = new PointerReceiver(Layer.Env, BlockType.None); pointerReceiver.AddAction(UserInputKey.PickUpTip, SetCastData); _pickUpUiAdapter.RegisterPointerReceiver(pointerReceiver); }
//Function to switch UI betwen enabled and disabled states //while user is dragging parent object public void EnableUI() { //Check if there is a reference to pointer receiver if (_pointer == null) { //Get pointer receiver component from parent _pointer = GetComponentInParent <PointerReceiver>(); } //Check if the state of the pointer is in a dragging state if (_pointer != null && _pointer.Dragging) { //Set game object active status to opposite of current status gameObject.SetActive(!gameObject.activeSelf); } }
private void InitKeyReveiver() { keyReveiver = new KeyReceiver(UiConstant.weaponBagWindowKeyBlockLayer, BlockType.All); for (int i = 0; i < _haveBagForIndexList.Count; i++) { if (_haveBagForIndexList[i]) { var index = i - 1; keyReveiver.AddAction(UserInputKey.Switch1 + index, (data) => { btnGroupTab.SetSelect(index); CloseView(); }); keyReveiver.AddAction(UserInputKey.HideWindow, (data) => { CloseView(); }); } } pointerReceiver = new PointerReceiver(UiConstant.weaponBagWindowKeyBlockLayer, BlockType.All); }
public void InitKeyBinding() { var receiver = new PointerReceiver(UiConstant.maxMapWindowLayer, BlockType.None); receiver.AddAction(UserInputKey.PickUpTip, (data) => { var pointerData = data; var type = pointerData.IdList[0]; switch ((ECastDataType)type) { case ECastDataType.Player: selectedPlayerId = PlayerCastData.EntityId(data.IdList); //Debug.Log(selectedPlayerId); break; default: selectedPlayerId = 0; break; } }); playerInfoUIAdapter.RegisterPointerReceive(receiver); }
//这里所有的操作层级都设置为Env,如果有特殊遮挡需求请修改层级并修改这段注释 public void BeginReceiveUserInput(IUserInputManager manager) { _userInputManager = manager; #region Env keyreceiver // 有UI打开的情况下,不能开枪, 不能瞄准 _specialKeyReceiver = new KeyReceiver(UiConstant.specicalCmdKeyLayer, BlockType.None); for (int i = 0; i < _inputMapperList.Count; i++) { _inputMapperList[i].RegisterSpecialCmdKeyInput(_specialKeyReceiver, _userCmd); } _specialKeyReceiver.AddAction(UserInputKey.Fire, (data) => _userCmd.IsLeftAttack = true); _specialKeyReceiver.AddAction(UserInputKey.RightAttack, (data) => _userCmd.IsRightAttack = true); _specialKeyReceiver.AddAction(UserInputKey.CameraFocus, (data) => _userCmd.IsCameraFocus = true); _userInputManager.RegisterKeyReceiver(_specialKeyReceiver); _keyReceiver = new KeyReceiver(UiConstant.userCmdKeyLayer, BlockType.None); for (int i = 0; i < _inputMapperList.Count; i++) { _inputMapperList[i].RegisterEnvKeyInput(_keyReceiver, _userCmd); } _keyReceiver.AddAction(UserInputKey.SwitchFireMode, (data) => _userCmd.IsSwitchFireMode = true); _keyReceiver.AddAction(UserInputKey.DrawWeapon, (data) => _userCmd.IsDrawWeapon = true); _keyReceiver.AddAction(UserInputKey.Throwing, (data) => _userCmd.IsThrowing = true); _keyReceiver.AddAction(UserInputKey.FirstPerson, (data) => _userCmd.ChangeCamera = true); _keyReceiver.AddAction(UserInputKey.FreeCamera, (data) => _userCmd.IsCameraFree = true); _keyReceiver.AddAction(UserInputKey.Jump, (data) => _userCmd.IsJump = true); _keyReceiver.AddAction(UserInputKey.Crouch, (data) => _userCmd.IsCrouch = true); _keyReceiver.AddAction(UserInputKey.Prone, (data) => _userCmd.IsProne = true); //_keyReceiver.AddAction(UserInputKey.Injured, (data) => _userCmd.BeState = 2); //_keyReceiver.AddAction(UserInputKey.Swim, (data) => _userCmd.BeState = 1); _keyReceiver.AddAction(UserInputKey.Reload, (data) => _userCmd.IsReload = true); _keyReceiver.AddAction(UserInputKey.PeekLeft, (data) => _userCmd.IsPeekLeft = true); _keyReceiver.AddAction(UserInputKey.PeekRight, (data) => _userCmd.IsPeekRight = true); _keyReceiver.AddAction(UserInputKey.SwitchWeapon, (data) => _userCmd.IsSwitchWeapon = true); _keyReceiver.AddAction(UserInputKey.DropWeapon, (data) => _userCmd.IsDropWeapon = true); _keyReceiver.AddAction(UserInputKey.Switch1, data => _userCmd.SwitchNumber = 1); _keyReceiver.AddAction(UserInputKey.Switch7, data => _userCmd.SwitchNumber = 7); _keyReceiver.AddAction(UserInputKey.IsPDown, data => _userCmd.IsPDown = true); _keyReceiver.AddAction(UserInputKey.IsYDown, data => _userCmd.IsYDown = true); _keyReceiver.AddAction(UserInputKey.AddMark, data => _userCmd.IsAddMark = true); _keyReceiver.AddAction(UserInputKey.BreathHold, data => _userCmd.IsHoldBreath = true); _keyReceiver.AddAction(UserInputKey.SwitchAutoRun, data => _userCmd.IsSwitchAutoRun = true); _keyReceiver.AddAction(UserInputKey.IsCDown, data => _userCmd.IsCDown = true); _keyReceiver.AddAction(UserInputKey.IsSpaceDown, data => _userCmd.IsSpaceDown = true); _keyReceiver.AddAction(UserInputKey.HoldF, data => _userCmd.IsF = true); _keyReceiver.AddAction(UserInputKey.SprayPaint, data => _userCmd.IsSprayPaint = true); _keyReceiver.AddAction(UserInputKey.ScopeIn, data => _userCmd.IsScopeIn = true); _keyReceiver.AddAction(UserInputKey.ScopeOut, data => _userCmd.IsScopeOut = true); _userInputManager.RegisterKeyReceiver(_keyReceiver); #endregion #region Ui Keyreciever _uiKeyReceiver = new KeyReceiver(UiConstant.userCmdUIKeyLayer, BlockType.None); _uiKeyReceiver.AddAction(UserInputKey.MoveHorizontal, (data) => _userCmd.MoveHorizontal = data.Axis); _uiKeyReceiver.AddAction(UserInputKey.MoveVertical, (data) => _userCmd.MoveVertical = data.Axis); _uiKeyReceiver.AddAction(UserInputKey.MoveUpDown, (data) => _userCmd.MoveUpDown = data.Axis); _uiKeyReceiver.AddAction(UserInputKey.Run, (data) => _userCmd.IsRun = true); _uiKeyReceiver.AddAction(UserInputKey.IsTabDown, data => _userCmd.IsTabDown = true); _uiKeyReceiver.AddAction(UserInputKey.SlightWalk, data => _userCmd.IsSlightWalk = true); _userInputManager.RegisterKeyReceiver(_uiKeyReceiver); #endregion #if UNITY_EDITOR foreach (var mockCmd in _mockCmdList) { mockCmd(_userCmd); } #endif var pointerReceiver = new PointerReceiver(UiConstant.userCmdPointLayer, BlockType.None); pointerReceiver.AddAction(UserInputKey.Yaw, (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 UNITY_EDITOR if (!Cursor.visible) { _userCmd.DeltaYaw = total; } #else _userCmd.DeltaYaw = total; #endif }); pointerReceiver.AddAction(UserInputKey.Pitch, (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 UNITY_EDITOR if (!Cursor.visible) { _userCmd.DeltaPitch = -total; } #else _userCmd.DeltaPitch = -total; #endif }); _userInputManager.RegisterPointerReceiver(pointerReceiver); }
public void DynamicKeyReceive() { pointerReceiver = new PointerReceiver(UiConstant.maxMapWindowPointBlockLayer, BlockType.All); keyReceive = new KeyReceiver(UiConstant.maxMapWindowKeyBlockLayer, BlockType.All); keyReceive.AddAction(UserInputKey.ChangeMapRate, (data) => { if (isGameObjectCreated == true) // if (isGameObjectCreated == true && MapLevel.Min.Equals(adapter.MapLevel) == false) { Vector2 hitPoint = Vector2.zero; if (RectTransformUtility.ScreenPointToLocalPointInRectangle(maxMapMaskControl.GetComponent <RectTransform>(), Input.mousePosition, uiCamera, out hitPoint)) { if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapBgRectTran, Input.mousePosition, uiCamera, out hitPoint)) { if (data.Axis > 0) //正向滚动滑轮 大地图控件可以显示的真实地图大小缩小一半 { var temperNum = MaxMapRepresentWHByRice / 2; if (temperNum >= MaxMapRealWHByRice / 16) { MaxMapRepresentWHByRice = temperNum; } } else if (data.Axis < 0) //反向滚动滑轮 大地图控件可以显示的真实地图大小扩大一半 { var temperNum = MaxMapRepresentWHByRice * 2; if (temperNum <= MaxMapRealWHByRice) { MaxMapRepresentWHByRice = temperNum; } } //更具滚轮的移动 改变MaxMapWHByRice rate = maxMapMaskWByPixel / MaxMapRepresentWHByRice; } } } }); keyReceive.AddAction(UserInputKey.AddMark, (data) => { if (MapLevel.Min.Equals(adapter.MapLevel) == false) { Vector2 markPos = adapter.CurPlayerPos; adapter.SendMarkMessage(markPos); } }); keyReceive.AddAction(UserInputKey.MouseAddMark, (data) => { Vector2 hitPoint = Vector2.zero; Vector2 hitPoint1 = Vector2.zero; if (MapLevel.Min.Equals(adapter.MapLevel) == false) { if (RectTransformUtility.ScreenPointToLocalPointInRectangle(maxMapMaskControlRect, Input.mousePosition, uiCamera, out hitPoint1)) { if (RectTransformUtility.ScreenPointToLocalPointInRectangle(mapBgRectTran, Input.mousePosition, uiCamera, out hitPoint)) { var markPos = maskCenterPInMapByRice + hitPoint1 / rate; adapter.SendMarkMessage(markPos); } } } }); keyReceive.AddAction(UserInputKey.LocationCurPlay, (data) => { if (MaxMapRepresentWHByRice != 8000) //缩放模式的时候 { //将当前玩家尽量移动到地图中心 也就是移动背景图 var curPlayPosByPice = adapter.CurPlayerPos; Vector2 curPlayPosByPixel = (curPlayPosByPice - maskCenterPInMapByRice) * rate; var offset = curPlayPosByPixel - Vector2.zero; SetMapBgLocationByDrag(-offset); } }); keyReceive.AddAction(UserInputKey.HideWindow, (data) => { if (adapter.Enable) { ShowMap(!adapter.Enable); } }); }
private void InitReceiver() { pointerReceiver = new PointerReceiver(Layer.Env, BlockType.All); }