예제 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (soundEffects == null)
        {
            soundEffects = GameObject.FindGameObjectWithTag("AudioManager").GetComponent <SoundEffectsManager>();
        }
        // Items is for player ultimately. It will be trouble if monster can even pick up the stuff!
        if (other.tag.Equals("Player"))
        {
            // Need to find the inventory again if can't find it!
            if (playerInventory == null)
            {
                Start();
            }
            if (theItemStuff == null)
            {
                Start();
            }
            Debug.Log("Interacting with: " + other.name);
            playerInventory.passInInventory(theItemStuff.m_itemInform);

            // We also need to give the player back some health!
            HealthScript zePlayerHealth = other.GetComponent <HealthScript>();
            zePlayerHealth.modifyHealth(m_heal);

            itemInteractParticles.transform.position = transform.position;
            itemInteractParticles.playEffect();
            if (soundEffects != null)
            {
                soundEffects.playSound("pickupItems");
            }
            Destroy(gameObject);
        }
    }