Exemple #1
0
 void Update()
 {
     if (playerControlsEnabled.Toggle)
     {
         if (hotkeyMap.GetKeyDown(GameAction.DropBomb))
         {
             dropper.Drop((Vector2)dropper.transform.position, rb2D.velocity);
         }
     }
 }
Exemple #2
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);
            }
        }
    }