void OnPointerDown(ScreenJoystick joystick) { Debug.Log("OnPointerDown"); _lastHighlightSite = null; SortNearbySites(); var allBunkerList = BattleEngine.Instance.BunkerList; foreach (var bunker in allBunkerList) { bunker.Gizmo.HideAndDehighlightAllSiteButtons(); } for (int i = 0; i < SortedCount; i++) { var e = SortArray[i]; allBunkerList[e.BunkerIndex].Gizmo.ShowHideSiteButton(e.SiteIndex, true); } }
void OnPointerStay(ScreenJoystick joystick) { if (joystick.IsValidDrag) { //肯定已经SortNearbySites()过了。当然如果在移动中,可能需要重新计算 var index = PickupSelectedSite(joystick.WorldActualDisplacement); if (index >= 0) { var site = SortArray[index].GetBunkerSite(BattleEngine.Instance.BunkerList); if (site != _lastHighlightSite) { var allBunkerList = BattleEngine.Instance.BunkerList; for (int i = 0; i < SortedCount; i++) { var e = SortArray[i]; allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false); } _lastHighlightSite = site; var gizmo = site.Bunker.Gizmo; gizmo.HighlightSiteButton(site.ID, true); } } } else { if (_lastHighlightSite) { var allBunkerList = BattleEngine.Instance.BunkerList; for (int i = 0; i < SortedCount; i++) { var e = SortArray[i]; allBunkerList[e.BunkerIndex].Gizmo.HighlightAllSiteButtons(false); } _lastHighlightSite = null; } } }
void UpdateMove() { if (!localPlayerAuthority) { return; } if (CurrentBunkerSite && Vector3.Distance(Position, CurrentBunkerSite.Position) > 0.5f) { CurrentBunkerSite.OnUnitExit(this); CurrentBunkerSite = null; } if (DestinationBunkerSite && Vector3.Distance(Position, DestinationBunkerSite.Position) <= 0.5f) { CurrentBunkerSite = DestinationBunkerSite; DestinationBunkerSite.OnUnitEnter(this); DestinationBunkerSite = null; if (UnitController.Instance.FocusedUnit == this) { UnitController.Instance.OnFocusedUnitEnterBunker(); } } }
public void SetDestination(BunkerSite destinationBunkerSite) { DestinationBunkerSite = destinationBunkerSite; Walker.WalkTo(destinationBunkerSite.Position); }
void UpdateMove() { if (!localPlayerAuthority) return; if (CurrentBunkerSite && Vector3.Distance(Position, CurrentBunkerSite.Position) > 0.5f) { CurrentBunkerSite.OnUnitExit(this); CurrentBunkerSite = null; } if (DestinationBunkerSite && Vector3.Distance(Position, DestinationBunkerSite.Position) <= 0.5f) { CurrentBunkerSite = DestinationBunkerSite; DestinationBunkerSite.OnUnitEnter(this); DestinationBunkerSite = null; if (UnitController.Instance.FocusedUnit == this) { UnitController.Instance.OnFocusedUnitEnterBunker(); } } }