Пример #1
0
 void Start()
 {
     audioManager          = AudioManager.instance;
     player                = Player.instance;
     controller            = GameController.instance;
     pooler                = PoolerManager.instance; // Pooler Manager
     player.ammo[ammoType] = initialAmmo;
     DisplayStats.UpdateRocketAmmo(initialAmmo);
 }
Пример #2
0
    void Update()
    {
        if (controller.isPaused)
        {
            return;
        }
        if (player.ammo[ammoType] > 0 && Input.GetKeyDown(rocket))
        {
            if (Time.time > shootTime + cooldown)
            {
                shootTime = Time.time;

                GameObject myRocket = pooler.Spawn("PRocket", transform.position, Quaternion.identity);                 // Pooling System to create or reuse a rocket

                myRocket.GetComponent <Projectile>().parent = transform.parent.gameObject;
                myRocket.GetComponent <Rigidbody2D>().AddForce(initForce, ForceMode2D.Impulse);
                audioManager.Play("RocketShoot");

                player.ammo[ammoType]--;
                DisplayStats.UpdateRocketAmmo(player.ammo[ammoType]);
            }
        }
    }
Пример #3
0
 public void AddAmmo(int type, int amount)
 {
     ammo[type] += amount;
     DisplayStats.UpdateRocketAmmo(ammo[1]);
 }