Beispiel #1
0
    private void Update()
    {
        if (!_canMove)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            _shipShooterScript.FrontalShoot();
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            _shipShooterScript.SideShoot(true);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            _shipShooterScript.SideShoot();
        }
    }
    protected override void FieldOfView()
    {
        base.FieldOfView();

        if (_currentDistance < _maxDistance && _currentAngle < _maxAngle && _currentAngle > -_maxAngle)
        {
            _canPatrol       = false;
            _wasSeeingPlayer = true;

            if (_rotateShipRoutine != null)
            {
                StopRotateRoutine();
            }

            if (_currentAngle > 60f)
            {
                _shipShooterScript.SideShoot(true);
            }
            else if (_currentAngle < -60f)
            {
                _shipShooterScript.SideShoot();
            }
            else
            {
                direction = _player.transform.position - transform.position;
                ShipObject.transform.up = Vector3.Lerp(ShipObject.transform.up, direction, Time.fixedDeltaTime * _rotateSpeed);

                _shipShooterScript.FrontalShoot();
            }
        }
        else
        {
            if (_wasSeeingPlayer)
            {
                _rotateShipRoutine = StartCoroutine(RotateShip());
                _wasSeeingPlayer   = false;
            }
        }
    }