Example #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag.Equals("Player"))
     {
         powerup.Apply(other.gameObject);
         powerupEvent.Raise();
         Destroy(gameObject);
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Powerup")
     {
         Powerup powerup = other.GetComponent <Powerup>();
         powerup.Apply(stats);
         Destroy(other.gameObject);
     }
 }
Example #3
0
    private void OnTriggerEnter(Collider other)
    {
        Player player = other.gameObject.GetComponent <Player>();

        if (player != null)
        {
            player.StatTracker.AddStat(new CountStat(player, "pickups", 1));
            powerup.Apply(player);
            Destroy(gameObject);
        }
    }
Example #4
0
    public void AddPowerup(Powerup powerupToAdd)
    {
        // Apply the powerup changes
        if (powerupToAdd.name == "FirepowerPU")
        {
            powerupToAdd.Apply(tankData);
        }
        if (powerupToAdd.name == "HealthPU")
        {
            powerupToAdd.Apply(tankHealth);
        }
        if (powerupToAdd.name == "FireRatePU")
        {
            powerupToAdd.Apply(tankData);
        }

        // Add the powerup to a list of powerups
        // *** Do not add it to the list if you want it to be permanent
        powerupsList.Add(powerupToAdd);
    }
Example #5
0
 void PickPowerup(Powerup powerup)
 {
     powerup.Apply(this);
     Destroy(powerup.gameObject);
 }