/// <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> /// 在输入OK键时更改选中状态 /// </summary> /// <param name="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { if (moveType == UIFocusPath.MoveType.OK) { if (toggle == null) { toggle = GetComponent <Toggle>(); } toggle.isOn = !toggle.isOn; } }
/// <summary> /// 移动子焦点(list中的数据,这里不用焦点) /// </summary> /// <param name="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { if (focusUIListItem == null) { focusUIListItem = uiDepostiList.FirstShowItem(); } UIListItem[] tempArrays = uiDepostiList.GetAllImtes(); if (tempArrays.Length == 0) { return; } int index = 0; if (focusUIListItem) { index = tempArrays.ToList().IndexOf(focusUIListItem); } if (index < 0) { index = 0; } switch (moveType) { case UIFocusPath.MoveType.UP: //- index--; break; case UIFocusPath.MoveType.DOWN: //+ index++; break; } index = Mathf.Clamp(index, 0, tempArrays.Length - 1); if (index < tempArrays.Length) { uiDepostiList.ShowItem(tempArrays[index]); if (focusUIListItem && focusUIListItem.childImage) { focusUIListItem.childImage.enabled = false; } focusUIListItem = tempArrays[index]; if (focusUIListItem && focusUIListItem.childImage) { focusUIListItem.childImage.enabled = true; } //设置选择了该物体 PlayGoods playGoods = (PlayGoods)focusUIListItem.value; if (SelectGoodsIDAction != null) { SelectGoodsIDAction(playGoods.ID); } } }
/// <summary> /// 是否可以移动 /// </summary> /// <param name="moveType"></param> /// <returns></returns> public override bool CanMoveNext(UIFocusPath.MoveType moveType) { if (!dropdown) { return(true); } if (LeftRightChangeItem)//左右控制内部切换 { return(moveType != UIFocusPath.MoveType.LEFT && moveType != UIFocusPath.MoveType.RIGHT); } else { return(moveType == UIFocusPath.MoveType.LEFT || moveType == UIFocusPath.MoveType.RIGHT); } }
/// <summary> /// 是否可以移动到下一个 /// 点击A键可以确认和返回 /// </summary> /// <param name="moveType"></param> /// <returns></returns> public override bool CanMoveNext(UIFocusPath.MoveType moveType) { switch (moveType) { case UIFocusPath.MoveType.LEFT: case UIFocusPath.MoveType.RIGHT: case UIFocusPath.MoveType.UP: case UIFocusPath.MoveType.DOWN: return(!SkillLittleSettingState); case UIFocusPath.MoveType.OK: return(false); } return(true); }
/// <summary> /// 移动子焦点 /// </summary> /// <param name="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { if (!equipentsLatticePath) { return; } UIFocusItemEquipmentLattice tempLattice = equipentsLatticePath.GetNewNextFocus(nowLattice, moveType) as UIFocusItemEquipmentLattice;// equipentsLatticePath.GetNextFocus(nowLattice, moveType) as UIFocusItemEquipmentLattice;//查询下一个位置 if (tempLattice) { nowLattice.LostForcus(); nowLattice = tempLattice; nowLattice.SetForcus(); } SelectNowLattice(); }
/// <summary> /// 是否可以移动本焦点 /// </summary> /// <param name="moveType"></param> /// <returns></returns> public override bool CanMoveNext(UIFocusPath.MoveType moveType) { if (!uiDepostiList) { return(true); } switch (moveType) { case UIFocusPath.MoveType.LEFT: case UIFocusPath.MoveType.RIGHT: return(true); default: return(false); } }
public override void MoveChild(UIFocusPath.MoveType moveType) { switch (moveType) { case UIFocusPath.MoveType.LEFT: ClickLeft(); break; case UIFocusPath.MoveType.RIGHT: ClickRight(); break; case UIFocusPath.MoveType.OK: ClickOK(null); break; } }
/// <summary> /// 移动子选项 /// </summary> /// <param name="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { if (slider) { float _variation = variation; if (LeftRightChangeValue) { _variation *= moveType == UIFocusPath.MoveType.LEFT ? -1 : (moveType == UIFocusPath.MoveType.RIGHT ? 1 : 0); } else { _variation *= moveType == UIFocusPath.MoveType.UP ? -1 : (moveType == UIFocusPath.MoveType.DOWN ? 1 : 0); } float value = slider.value; value += _variation; value = Mathf.Clamp(value, slider.minValue, slider.maxValue); slider.value = value; } }
/// <summary> /// 移动子节点(技能) /// </summary> /// <param name="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { switch (moveType) { case UIFocusPath.MoveType.LEFT: case UIFocusPath.MoveType.DOWN: UiAddNum_ClickLeftHandle(); break; case UIFocusPath.MoveType.RIGHT: case UIFocusPath.MoveType.UP: UIAddNum_ClickRightHandle(); break; case UIFocusPath.MoveType.OK: SkillLittleSettingState = !SkillLittleSettingState; 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="moveType"></param> public override void MoveChild(UIFocusPath.MoveType moveType) { if (dropdown) { int add = 0; if (LeftRightChangeItem) { add = moveType == UIFocusPath.MoveType.LEFT ? -1 : (moveType == UIFocusPath.MoveType.RIGHT ? 1 : 0); } else { add = moveType == UIFocusPath.MoveType.UP ? -1 : (moveType == UIFocusPath.MoveType.DOWN ? 1 : 0); } List <Dropdown.OptionData> datas = dropdown.options; int length = datas.Count; int value = dropdown.value; value += add; if (cicle) { if (value >= length) { value = 0; } else if (value < 0) { value = length - 1; } } if (length > 0) { if (value >= 0 && value < length) { dropdown.value = value; } } } }
/// <summary> /// 移动控件的内部 /// </summary> /// <param name="moveType"></param> public virtual void MoveChild(UIFocusPath.MoveType moveType) { }
/// <summary> /// 在失去焦点前使用该函数判断指定的操作是否会遭致失去焦点 /// </summary> /// <param name="moveType">移动方式</param> /// <returns></returns> public virtual bool CanMoveNext(UIFocusPath.MoveType moveType) { return(true); }