Esempio n. 1
0
    public override IEnumerator UsePowerup(GameObject player)
    {
        CarController controller = player.GetComponent <CarController>();
        PlayerStats   ps         = player.GetComponent <PlayerStats>();

        // apply powerup actions
        Missile missile = missileManager.CreateMissile(player.transform, ps.hasWhiteBrick);

        if (ps.hasWhiteBrick)
        {
            Transform playerToAttack = GetPlayerToAttack(player.transform);
            missile.Follow(playerToAttack);
        }
        else
        {
            missile.Shoot();
        }

        ps.UsedPowerup();

        yield return(new WaitForSeconds(15));

        // undo actions

        // if not already destroyed
        if (missile != null)
        {
            missile.Destroy();
        }
    }