private IEnumerator Return() { sequence = TravelSequenceTowards(startPos); sequence.Insert(travelTime, transform.DOLookAt(startPos + startForward, turnTime)); yield return(new WaitWhile(() => { return sequence.IsActive() && sequence.IsPlaying(); })); OnArrival?.Invoke(this); }
public void Move() { if (!CanMove) { return; } // _parallelMovingCheck.Tick(); if (_movementPackage.Destination.DestinationType == DestinationType.Intersection && !_movementPackage.Finished) { if (InRedirectRange()) { _movementPackage.Destination.TargetLocation = _movementPackage.IntersectionAnalysis.IntersectingUnit .AngleDefinition.IntersectionPoint; HandleIntersectionTimeSlow(); var successfulRedirect = RedirectEvaluator.ValidRedirect( _movementPackage.IntersectionAnalysis.IntersectingUnit.Transform.position, _movementPackage.Destination.TargetLocation, 0.85f); if (PassedRedirectRange()) { NewMovementPackageRequested?.Invoke(_movementPackage, SetMovementPackage, successfulRedirect); Time.timeScale = 1f; _currentMoveSpeed = _defaultMoveSpeed * 1.5f; } } } if (InRequestRange() && _movementPackage.Destination.DestinationType == DestinationType.ClosestPointToEnemy && !_movementPackage.Finished) { if (!_requested) { _requested = true; NewMovementPackageRequested?.Invoke(_movementPackage, SetMovementPackage, false); } } if (_movementPackage.Finished && !_isInDanger) { _currentMoveSpeed = _defaultMoveSpeed * 2f; } if (Arrived(_movementPackage.Destination.TargetLocation)) { OnArrival?.Invoke(); Reset(); return; } IsMoving = true; _transform.position = Vector2.MoveTowards(_transform.position, _movementPackage.Destination.TargetLocation, _currentMoveSpeed * Time.deltaTime); }
public void Update() { if (route == null) { return; } var towards = GetGoingTo() - root.position; towards.Scale(level); if (towards.magnitude < .1f) { currentIndex++; } if (currentIndex >= route.Count) { OnArrival?.Invoke(); route = null; } }
public void Incoming(Airplane airplane) { Airplanes.Add(airplane); OnArrival?.Invoke(this, airplane); }
public void Reset() { OnArrival?.Invoke(); _currentMoveSpeed = _defaultMoveSpeed; _currentPlan = null; }