Exemplo n.º 1
0
    public void AddItem(ItemType itemType, int amount)
    {
        if (m_Items.ContainsKey(itemType))
        {
            m_Items[itemType] += amount;
        }
        else
        {
            m_Items.Add(itemType, amount);
        }

        if (amount > 0)
        {
            ItemData itemData = DataBase.Item.FindItem(itemType);

            if (itemData != null)
            {
                if (itemData.pickUpAnimation != ItemData.PickUpAnimation.None)
                {
                    m_MovementModel.ShowItemPickup(itemType);
                }
                if (itemData.IsEquipable == ItemData.EquipPosition.SwordHand)
                {
                    m_MovementModel.EquipWeapon(itemType);
                }
                if (itemData.IsEquipable == ItemData.EquipPosition.ShieldHand)
                {
                    m_MovementModel.EquipShield(itemType);
                }
            }
        }

        Debug.Log(amount + " " + itemType + " Added!");
    }
    public void AddItem(ItemType itemType, int amount)
    {
        if (m_Items.ContainsKey(itemType) == true)
        {
            m_Items[itemType] += amount;
        }
        else
        {
            m_Items.Add(itemType, amount);
        }

        if (amount > 0)
        {
            ItemData itemData = Database.Item.FindItem(itemType);

            if (itemData != null)
            {
                //if (itemData.Animation != ItemData.PickupAnimation.None)
                //{
                //    m_MovementModel.ShowItemPickup(itemType);
                //}

                if (itemData.IsEquipable == ItemData.EquipPosition.SwordHand)
                {
                    m_MovementModel.EquipWeapon(itemType);
                }

                //else if (itemData.IsEquipable == ItemData.EquipPosition.ShieldHand)
                //{
                //    m_MovementModel.EquipShield(itemType);
                //}
            }
        }
    }
    //Add X amount of items to our inventory
    public void AddItem(ItemType itemType, int amount)
    {
        if (m_Items.ContainsKey(itemType) == true)
        {
            m_Items[itemType] += amount;                                        //If item exists, just add more
        }
        else
        {
            m_Items.Add(itemType, amount);                        //Otherwise just add the item and its amount as new
        }
        if (amount > 0)                                           //If we have a bunch
        {
            ItemData itemData = Database.Item.FindItem(itemType); //Find the item in the database

            if (itemData != null)                                 //If it is valid data
            {
                if (itemData.Animation != ItemData.PickupAnimation.None)
                {
                    m_MovementModel.ShowItemPickup(itemType);                                                      //if using pickup anim, show the anim
                }
                if (itemData.IsEquipable == ItemData.EquipPosition.SwordHand)
                {
                    m_MovementModel.EquipWeapon(itemType);                                                           //If is a sword hand item, put it there
                }
                else if (itemData.IsEquipable == ItemData.EquipPosition.ShieldHand)
                {
                    m_MovementModel.EquipShield(itemType);                                                                 //If is a shield hand item, put it there
                }
            }
        }
    }
    public void AddItem(ItemType itemType, int amount, PickUpType pickupType)
    {
        if (items.ContainsKey(itemType) == true)
        {
            items[itemType] += amount;
        }
        else
        {
            items.Add(itemType, amount);
        }

        //   Debug.Log("Adding + " + itemType + "  " + amount);

        if (amount > 0)
        {
            ItemData itemData = Database.Item.FindItem(itemType);

            if (itemData != null)
            {
                if (itemData.getPickUpAnimation(pickupType) != ItemData.PickUpAnim.None)
                {
                    movementModel.ShowItemPickedUp(itemType, pickupType);
                }
                if (itemData.isEquipable == ItemData.EquipPosition.SwordHand)
                {
                    movementModel.EquipWeapon(itemType);
                    source.clip = getTheSword;
                    source.Play();
                }
                if (itemData.isEquipable == ItemData.EquipPosition.ShieldHand)
                {
                    movementModel.EquipShield(itemType);
                }

                if (itemData.type == ItemType.Bomb)
                {
                    source.clip = getTheBomb;
                    source.Play();
                }

                if (itemData.type == ItemType.Rupee)
                {
                    source.clip = getTheRupee;
                    source.Play();
                }
            }

            if (itemData.type == ItemType.Heart)
            {
                PlayHeartSound();
                // if (characterHealth.GetHealth() > 80)
                if (GameObject.Find("Character").GetComponent <CharacterHealth>().GetHealth() > 80)
                {
                    GameObject.Find("Character").GetComponent <CharacterHealth>().health = 100;
                }
                else
                {
                    GameObject.Find("Character").GetComponent <CharacterHealth>().AddHealth(20);
                }
            }
        }
    }