예제 #1
0
    private void FixedUpdate()
    {
        var angleDiff = Vector3.SignedAngle(transform.right, targetDir, Vector3.forward);

        if (angleDiff < -5.0f)
        {
            plane.RotateCW();
        }
        if (angleDiff > 5.0f)
        {
            plane.RotateCCW();
        }

        if (transform.right.x < 0 && !plane.isUpsideDown())
        {
            plane.Roll();
        }

        if (transform.right.x > 0 && plane.isUpsideDown())
        {
            plane.Roll();
        }

        if (plane.throttle < targetThrottle - 0.1f)
        {
            plane.Accelerate();
        }
        if (plane.throttle > targetThrottle + 0.1f)
        {
            plane.Decelerate();
        }

        if (shoot)
        {
            Projectile projectile = shooter.Shoot(transform.right);
            if (projectile != null)
            {
                AudioPlayer.main.PlaySound(GameEvent.EnemyGunFires);
            }
        }

        if (bomb)
        {
            bomber.Drop((Vector2)bomber.transform.position, rb2D.velocity);
            Projectile projectile = shooter.Shoot(transform.right);
            if (projectile != null)
            {
                AudioPlayer.main.PlaySound(GameEvent.EnemyGunFires);
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (playerControlsEnabled.Toggle)
        {
            if (Input.GetKey(turnCW))
            {
                rotateClockwise = true;
            }
            else if (Input.GetKey(turnCCW))
            {
                rotateCounterClockwise = true;
            }

            if (Input.GetKey(throttle))
            {
                accelerate = true;
            }
            else if (Input.GetKey(dethrottle))
            {
                decelerate = true;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                flying.Roll();
            }
        }
    }