示例#1
0
    void OnTriggerEnter2D(Collider2D item)
    {
        Equipable equipped = item.GetComponent <Equipable>();

        if (equipped != null)
        {
            switch (equipped.myType)
            {
            case EquipableType.GUN:
                Gun playerGun = GetComponentInChildren <Gun>();
                playerGun.gameObject.SetActive(true);
                playerGun.SetProjectile(equipped.myItem);
                playerGun.SetSprite(equipped.Collected());
                playerGun.SetFirePoint(equipped.firePoint.localPosition);
                break;

            case EquipableType.MELEE:
                break;

            case EquipableType.ARMOR:
                PlayerHealth health = GetComponent <PlayerHealth>();
                health.ArmorUp(1);
                equipped.Collected();
                break;
            }
        }
    }