Esempio n. 1
0
    public void ItemManager(int SlotNumber) //Handles Item effects when the corresponding inventory slot is tapped
    {
        string Item = inventory[SlotNumber];

        if (!gameOver)
        {
            switch (Item)
            {
            case "Durian":
                inventory[SlotNumber] = "";
                numberOfItems--;
                PlayerFart.BeginDurationEffect(5f);
                break;

            case "Cookie":
                inventory[SlotNumber] = "";
                numberOfItems--;
                PlayerMovement.AddSpeedMultiplier(1.5f, 2f);
                break;

            case "WatermelonSlice":
                inventory[SlotNumber] = "";
                numberOfItems--;
                PlayerMovement.AddSpeedMultiplier(1.25f, 4f);
                break;

            case "Banana":    //Heals the player fully
                inventory[SlotNumber] = "PeeledBanana";
                if (GameObject.Find("BOY").GetComponent <BoyHealth>() != null)
                {
                    SegmentBarmanager.UpdateHealth(BoyHealth.maxHealth - BoyHealth.currentHealth);
                    BoyHealth.currentHealth = BoyHealth.maxHealth;
                }
                if (GameObject.Find("BOY").GetComponent <PlayerHealth>() != null)
                {
                    SegmentBarmanager.UpdateHealth(PlayerHealth.maxHealth - PlayerHealth.health);
                    PlayerHealth.health = PlayerHealth.maxHealth;
                }
                break;

            case "PeeledBanana":    //Drops a banana peel below the player
                inventory[SlotNumber] = "";
                numberOfItems--;
                Instantiate(peeledBanana, transform.position, Quaternion.Euler(0f, 180f, 0f));
                break;

            case "Fries":    //Player heals one health, changes fart type for 5 seconds
                if (PlayerFart.effectOn == false)
                {
                    inventory[SlotNumber] = "";
                    numberOfItems--;
                    if (GameObject.Find("BOY").GetComponent <PlayerHealth>() != null)
                    {
                        if (PlayerHealth.health < PlayerHealth.maxHealth)
                        {
                            SegmentBarmanager.UpdateHealth(1);
                            PlayerHealth.health += 1;
                        }
                    }
                    if (GameObject.Find("BOY").GetComponent <BoyHealth>() != null)
                    {
                        if (BoyHealth.currentHealth < BoyHealth.maxHealth)
                        {
                            SegmentBarmanager.UpdateHealth(1);
                            BoyHealth.currentHealth += 1;
                        }
                    }
                    PlayerFart.FartChange(1, 5f);
                }
                break;

            case "Egg":    //Changes fart type for 5 seconds
                if (PlayerFart.effectOn == false)
                {
                    inventory[SlotNumber] = "";
                    numberOfItems--;
                    PlayerFart.FartChange(3, 5f);
                }
                break;

            case "Kimchi":     //Player takes one damage, changes fart type for 5 seconds
                if (PlayerFart.effectOn == false)
                {
                    inventory[SlotNumber] = "";
                    numberOfItems--;
                    SegmentBarmanager.UpdateHealth(-1);
                    PlayerHealth.health -= 1;
                    PlayerFart.FartChange(4, 5f);
                }
                break;

            case "Onion":    //Changes fart type for 5 seconds
                if (PlayerFart.effectOn == false)
                {
                    inventory[SlotNumber] = "";
                    numberOfItems--;
                    PlayerFart.FartChange(2, 5f);
                }
                break;

            case "EnergyDrink":     //Player moves faster by 2 times and for 2 seconds
                inventory[SlotNumber] = "";
                numberOfItems--;
                PlayerMovement.AddSpeedMultiplier(2f, 2f);
                break;

            case "BakedBeans":     //Player's fart type gets changed to 5 for 4 seconds
                if (PlayerFart.effectOn == false)
                {
                    inventory[SlotNumber] = "";
                    numberOfItems--;
                    PlayerFart.FartChange(5, 4f);
                }
                break;

            case "Plastic Bag":     //Player stores the next fart in a plastic bag that is then placed on the ground
                inventory[SlotNumber] = "";
                numberOfItems--;
                PlayerFart.bagActive = true;
                break;

            default:
                break;
            }

            SlotManager.handleItemIcon(SlotNumber);
        }
    }