Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Exit")
        {
            dungeonTransition = true;
            Invoke("GoDungeonPortal", 0.5f);
            Destroy(collision.gameObject);
        }

        else if (collision.tag == "Food" || collision.tag == "Soda")
        {
            UpdateHealth(collision);
            Destroy(collision.gameObject);
        }

        else if (collision.tag == "Item")
        {
            UpdateInventory(collision);
            Destroy(collision.gameObject);
            AdaptDifficulty();
        }

        else if (collision.tag == "Weapon")
        {
            if (weapon)
            {
                Destroy(transform.GetChild(0).gameObject);
            }

            collision.enabled          = false;
            collision.transform.parent = transform;
            weapon = collision.GetComponent <Weapon>();
            weapon.AcquireWeapon();
            weapon.inPlayerInventory = true;
            weapon.EnableSpriteRender(false);
            wallDamage = attackMod + 3;
            weaponComponent1.sprite = weapon.GetComponentImage(0);
            weaponComponent2.sprite = weapon.GetComponentImage(1);
            weaponComponent3.sprite = weapon.GetComponentImage(2);
            AdaptDifficulty();
        }
    }
Beispiel #2
0
 private void PickUpWeapon(Collider2D collision)
 {
     if (weapon)
     {
         Destroy(transform.GetChild(0).gameObject);
     }
     collision.enabled          = false;
     collision.transform.parent = transform;
     weapon = collision.GetComponent <Weapon>();
     weapon.AcquireWeapon();
     weapon.isInInventory = true;
     weapon.EnableSpriteRender(false);
     wallDamage = attactNumber + 3;
     for (int i = 0; i < weaponComps.Length; i++)
     {
         weaponComps[i].sprite = weapon.GetComponentImage(i);
         var tempColor = weaponComps[i].color;
         tempColor.a          = 1f;
         weaponComps[i].color = tempColor;
     }
     AdjustDifficulty();
 }