private void clearHighlights() { setHighlighted(false); sister.setHighlighted(false); if (action.Target != null) { Tooltippable correspondingHighlightable = action.Target.GetComponent <Tooltippable>(); correspondingHighlightable.setHighlighted(false); correspondingHighlightable.hideTargetInfoText(); } }
private void showHighlights() { setHighlighted(true); sister.setHighlighted(true); if (action.Target != null) { Tooltippable correspondingHighlightable = action.Target.GetComponent <Tooltippable>(); correspondingHighlightable.setHighlighted(true); correspondingHighlightable.showTargetInfoText(action.getAdditionalTextForTarget(action.Target)); } }
/// <summary> /// Called after a selected action is either scheduled or cancelled. /// </summary> public void clearSelectionState() { //the other targets should not be highlighted now foreach (Targetable noLongerATarget in selected.getPossibleTargets()) { Tooltippable guiObj = noLongerATarget.GetComponent <Tooltippable>(); guiObj.setHighlighted(false); guiObj.OnClicked -= clickHandlers[noLongerATarget].click; guiObj.OnHover -= clickHandlers[noLongerATarget].hover; guiObj.OnEndHover -= clickHandlers[noLongerATarget].endHover; guiObj.hideTargetInfoText(); } clickHandlers = new Dictionary <Targetable, EventHandlers>(); selected.transform.parent.GetComponent <NodeMenu>().clear(); inSelectionState = false; selected = null; }
public void selectAction(Action selected) { inSelectionState = true; isFirstFrameAfterSelected = true; this.selected = selected; //if the action is targeted, ask for targets if (selected.IsTargeting) { List <Targetable> possibleTargets = selected.getPossibleTargets(); possibleTargets.ForEach((x) => { //highlight the possible targets Tooltippable guiObj = x.GetComponent <Tooltippable>(); guiObj.setHighlighted(true); guiObj.showTargetInfoText(selected.getAdditionalTextForTarget(x)); clickHandlers[x] = new EventHandlers(); //attach click event handlers to the possible targets so they're selected when they're clicked System.Action clickAction = () => scheduleAction(x); clickHandlers[x].click = clickAction; guiObj.OnClicked += clickAction; //attach hover event handlers to possible targets so that they display edge visibility data when hovered over System.Action hoverAction = () => startHoverForTarget(x); clickHandlers[x].hover = hoverAction; guiObj.OnHover += hoverAction; System.Action endHoverAction = () => endHoverForTarget(x); clickHandlers[x].endHover = endHoverAction; guiObj.OnEndHover += endHoverAction; }); return; } //no target needed //add the action to the player scheduleAction(null); }