private void SelectionChanged(WaypointArrow oldSelection, WaypointArrow newSelection) { if (!newSelection && oldSelection) { // if (!_goMode) // { oldSelection.DClearDestination(); oldSelection.EReleaseDestination -= DReleaseDestination; HexEditor.ClearRange(); _waypointArrow = null; _currentPick = Vector3.back; _lastPick = Vector3.back; // Debug.Log("Deselect any object"); // } } else if (oldSelection && newSelection) { // if (!_goMode) // { oldSelection.DClearDestination(); // newSelection.DClearDestination(); oldSelection.EReleaseDestination -= DReleaseDestination; // newSelection.EReleaseDestination -= DReleaseDestination; HexEditor.ClearRange(); _waypointArrow = newSelection; _currentPick = Vector3.back; _lastPick = Vector3.back; newSelection.EReleaseDestination += DReleaseDestination; // Debug.Log("Selection shifts"); // } } else if (!oldSelection && newSelection) { _waypointArrow = newSelection; newSelection.EReleaseDestination += DReleaseDestination; // Debug.Log("A brand new selection " + _wasSelectedThisFrame + " " + Time.time); } /*if (oldSelection) * { * oldSelection.DClearDestination(); * oldSelection.ClearMovementQueue(); * }*/ }
void Awake() { if (instance != null) { Debug.LogError("More than one instance of Arrows found in scene!"); return; } instance = this; arrows = new Transform[transform.childCount]; for (int i = 0; i < arrows.Length; i++) { arrows[i] = transform.GetChild(i); WaypointArrow a = arrows[i].GetComponent <WaypointArrow>(); arrowScript.Add(a); } }
private void SelectionChanged(WaypointArrow previousSelection, WaypointArrow brandNewSelection) { if (!previousSelection && brandNewSelection) { // Debug.Log("Brand new selection"); brandNewSelection.TryGetComponent(out _selectCommonUser); } else if (previousSelection && brandNewSelection) { // Debug.Log("Changed selection"); brandNewSelection.TryGetComponent(out _selectCommonUser); } else if (previousSelection && !brandNewSelection) { // Debug.Log("Disable selection"); _selectCommonUser = null; } }
public WaypointArrow GetHighlighted() { if (TurnShift.Length > 0) { for (int i = 0; i < TurnShift.Length; i++) { SpriteOutline so = TurnShift[i].GetComponentInChildren <SpriteOutline>(); // Debug.Log(so.transform.position + " " + so.IsSelected + " " + nameof(TurnShifterController) + "23"); if (so.IsSelected) { HasSelectionBefore = LastPickedWaypointArrow == TurnShift[i]; if (!HasSelectionBefore) { SelectionChanged?.Invoke(LastPickedWaypointArrow, TurnShift[i]); } LastPickedWaypointArrow = TurnShift[i]; return(TurnShift[i]); } } if (LastPickedWaypointArrow != default) { SelectionChanged?.Invoke(LastPickedWaypointArrow, null); } } LastPickedWaypointArrow = default; HasSelectionBefore = false; return(null); }