Example #1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player") && !collision.isTrigger)
     {
         //add coin to inventory
         //playerInventory.Bombs += 1;
         PickUpSignal.Raise();
         Destroy(this.gameObject); //destroy after pickup
     }
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Player") && !collision.isTrigger)
     {
         heartContainers.RuntimeValue    += 1;
         playerHealth.RuntimeValue        = heartContainers.RuntimeValue * 2;
         HeartContainerState.RuntimeValue = true;
         PickUpSignal.Raise();
         Destroy(gameObject);
     }
 }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !collision.isTrigger)
        {
            playerHealth.RuntimeValue += amount;

            // Looks if the playerhalth is not more than the amount of heartcontainers the player has. 2* because you can have half heart
            if (playerHealth.RuntimeValue > heartContainers.RuntimeValue * 2f)
            {
                playerHealth.RuntimeValue = heartContainers.RuntimeValue * 2f;
            }
            PickUpSignal.Raise();

            Destroy(this.gameObject);
        }
    }