/// <summary> /// 是否可以移动到下一个 /// 当左右移动时判断是否需要给予焦点 /// 当上下移动时移动自身格子的焦点 /// </summary> /// <param name="moveType"></param> /// <returns></returns> public override bool CanMoveNext(UIFocusPath.MoveType moveType) { if (!equipentsLatticePath) { return(true); } UIFocusItemEquipmentLattice tempLattice = equipentsLatticePath.GetNewNextFocus(nowLattice, moveType) as UIFocusItemEquipmentLattice;// equipentsLatticePath.GetNextFocus(nowLattice, moveType) as UIFocusItemEquipmentLattice;//查询下一个位置 switch (moveType) { //当左右移动时需要判断下一个目标是不是空,如果是空,则允许上层移动焦点,如果不为空则本身移动 //当上下移动时,不需要判断,如果为空则不处理,则下方也不会处理,如果不为空则移动 case UIFocusPath.MoveType.LEFT: //case UIFocusPath.MoveType.RIGHT://暂时没有向右移动失去焦点的功能 if (!tempLattice) { if (nowLattice) { nowLattice.LostForcus(); } return(true); } break; } return(false); }
/// <summary> /// 获取焦点 /// </summary> /// <param name="moveType"></param> public void GetKeyDown(UIFocusPath.MoveType moveType) { Action <UIFocusPath.MoveType> MoveNextAction = (_moveType) => { if (!nowUIFocus) { nowUIFocus = uiFocusPath.GetFirstFocus(); } if (nowUIFocus) { UIFocus nextUIFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, _moveType); if (nextUIFocus != null) { nowUIFocus = nextUIFocus; } nowUIFocus.SetForcus(); } }; switch (moveType) { case UIFocusPath.MoveType.LEFT: case UIFocusPath.MoveType.RIGHT: MoveNextAction(moveType); break; case UIFocusPath.MoveType.OK: UIFocusButton uiFocusButton = nowUIFocus as UIFocusButton; if (uiFocusButton) { uiFocusButton.ClickThisButton(); //激活事件 } break; } }
/// <summary> /// 创建时输入名字状态的手柄输入检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void CreateNameInputType_HandleUpdate(UIManager.KeyType keyType, Vector2 rockValue) { if (nowNameInputFocus == null && nameInputUIFocusPath) { nowNameInputFocus = nameInputUIFocusPath.GetFirstFocus(); if (nowNameInputFocus) { nowNameInputFocus.SetForcus(); } } if (nowNameInputFocus) { //判断键位 Action <UIFocusPath.MoveType> MoveFocusAction = (moveType) => { UIFocus next = nameInputUIFocusPath.GetNewNextFocus(nowNameInputFocus, moveType);// uiFocusPath.GetNextFocus(nowFocus, moveType, true); if (next) { nowNameInputFocus.LostForcus(); nowNameInputFocus = next; nowNameInputFocus.SetForcus(); } }; switch (keyType) { case UIManager.KeyType.A: if (nowNameInputFocus) { UIFocusButton uiFocusButton = nowNameInputFocus as UIFocusButton; UIFocusInputField uiFocusInputField = nowNameInputFocus as UIFocusInputField; if (uiFocusButton) { uiFocusButton.ClickThisButton(); } else if (uiFocusInputField) { uiFocusInputField.EnterInputField(); } } break; case UIManager.KeyType.LEFT: MoveFocusAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveFocusAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: MoveFocusAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveFocusAction(UIFocusPath.MoveType.DOWN); break; } } }
/// <summary> /// 创建时选择种族状态的手柄输入检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void CreateSelectRoleOfRaceType_HandleUpdate(UIManager.KeyType keyType, Vector2 rockValue) { if (nowRoleOfRaceFocus == null && roleOfRaceUIFocusPath) { nowRoleOfRaceFocus = roleOfRaceUIFocusPath.GetFirstFocus(); if (nowRoleOfRaceFocus) { nowRoleOfRaceFocus.SetForcus(); } } if (nowRoleOfRaceFocus) { //判断键位 Action <UIFocusPath.MoveType> MoveFocusAction = (moveType) => { UIFocus next = roleOfRaceUIFocusPath.GetNewNextFocus(nowRoleOfRaceFocus, moveType);// uiFocusPath.GetNextFocus(nowFocus, moveType, true); if (next) { nowRoleOfRaceFocus = next; CreateSelectRoleOfRaceUpdateNowFocus(); } }; switch (keyType) { case UIManager.KeyType.A: if (nowRoleOfRaceFocus) { UIFocusButton uiFocusButton = nowRoleOfRaceFocus as UIFocusButton; if (uiFocusButton) { uiFocusButton.ClickThisButton(); } } break; case UIManager.KeyType.LEFT: MoveFocusAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveFocusAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: MoveFocusAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveFocusAction(UIFocusPath.MoveType.DOWN); break; } } }
/// <summary> /// 按键检测(抬起) /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { Func <UIFocusPath.MoveType, UIFocus> GetNext = (key) => { UIFocus nextFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, key); return(nextFocus); }; switch (keyType) { case UIManager.KeyType.A: if (nowUIFocus) { nowUIFocus.MoveChild(UIFocusPath.MoveType.OK); } break; case UIManager.KeyType.LEFT: if (nowUIFocus) { nowUIFocus.MoveChild(UIFocusPath.MoveType.LEFT); } break; case UIManager.KeyType.RIGHT: if (nowUIFocus) { nowUIFocus.MoveChild(UIFocusPath.MoveType.RIGHT); } break; case UIManager.KeyType.UP: case UIManager.KeyType.DOWN: if (!nowUIFocus) { nowUIFocus = uiFocusPath.GetFirstFocus(); } else { UIFocus nextFocus = GetNext(keyType == UIManager.KeyType.UP ? UIFocusPath.MoveType.UP : UIFocusPath.MoveType.DOWN); nowUIFocus.LostForcus(); nowUIFocus = nextFocus; } if (nowUIFocus) { nowUIFocus.SetForcus(); } break; } }
/// <summary> /// 按键检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { if (!fisrtKeyUP) { fisrtKeyUP = true; return; } if (UIAction.isSaving) { return; } Action <UIFocusPath.MoveType> MoveNextEndAction = (moveType) => { if (nowUIFocus) { UIFocus uiFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, moveType); if (uiFocus) { nowUIFocus.LostForcus(); nowUIFocus = uiFocus; nowUIFocus.SetForcus(); } } else { nowUIFocus = uiFocusPath.GetFirstFocus(); nowUIFocus.SetForcus(); } }; switch (keyType) { case UIManager.KeyType.A: UIFocusButton uiFocusButton = nowUIFocus as UIFocusButton; if (uiFocusButton) { uiFocusButton.ClickThisButton(); } break; case UIManager.KeyType.UP: MoveNextEndAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveNextEndAction(UIFocusPath.MoveType.DOWN); break; } }
/// <summary> /// 按键检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { if (uiFocusPath)//切换标签页 { UIFocus nextTabPageFocus = null; switch (keyType) { case UIManager.KeyType.R1: nextTabPageFocus = uiFocusPath.GetNewNextFocus(nowTabPageFocus, UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.L1: nextTabPageFocus = uiFocusPath.GetNewNextFocus(nowTabPageFocus, UIFocusPath.MoveType.LEFT); break; } TabPageClick(nextTabPageFocus as UIFocusTabPage); } switch (keyType) { case UIManager.KeyType.B: //返回 CloseActionClick(); break; } }
/// <summary> /// 按键检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { //输入 if (uiFocusPath) { Action <UIFocusPath.MoveType> MoveFocusAction = (moveType) => { if (nowUIFocus) { if (nowUIFocus.CanMoveNext(moveType)) { UIFocus nextUIFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, moveType);//uiFocusPath.GetNextFocus(nowUIFocus, moveType); if (nextUIFocus) { nowUIFocus = nextUIFocus; nowUIFocus.SetForcus(); } } else//移动控件内的控件 { nowUIFocus.MoveChild(moveType); } } }; switch (keyType) { case UIManager.KeyType.LEFT: MoveFocusAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveFocusAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: MoveFocusAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveFocusAction(UIFocusPath.MoveType.DOWN); break; } } }
/// <summary> /// 依照当前的焦点获取下一个可以移动的焦点 /// </summary> /// <param name="moveType"></param> /// <returns></returns> private UIFocus GetNextEnableTabPage(UIFocusPath.MoveType moveType) { UIFocus tempStartFocus = nowTabPageFocus; ReGo: tempStartFocus = uiFocusPath.GetNewNextFocus(tempStartFocus, moveType); if (tempStartFocus != null) { //查看是否可以使用 if (tempStartFocus.Tag == "BigMap")//如果是大地图则查看是是否可以使用大地图 { GameRunningStateData gameRunningStateData = DataCenter.Instance.GetEntity <GameRunningStateData>(); if (!gameRunningStateData.CanBigMap)//如果不可以使用则调到上面重新获取该节点的下一个位置 { goto ReGo; } } } return(tempStartFocus); }
/// <summary> /// 按键检测 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { switch (enumUISkillCombine) { case EnumUISkillCombine.CombineSkillItem: //处于左侧状态 switch (keyType) { case UIManager.KeyType.A: if (nowCombineSkillItem) { //设置技能框的边框显示 nowUISkilCombineLattice = uiFocusPath.GetFirstFocus <UIFocusSkillCombineLattice>(); if (nowUISkilCombineLattice) { nowUISkilCombineLattice.SetForcus(); } //同时将模式更改为CombineSkillLattice enumUISkillCombine = EnumUISkillCombine.CombineSkillLattice; uiCombineSkillList.CanClickListItem = false; } break; case UIManager.KeyType.UP: case UIManager.KeyType.DOWN: { UIListItem[] tempArrays = uiCombineSkillList.GetAllImtes(); int index = 0; if (nowCombineSkillItem) { index = tempArrays.ToList().IndexOf(nowCombineSkillItem); } if (index < 0) { index = 0; } switch (keyType) { case UIManager.KeyType.UP: index--; break; case UIManager.KeyType.DOWN: index++; break; } index = Mathf.Clamp(index, 0, tempArrays.Length - 1); if (index < tempArrays.Length) { uiCombineSkillList.ShowItem(tempArrays[index]); if (nowCombineSkillItem && nowCombineSkillItem.childImage) { nowCombineSkillItem.childImage.enabled = false; nowCombineSkillItem.childImage.gameObject.SetActive(false); } nowCombineSkillItem = tempArrays[index]; if (nowCombineSkillItem && nowCombineSkillItem.childImage) { nowCombineSkillItem.childImage.enabled = true; nowCombineSkillItem.childImage.gameObject.SetActive(true); } if (nowCombineSkillItem) { SetSkillCombineLatticeAndShowVadio((EnumSkillType[])nowCombineSkillItem.value); } } } break; } break; case EnumUISkillCombine.CombineSkillLattice: //处于右侧状态 switch (keyType) { case UIManager.KeyType.A: SetSelectSkill(); break; case UIManager.KeyType.B: if (nowUISkilCombineLattice) { nowUISkilCombineLattice.LostForcus(); } enumUISkillCombine = EnumUISkillCombine.CombineSkillItem; //切换模式到组合技能集合 uiCombineSkillList.CanClickListItem = true; break; case UIManager.KeyType.LEFT: case UIManager.KeyType.RIGHT: if (nowUISkilCombineLattice) { UIFocusSkillCombineLattice tempUIFocuesSkillCombineLattice = uiFocusPath.GetNewNextFocus(nowUISkilCombineLattice, keyType == UIManager.KeyType.LEFT ? UIFocusPath.MoveType.LEFT : UIFocusPath.MoveType.RIGHT) as UIFocusSkillCombineLattice; //uiFocusPath.GetNextFocus(nowUISkilCombineLattice, keyType == UIManager.KeyType.LEFT ? UIFocusPath.MoveType.LEFT : UIFocusPath.MoveType.RIGHT) as UIFocusSkillCombineLattice; if (tempUIFocuesSkillCombineLattice) { nowUISkilCombineLattice.LostForcus(); nowUISkilCombineLattice = tempUIFocuesSkillCombineLattice; nowUISkilCombineLattice.SetForcus(); } } break; } break; case EnumUISkillCombine.CombineSkillSelect: //处于选择技能状态 switch (keyType) { case UIManager.KeyType.A: ResetCombineSkillLattice(); break; case UIManager.KeyType.B: //切换状态 uiSelectSkillList.gameObject.SetActive(false); enumUISkillCombine = EnumUISkillCombine.CombineSkillLattice; break; case UIManager.KeyType.UP: case UIManager.KeyType.DOWN: { UIListItem[] tempArrays = uiSelectSkillList.GetAllImtes(); int index = 0; if (nowCombineSkillItem) { index = tempArrays.ToList().IndexOf(nowSelectSkillItem); } if (index < 0) { index = 0; } switch (keyType) { case UIManager.KeyType.UP: index--; break; case UIManager.KeyType.DOWN: index++; break; } index = Mathf.Clamp(index, 0, tempArrays.Length - 1); if (index < tempArrays.Length) { uiSelectSkillList.ShowItem(tempArrays[index]); if (uiSelectSkillList && nowSelectSkillItem.childImage) { nowSelectSkillItem.childImage.enabled = false; nowSelectSkillItem.childImage.gameObject.SetActive(false); } nowSelectSkillItem = tempArrays[index]; if (uiSelectSkillList && nowSelectSkillItem.childImage) { nowSelectSkillItem.childImage.enabled = true; nowSelectSkillItem.childImage.gameObject.SetActive(true); } } } break; } break; } }
/// <summary> /// 接收输入 /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { if (!nowKeySettingLattice && keySettingFocusPath) { nowKeySettingLattice = keySettingFocusPath.GetFirstFocus() as UIFocusKeySettingLattice; } switch (enumKeySettingType) { case EnumKeySettingType.Lattice: //此时可以移动和确认 Action <UIFocusPath.MoveType> MoveNExtEndAction = (moveType) => { if (keySettingFocusPath) { //UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNextFocus(nowKeySettingLattice, moveType) as UIFocusKeySettingLattice; //UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNextFocus(nowKeySettingLattice, moveType, UIFocusPath.EnumFocusCheckModel.Vertical) as UIFocusKeySettingLattice; UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNewNextFocus(nowKeySettingLattice, moveType) as UIFocusKeySettingLattice; if (currentKeySettingLattice != null && !object.Equals(currentKeySettingLattice, nowKeySettingLattice)) { nowKeySettingLattice.LostForcus(); nowKeySettingLattice = currentKeySettingLattice; nowKeySettingLattice.SetForcus(); } } }; switch (keyType) { case UIManager.KeyType.A: //进入选择 //显示集合 ShowUIList(); break; case UIManager.KeyType.LEFT: MoveNExtEndAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveNExtEndAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: MoveNExtEndAction(UIFocusPath.MoveType.UP); break; case UIManager.KeyType.DOWN: MoveNExtEndAction(UIFocusPath.MoveType.DOWN); break; } break; case EnumKeySettingType.Select: //此时可以选择技能 Action <int> MoveListSelect = (addOffset) => { UIListItem[] tempArrays = uiKeySettingList.GetAllImtes(); int index = 0; if (nowKeySettingListItem) { index = tempArrays.ToList().IndexOf(nowKeySettingListItem); } if (index < 0) { index = 0; } index += addOffset; index = Mathf.Clamp(index, 0, tempArrays.Length - 1); if (index < tempArrays.Length && tempArrays.Length > 0) { uiKeySettingList.ShowItem(tempArrays[index]); if (nowKeySettingListItem && nowKeySettingListItem.childImage) { nowKeySettingListItem.childImage.enabled = false; } nowKeySettingListItem = tempArrays[index]; if (nowKeySettingListItem && nowKeySettingListItem.childImage) { nowKeySettingListItem.childImage.enabled = true; } } }; switch (keyType) { case UIManager.KeyType.A: //确认选择 SelectAction(); break; case UIManager.KeyType.UP: MoveListSelect(-1); break; case UIManager.KeyType.DOWN: MoveListSelect(1); break; } break; } }
/// <summary> /// 按键检测(功能键) /// </summary> /// <param name="keyType"></param> /// <param name="rockValue"></param> private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue) { if (!fisrtKeyUP) { fisrtKeyUP = true; return; } switch (bigMapOperateState) { case EnumBigMapOperateState.OperateMap: //操作地图 switch (keyType) { case UIManager.KeyType.A: Vector2 handlePos = uiMapControl.GetHandlePosInTerrain(); ActionAtTerrain(handlePos); break; case UIManager.KeyType.Y: bigMapOperateState = EnumBigMapOperateState.CheckSetting; showSettingPanel.gameObject.SetActive(true); if (uiFocusPath) { nowUIFocus = uiFocusPath.GetFirstFocus(); } if (nowUIFocus) { nowUIFocus.SetForcus(); } break; } break; case EnumBigMapOperateState.CheckSetting: //操作设置 if (!nowUIFocus) { if (uiFocusPath) { nowUIFocus = uiFocusPath.GetFirstFocus(); } } if (nowUIFocus) { Action <UIFocusPath.MoveType> MoveUIFocusAction = (moveType) => { UIFocus nextUIFocus = uiFocusPath.GetNewNextFocus(nowUIFocus, moveType); //uiFocusPath.GetNextFocus(nowUIFocus, moveType); if (nextUIFocus != null) { nowUIFocus.LostForcus(); nowUIFocus = nextUIFocus; nowUIFocus.SetForcus(); } }; switch (keyType) { case UIManager.KeyType.A: if (nowUIFocus.GetType().Equals(typeof(UIFocusButton))) { ((UIFocusButton)nowUIFocus).ClickThisButton(); } else if (nowUIFocus.GetType().Equals(typeof(UIFocusToggle))) { ((UIFocusToggle)nowUIFocus).MoveChild(UIFocusPath.MoveType.OK); } break; case UIManager.KeyType.B: ExitSetting_Click(); break; case UIManager.KeyType.LEFT: MoveUIFocusAction(UIFocusPath.MoveType.LEFT); break; case UIManager.KeyType.RIGHT: MoveUIFocusAction(UIFocusPath.MoveType.RIGHT); break; case UIManager.KeyType.UP: case UIManager.KeyType.DOWN: if (string.Equals(nowUIFocus.Tag, "SceneDropDown")) { UIFocusDropdown uiFocusDropDown = nowUIFocus as UIFocusDropdown; if (uiFocusDropDown != null) { uiFocusDropDown.MoveChild(keyType == UIManager.KeyType.UP ? UIFocusPath.MoveType.UP : UIFocusPath.MoveType.DOWN); } } break; } } break; } }