Beispiel #1
0
 private void UpdateMovement()
 {
     PlayerPosition();
     if (_x < 0)
     {
         _movement.x = -0.1f;
     }
     if (_x > 0)
     {
         _movement.x = 0.1f;
     }
     if (_y + _sineCurveDistance < 0)
     {
         _movement.y = -0.1f;
     }
     if (_y - _sineCurveDistance > 0)
     {
         _movement.y = 0.1f;
     }
     if (Mathf.Pow((Mathf.Pow(_x, 2) + Mathf.Pow(_y, 2)), 0.5f) < _distanceToTarget)
     {
         _state = State.ATTACKING;
     }
     _objectRotation.FollowGameObject(_player);
     _objectMovement.Movement(_movement.x, _movement.y, _deltaTime, _movementSpeed);
 }
    private void Movement()
    {
        _deltaTime      = Time.deltaTime;
        _playerPosition = _player.transform.position;
        if (_playerPosition.x - transform.position.x < 0)
        {
            _movementX = -0.1f;
        }
        if (_playerPosition.x - transform.position.x > 0)
        {
            _movementX = 0.1f;
        }
        if (_playerPosition.y - transform.position.y < 0)
        {
            _movementY = -0.1f;
        }
        if (_playerPosition.y - transform.position.y > 0)
        {
            _movementY = 0.1f;
        }

        _objectRotation.FollowGameObject(_player);
        _objectMovement.Movement(_movementX, _movementY, _deltaTime, _movementSpeed);
    }