コード例 #1
0
 public void Move(Vector3 destination, OnArrival onArrival)
 {
     this.destination   = destination;
     this.destination.y = transform.position.y;
     move           = true;
     this.onArrival = onArrival;
 }
コード例 #2
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);
    }
コード例 #3
0
ファイル: Mover.cs プロジェクト: ChiefTripodBear/Samurai-Dash
    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);
    }
コード例 #4
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;
        }
    }
コード例 #5
0
 public void Incoming(Airplane airplane)
 {
     Airplanes.Add(airplane);
     OnArrival?.Invoke(this, airplane);
 }
コード例 #6
0
 public void Reset()
 {
     OnArrival?.Invoke();
     _currentMoveSpeed = _defaultMoveSpeed;
     _currentPlan      = null;
 }