Пример #1
0
    //Method for when Player uses a consummable Item like a potion
    public void useItem(int index)
    {
        string playerID = "AlphaTest";

        PlayerInventoryTutorial inventory = GameObject.Find(playerID).GetComponent <PlayerInventoryTutorial>();
        ItemTutorial            item      = inventory.getItem(index);

        if (item.itemType.Equals("HealthPotion"))
        {
            GameObject.Find("SoundManager").GetComponent <InGameSoundManager>().playHpHealEffect();
            GameObject.Find(playerID).GetComponent <PlayerStatTutorial>().CmdAddHealth(20f);
            inventory.removeItem(index);
            updateSlotImage(index, "");
            foreach (Transform child in GameObject.Find(playerID).transform.FindChild("Alpha:Hips/Alpha:Spine/Alpha:Spine1/Alpha:Spine2/Alpha:RightShoulder/Alpha:RightArm/Alpha:RightForeArm/Alpha:RightHand"))
            {
                if (child.name.Contains("Item"))
                {
                    if (child.GetComponent <ItemTutorial>().itemName.Equals(item.itemName))
                    {
                        GameObject.Find(playerID).GetComponent <PlayerActionsTutorial>().CmdDeleteItem(child.gameObject);
                        break;
                    }
                }
            }
        }
        else if (item.itemType.Equals("StaminaPotion"))
        {
            GameObject.Find("SoundManager").GetComponent <InGameSoundManager>().playHpHealEffect();
            GameObject.Find(playerID).GetComponent <PlayerMovementTutorial>().CmdAddStamina();
            inventory.removeItem(index);
            updateSlotImage(index, "");
            foreach (Transform child in GameObject.Find(playerID).transform.FindChild("Alpha:Hips/Alpha:Spine/Alpha:Spine1/Alpha:Spine2/Alpha:RightShoulder/Alpha:RightArm/Alpha:RightForeArm/Alpha:RightHand"))
            {
                if (child.name.Contains("Item"))
                {
                    if (child.GetComponent <ItemTutorial>().itemName.Equals(item.itemName))
                    {
                        GameObject.Find(playerID).GetComponent <PlayerActionsTutorial>().CmdDeleteItem(child.gameObject);
                        break;
                    }
                }
            }
        }
    }
Пример #2
0
    //Method for when Player decides to throw the item away
    public void DropButtonYesPressed()
    {
        GameObject.Find("SoundManager").GetComponent <InGameSoundManager>().playInventoryDialogPopupYesEffect();
        GameObject dialog   = GameObject.Find("/ScreenUI/InventoryDropItemDialog/Panel");
        string     playerID = "AlphaTest";

        PlayerInventoryTutorial inventory = GameObject.Find(playerID).GetComponent <PlayerInventoryTutorial>();
        string itemToRemove = inventory.GetItemName(ItemToThrowAway);

        foreach (Transform child in GameObject.Find(playerID).transform.FindChild("Alpha:Hips/Alpha:Spine/Alpha:Spine1/Alpha:Spine2/Alpha:RightShoulder/Alpha:RightArm/Alpha:RightForeArm/Alpha:RightHand"))
        {
            if (child.name.Contains("Item"))
            {
                if (child.GetComponent <ItemTutorial>().itemName.Equals(itemToRemove))
                {
                    GameObject.Find(playerID).GetComponent <PlayerActionsTutorial>().CmdDropItem(GameObject.Find(playerID), child.gameObject);
                }
            }
        }
        inventory.removeItem(ItemToThrowAway);
        dialog.SetActive(false);
    }