예제 #1
0
    void  OnTriggerEnter(Collider pickup)
    {
        if (!pickup.gameObject.GetComponent <PickUp>())
        {
            Debug.Log("you hit ? " + pickup.gameObject.name);
            return;
        }
        PickUp tempPickup = pickup.gameObject.GetComponent <PickUp>();

        if (tempPickup.isHealth && Health < (100 - tempPickup.amount))
        {
            Debug.Log("health picked up" + pickup.gameObject.name);
            Health += tempPickup.amount;
            tempPickup.DestoyPackage();
        }
        else if (tempPickup.isShotgunAmmo && weaponInHand == 2)
        {
            Debug.Log("ammo picked up" + pickup.gameObject.name);
            WS.Ammunition += tempPickup.amount;
            tempPickup.DestoyPackage();
        }
        else
        {
            Debug.Log("??" + pickup.gameObject.name);
        }
    }