Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    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;
        }
    }
Exemplo n.º 4
0
 public void Incoming(Airplane airplane)
 {
     Airplanes.Add(airplane);
     OnArrival?.Invoke(this, airplane);
 }
Exemplo n.º 5
0
 public void Reset()
 {
     OnArrival?.Invoke();
     _currentMoveSpeed = _defaultMoveSpeed;
     _currentPlan      = null;
 }