Ejemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        // We hit a player
        if (collision.tag == "Team1" || collision.tag == "Team2")
        {
            Debug.Log("Player has collided with item : power " + itemData.powerMultiplier + " speed " + itemData.speedMultiplier);

            Player player = collision.GetComponent <Player>();
            player.PickUpItem(itemData);

            // Send the item back to the pool if it belongs to the pool
            // Items with index smaller then 0 will be items spawned by abilities
            if (index >= 0)
            {
                ItemPool.DeactivateItem(index);
            }
            else
            {
                Destroy(gameObject);
            }

            EventManager.TriggerEvent(GameEvent.ItemPickedUp);
        }
    }