コード例 #1
0
    public void Tick()
    {
        if (!_mover.IsMoving)
        {
            _playerDashMonitor.RefundChargesWhileNotMoving();
        }

        if (_mover.MovementPackage?.Destination != null)
        {
            _player.PlayerCollider2D.enabled =
                _mover.MovementPackage.Destination.DestinationType == DestinationType.Exit;
        }
        else
        {
            _player.PlayerCollider2D.enabled = true;
        }

        if (_mover.HasDestination)
        {
            _mover.Move();
            // _playerSafetyRedirect.Tick();
        }

        if (_playerSafetyRedirect.SafetyRedirectAllowed)
        {
            if (_startPosition.HasValue)
            {
                _mover.Reset();
                _playerSafetyRedirect.SafetyRedirectAllowed = false;
            }
        }
        if (_startPosition.HasValue && _mover.MovementPackage?.Destination?.DestinationType == DestinationType.Intersection)
        {
            _mover.IsMoving = false;
            Time.timeScale  = 1f;
            _mover.SetMoveSpeed(40);
        }

        var startingDirection = _playerDashMonitor.CurrentCharges > 0 ? InputDestination() : null;

        if (startingDirection.HasValue == false)
        {
            return;
        }

        _startPosition = null;
        _endPosition   = null;
        if (_mover.IsMoving)
        {
            return;
        }

        _mover.CanMove          = true;
        _currentMovementPackage = _destinationSetter.GetDestinationFromFirstMove(_player.MoveAmountPerSwipe, startingDirection.Value);

        _mover.SetMovementPackage(_currentMovementPackage);
    }
コード例 #2
0
    public void Tick()
    {
        if (!_playerMover.IsMoving)
        {
            _playerDashMonitor.RefundChargesWhileNotMoving();
        }

        if (_playerMover.CurrentPlan != null)
        {
            if (_playerMover.CurrentPlan.IsFirst || _playerMover.CurrentPlan.Finished)
            {
                _playerSafetyCheck.Tick();
            }
        }

        if (_playerMover.CurrentPlan?.TargetUnit != null)
        {
            if (_currentUnit != null)
            {
                _currentUnit.Transform.GetComponent <SpriteRenderer>().color = Color.white;
            }
            _currentUnit = _playerMover.CurrentPlan.TargetUnit;
            _currentUnit.Transform.GetComponent <SpriteRenderer>().color = Color.magenta;
        }
        _playerMover.Tick();
        _parallelMovingCheck.Tick();

        if (_playerMover.IsMoving || _playerDashMonitor.CurrentCharges <= 0)
        {
            return;
        }

        var startingDirection = InputDestination();

        if (!startingDirection.HasValue || startingDirection == Vector2.zero)
        {
            return;
        }

        _playerMover.SetCurrentPlan(_movementPlanRequester.RequestStartPlan(startingDirection.Value, 5f));
    }