private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag.Equals("Player"))
        {
            if (type == colliderType.Rock)
            {
                //slow down until exit
                playerMove.ModifySpeed(speedMod);
            }
            else if (type == colliderType.Scoreable && !scored)
            {
                //add score

                scored = true;
                ptTracker.AddScore(scoreOnCollide);

                GetComponent <AudioSource>().Play();

                //Temp way to get rid of scoreable
                gameObject.transform.position = new Vector3(-100, 0, 0);
            }
            else if (type == colliderType.PickUp)
            {
                energyBar.AddEnergy(energyAddAmount);
                gameObject.transform.position = new Vector3(-100, 0, 0);
            }
        }
    }
Beispiel #2
0
 public void GiveEnergy()       //This function is called when the gameobject is destroyed.
 {
     if (hasGivingEnergy == false)
     {
         energyBar.AddEnergy(amountGiven, transform.position);
         hasGivingEnergy = true;
     }
 }