Ejemplo n.º 1
0
    public void LoadItems()
    {
        var allItems  = GameManager.Instance.GetComponent <Items>().allConsumablesDict;
        var yourItems = GameManager.Instance.Inventory.ConsumablePocket;

        int q = 1;

        //loops through all the items that you have, and if the selected monster meets the equipment requirements, then you can equip this item to the monster
        for (int i = 0; i < yourItems.items.Count; i++)
        {
            string name = yourItems.items[i].itemName;

            PocketItem p = yourItems.items[i];
            //EquipmentScript eq = Instantiate(allEquips[name]);
            ConsumableItem cItem = Instantiate(allItems[name]);
            cItem.inventorySlot = p;
            var x = Instantiate(itemObject, new Vector2(itemPlacement.transform.position.x + (50 * (q - 1)), itemPlacement.transform.position.y), Quaternion.identity);
            x.transform.SetParent(transform, true);
            x.GetComponent <ConsumableObject>().consumableItem = cItem;
            x.GetComponent <ConsumableObject>().LoadItem();
            x.GetComponentInChildren <TMP_Text>().text = "";
            x.transform.localScale = new Vector3(1f, 1f, 1f);
            x.tag  = "ConsumableItem";
            x.name = cItem.itemName;

            q += 1;
        }
    }
Ejemplo n.º 2
0
        public Consumable(string name, string itemdescribe, bool buyable, int price, int itemStrength, bool questitem, Rarity rare, ConsumableItem itemType, List <ItemType> itemDefine)
        {
            Name              = name;
            ItemDescribe      = itemdescribe;
            Buyable           = buyable;
            Price             = price;
            ItemStrength      = itemStrength;
            QuestItem         = questitem;
            MyRare            = rare;
            MyConsuamableType = itemType;
            MyItemType        = itemDefine;
            switch (MyConsuamableType)
            {
            case ConsumableItem.Healing:
                MyEffect = new Heal(ItemStrength);
                break;

            case ConsumableItem.Food:
                MyEffect = new Food(ItemStrength);
                break;

            case ConsumableItem.Boost:
                MyEffect = new Buff(ItemStrength);
                break;

            case ConsumableItem.Defense:
                MyEffect = new Defense(ItemStrength);
                break;

            case ConsumableItem.Mana:
                MyEffect = new ManaPotion(ItemStrength);
                break;
            }
        }
 public void ClearConsumableItemInventorySlot() //limpiamos el slot del inventario
 {
     consumableItem = null;
     icon.sprite    = null;
     icon.enabled   = false;
     gameObject.SetActive(false);
 }
Ejemplo n.º 4
0
    // Loads inventory from xml file
    void LoadInvetory()
    {
        XmlDocument xmlDocument = new XmlDocument();

        xmlDocument.LoadXml(INVENTORY_XML.text);
        XmlNodeList itemNodeList = xmlDocument.GetElementsByTagName("Item");

        // Read items from xml, copy from database, and add to inventory
        foreach (XmlNode itemInfo in itemNodeList)
        {
            XmlNodeList itemContent = itemInfo.ChildNodes;
            string      tempName    = "";
            string      tempCount   = "";

            foreach (XmlNode content in itemContent)
            {
                switch (content.Name)
                {
                case "ItemName":
                    tempName = content.InnerText;
                    break;

                case "ItemCount":
                    tempCount = content.InnerText;
                    break;
                }
            }

            // Get item dictionary, set count, and add item to list
            Dictionary <string, string> tempDict;

            if (itemDatabase != null)
            {
                tempDict = itemDatabase.GetItem(tempName);
                if (tempDict != null)
                {
                    switch (tempDict ["ItemType"])
                    {
                    case "EQUIP":
                        EquipItem tempEquip = new EquipItem(tempDict);
                        tempEquip.Count = int.Parse(tempCount);
                        playerEquipItems.Add(tempEquip);
                        break;

                    case "CONSUMABLE":
                        ConsumableItem tempConsumable = new ConsumableItem(tempDict);
                        tempConsumable.Count = int.Parse(tempCount);
                        playerConsumableItems.Add(tempConsumable);
                        break;

                    case "STORY":
                        StoryItem tempStory = new StoryItem(tempDict);
                        tempStory.Count = int.Parse(tempCount);
                        playerStoryItems.Add(tempStory);
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 소비 아이템 정보를 서버에 추가한다.
    /// 성공 할 경우 item의 id 값을 가져와 item에 대입한다.
    /// </summary>
    /// <returns>응답 메세지</returns>
    public IEnumerator IAddConsumableItemToServer(ConsumableItem item)
    {
        WWWForm form = new WWWForm();

        form.AddField("Name", PlayerInformation.userData.name);
        form.AddField("Character_Type", (int)PlayerInformation.userData.characterType);
        form.AddField("Item_Name", item.name);
        form.AddField("Type", (int)item.type);
        form.AddField("Gold", item.gold);
        form.AddField("Image_Number", item.imageNumber);

        UnityWebRequest www = UnityWebRequest.Post(ADD_CONSUMABLE_ITEM_URL, form);

        yield return(www.SendWebRequest());

        if (www.isDone)
        {
            JSONObject jsonData = (JSONObject)JSON.Parse(www.downloadHandler.text);

            int message = jsonData["affectedRows"];

            if (message == 1)
            {
                item.id = jsonData["insertId"];
                Debug.Log("서버에 아이템 저장 성공" + www.downloadHandler.text);
            }
            else
            {
                Debug.LogWarning("서버에 아이템 저장 실패 : " + www.downloadHandler.text);
            }
        }
    }
Ejemplo n.º 6
0
        public void UseConsumableItem_2()
        {
            IEffect insta = new InstantEffect(EffectTarget.Character, StatType.Health, -40f);

            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.AddEffect(insta);

            IEffect        restoreHealth = new TimeEffect(EffectTarget.Character, StatType.Health, +10f, 3, 1);
            ConsumableItem potion        = new ConsumableItem(99, "Health of Potion", "Get 40hp", restoreHealth);

            Assert.AreEqual(60f, hero.GetStat(StatType.Health).Value);

            hero.UseItem(potion); //+10hp/stack x3

            Assert.AreEqual(70f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(80f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(90f, hero.GetStat(StatType.Health).Value);

            ((TimeEffect)potion.Effect).Refill();
            hero.UseItem(potion);
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
            hero.Update();
            Assert.AreEqual(100f, hero.GetStat(StatType.Health).Value);
        }
Ejemplo n.º 7
0
 public GameMove(Vector2Int start, Vector2Int end, ConsumableItem item)
 {
     StartPosition = start;
     EndPosition   = end;
     MoveType      = GameMoveType.Item;
     UsedItem      = item;
 }
Ejemplo n.º 8
0
 public void SetupItemButton(ConsumableItem receivedItem, GeneralUiManager ui)
 {
     item           = receivedItem;
     uiManager      = ui;
     itemName.text  = item.itemName;
     itemPrice.text = item.price.ToString();
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 현재 클래스의 데이터 값들을 복사한 데이터를 반환한다.
    /// </summary>
    /// <returns>반환할 데이터</returns>
    public ConsumableItem GetCopiedData()
    {
        ConsumableItem data = new ConsumableItem();

        data.CopyData(this);
        return(data);
    }
 private IDictionary <IItem, int> GetItemsAndOccuranceChance(ShopTypes shopType)
 {
     return(shopType switch
     {
         ShopTypes.Tavern => new Dictionary <IItem, int>()
         {
             { ConsumableItem.GetConsumableItem(ConsumableItemTypes.Beer), 1 }
         },
         ShopTypes.Inn => new Dictionary <IItem, int>()
         {
             { ConsumableItem.GetConsumableItem(ConsumableItemTypes.Beer), 1 }
         },
         ShopTypes.ArmorShop => new Dictionary <IItem, int>()
         {
             { Armor.GetArmor(ArmorTypes.CopperArmor), 10 },
             { Armor.GetArmor(ArmorTypes.IronArmor), 3 },
         },
         ShopTypes.WeaponShop => new Dictionary <IItem, int>()
         {
             { Weapon.GetWeapon(WeaponTypes.Axe), 10 },
             { Weapon.GetWeapon(WeaponTypes.Spear), 15 },
             { Weapon.GetWeapon(WeaponTypes.Sword), 13 },
         },
         ShopTypes.ItemShop => new Dictionary <IItem, int>()
         {
             { ConsumableItem.GetConsumableItem(ConsumableItemTypes.HealingPotion), 1 }
         },
         ShopTypes.BitOfEverythingShopType => new Dictionary <IItem, int>()
         {
             { ConsumableItem.GetConsumableItem(ConsumableItemTypes.HealingPotion), 50 },
             { Armor.GetArmor(ArmorTypes.CopperArmor), 1 },
             { Weapon.GetWeapon(WeaponTypes.Axe), 4 },
         },
         _ => null
     });
Ejemplo n.º 11
0
 public void ClearConsumableItem()
 {
     consumableItem = null;
     icon.sprite    = null;
     icon.enabled   = false;
     gameObject.SetActive(false);
 }
Ejemplo n.º 12
0
 public void RemoveItem(ConsumableItem item)
 {
     if (items.Contains(item))
     {
         items.Remove(item);
     }
 }
    public override void OnPickUp(PlayerItemPickUpData data)
    {
        // Get Item Reference
        ConsumableItem consumableItem = Item as ConsumableItem;

        // Spawn Item
        if (Item.gameObject.IsPrefab())
        {
            consumableItem = ItemDB.Inst.SpawnItem(Item.GetType()).GetComponent <ConsumableItem>();
        }

        // Add To Inventory
        if (PlayerInventoryManager.consumableHotbar.TryAddItem(consumableItem))
        {
            goto EXIT;
        }

        if (PlayerInventoryManager.inventory.TryAddItem(consumableItem))
        {
            goto EXIT;
        }

        return;

EXIT:
        Destroy(gameObject);
    }
Ejemplo n.º 14
0
 private void UseItemOnTarget()
 {
     if (Databases.items[toUse].itemType == ItemType.Consumable)
     {
         ConsumableItem consumable = (ConsumableItem)Databases.items[toUse];
         bool           used       = false;
         if (consumable.targetType == TargetType.One)
         {
             if (consumable.hpRestore > 0 && target.currentHealth < target.maxHealth)
             {
                 target.RestoreHp(consumable.hpRestore);
                 used = true;
             }
             if (consumable.mpRestore > 0 && target.currentMana < target.maxMana)
             {
                 target.RestoreMp(consumable.mpRestore);
                 used = true;
             }
         }
         else if (consumable.targetType == TargetType.AllFriendly)
         {
             foreach (GameObject member in party.playerParty)
             {
                 UnitStats memberStats = member.GetComponent <UnitStats>();
                 if (memberStats.available == true)
                 {
                     if (consumable.hpRestore > 0 && memberStats.currentHealth < memberStats.maxHealth)
                     {
                         memberStats.RestoreHp(consumable.hpRestore);
                         used = true;
                     }
                     if (consumable.mpRestore > 0 && memberStats.currentMana < memberStats.maxMana)
                     {
                         memberStats.RestoreMp(consumable.mpRestore);
                         used = true;
                     }
                 }
             }
         }
         if (used)
         {
             party.RemoveItemFromInventory(toUse);
             sender.GetComponent <InventoryButtonController>().UpdateText();
             ic.UpdateTargetPanel();
             if (party.playerInventoryCount[toUse] < 1)
             {
                 sender.GetComponent <InventoryButtonController>().DestroySelf();
                 ic.HideTargetPanel();
                 toUse  = -1;
                 sender = null;
             }
             target = null;
         }
     }
     else
     {
         //SHOW SOME KIND OF WARNING
     }
 }
Ejemplo n.º 15
0
 //consumable weapons methods
 public void AddConsumableItem(ConsumableItem newItem) //add item to weapon inventory slot
 {
     //sustituimos los icons del arma nueva
     consumableItem = newItem;
     icon.sprite    = consumableItem.itemIcon;
     icon.enabled   = true;
     gameObject.SetActive(true);
 }
        /// <summary>
        /// Create an consumable item from a given itemForSave
        /// </summary>
        /// <param name="itemForSave"></param>
        /// <returns></returns>
        private ConsumableItem CreateConsumableItem(ItemForSave itemForSave)
        {
            ConsumableItem item = new ConsumableItem();

            SetCommonProperties(itemForSave, item);

            return(item);
        }
        /// <summary>
        /// Creates an itemForSave for a given ConsumableItem
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private ItemForSave ConvertFromItem(ConsumableItem item)
        {
            ItemForSave itemForSave = new ItemForSave();

            SetCommonProperties(item, itemForSave);

            return(itemForSave);
        }
Ejemplo n.º 18
0
 }             // Item image
 /// <summary>
 /// 값을 복사한다.
 /// </summary>
 /// <param name="data">복사 할 소비 아이템</param>
 public void CopyData(ConsumableItem data)
 {
     id          = data.id;
     name        = data.name;
     gold        = data.gold;
     type        = data.type;
     imageNumber = data.imageNumber;
 }
Ejemplo n.º 19
0
 public virtual void Drink(ConsumableItem item, Inventory inventory)
 {
     for (int i = 0; i < item.effects.Count; i++)
     {
         effects.AddEffect(Instantiate(item.effects[i]));
     }
     inventory.DeleteItem(item);
 }
Ejemplo n.º 20
0
//Method to Remove UI
    public void RemoveItem(ConsumableItem item)
    {
        items.RemoveAt(1);
        items.Insert(1, null);
        currentPotion = null;
        RefreshUI();
        return;
    }
Ejemplo n.º 21
0
 public void Consume(ConsumableItem item)
 {
     if (!Inventory.Any(i => i == item))
     {
         throw new InvalidOperationException($"The Character ({Name}) has not this Item: {item.Name}");
     }
     Inventory.Remove(item);
     item.Apply(this);
 }
Ejemplo n.º 22
0
    private void Update()
    {
        if (consumesItem)
        {
            ConsumableItem consumableItem = itemOnSurface as ConsumableItem;
            if (amountOnSurface == numberNeeded && itemOnSurface == null)
            {
                amountOnSurface = 0;
                PlaceItemOnMe(Instantiate(itemToSpawn, positionOfItem.position, positionOfItem.rotation, transform));
            }
            else if (consumableItem && consumableItem.canBeUsedFor == typeToConsume)
            {
                if (placeDownSound.Length != 0)
                {
                    consumeItemSoundEvent = FMODUnity.RuntimeManager.CreateInstance(consumeItemSound);
                    consumeItemSoundEvent.start();
                }

                Debug.Log("Consume item");
                Destroy(itemOnSurface.gameObject);
                itemOnSurface = null;
                amountOnSurface++;
            }

            textForConsumeables.text = amountOnSurface + "/" + numberNeeded;
        }

        if (itemOnSurface is UsableItem)
        {
            UsableItem item = itemOnSurface as UsableItem;

            if (item.percentageFull != 100 && hasItemOnCoroutine == null)
            {
                hasItemOnCoroutine = StartCoroutine(HasItemOnRoutine(item));

                if (placeDownSound.Length != 0)
                {
                    soundEvent = FMODUnity.RuntimeManager.CreateInstance(placeDownSound);
                    soundEvent.start();
                    Debug.Log("Playing put down sound");
                }
            }
            else if (item.percentageFull == 100 && hasItemOnCoroutine != null)
            {
                StopCoroutine(hasItemOnCoroutine);
                hasItemOnCoroutine = null;
                soundEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
            }
        }
        else if (hasItemOnCoroutine != null)
        {
            StopCoroutine(hasItemOnCoroutine);
            hasItemOnCoroutine = null;
            soundEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
        }
    }
Ejemplo n.º 23
0
 private void RemoveConsumable()
 {
     if (Consumable)
     {
         _player.RemoveConsumable(Consumable);
         Consumable                = null;
         _useButtonImage.sprite    = _defaultSprite;
         _removeButtonImage.sprite = _defaultSprite;
     }
 }
Ejemplo n.º 24
0
        public void EatFood(ConsumableItem food, int number)
        {
            float cal = food.GetCalories() * number;

            bodyManager.AddCalories(cal);

            float size = food.GetSize() * number;

            fullnessPoints.value += size;
        }
Ejemplo n.º 25
0
    public ConsumableItem Copy()
    {
        ConsumableItem i = new ConsumableItem(consumeableEffect, itemParentKey);

        i.consumeableEffect = consumeableEffect.Copy() as Skill;

        i.animControllerID = animControllerID;

        return(i);
    }
Ejemplo n.º 26
0
 public void RemoveItem(ConsumableItem item)
 {
     foreach (ConsumableItem x in items)
     {
         if (x == item)
         {
             items.Remove(x);
             break;
         }
     }
 }
Ejemplo n.º 27
0
 public override void _Ready()
 {
     player         = GetParent() as Player;
     turnManager    = GetNode("/root/TurnManager") as TurnManager;
     grid           = GetTree().GetRoot().GetNode("Game/Grid") as Grid;
     console        = GetTree().GetRoot().GetNode("Game/CanvasLayer/GUI/Console") as Console;
     playerInfo     = GetTree().GetRoot().GetNode("Game/CanvasLayer/GUI/SideMenu/PlayerInfo") as PlayerInfo;
     movementCursor = GetParent().GetNode("MovementCursor") as MovementCursor;
     attackTimer    = GetParent().GetNode("AttackTimer") as Timer;
     potion         = potionScene.Instance() as ConsumableItem;
 }
Ejemplo n.º 28
0
 public void RemoveItem(ConsumableItem item)
 {
     for (int i = 0; i < itens.Count; i++)
     {
         if (itens[i] == item)
         {
             itens.RemoveAt(i);
             break;
         }
     }
 }
Ejemplo n.º 29
0
    public override void OnConsumeItem(Player player, ConsumableItem item)
    {
        base.OnConsumeItem(player, item);

        if (item is Food)
        {
            player.Health.baseHP += maxHpBonus;
            player.Health.UpdateHealth();
            player.GainLife(maxHpBonus);
        }
    }
Ejemplo n.º 30
0
 public void UseItem(BattleParticipant target, ItemStack item)
 {
     MessageBox.instance.setText($"{name} uses {item.item.name} on {target.name}!");
     if (item.item.GetType() == typeof(ConsumableItem))
     {
         ConsumableItem cItem = (ConsumableItem)item.item;
         target.HP += cItem.restoreHP;
         target.MP += cItem.restoreMP;
     }
     item.amount -= 1;
 }
        public void Initialize()
        {
            storageInfo = new BuildableItemStorageInformation(BuildableItemEnum.White_Flour.ToString());

            bitem = new ConsumableItem
            {
                ItemCode = BuildableItemEnum.White_Pizza_Dough,
                Stats = new List<BuildableItemStat>
                {
                    new BuildableItemStat
                    {
                        RequiredLevel = 2,
                        CoinCost = 50,
                        Experience = 100,
                        BuildSeconds = 60,
                        CouponCost = 0,
                        SpeedUpCoupons = 1,
                        SpeedUpSeconds = 60,
                        RequiredItems = new List<ItemQuantity>
                        {
                            new ItemQuantity 
                            {
                                ItemCode = BuildableItemEnum.White_Flour,
                                StoredQuantity = 1
                            },
                            new ItemQuantity
                            {
                                ItemCode = BuildableItemEnum.Salt,
                                StoredQuantity = 1
                            },
                            new ItemQuantity
                            {
                                ItemCode = BuildableItemEnum.Yeast,
                                StoredQuantity = 1                    
                            }
                        }
                    }
                },
                ConsumableStats = new List<ConsumableItemStat>
                {
                    new ConsumableItemStat
                    {
                        ProductionQuantity = 2
                    }                   
                }
            };
        }
 public void collectItem(ConsumableItem item)
 {
     consumableItems.Add(item);
 }
 public void removeItem(ConsumableItem item)
 {
     consumableItems.Remove(item);
 }
Ejemplo n.º 34
0
 public void Consume(ConsumableItem item)
 {
     if(!Inventory.Any(i => i == item))
     {
         throw new InvalidOperationException($"The Character ({Name}) has not this Item: {item.Name}");
     }
     Inventory.Remove(item);
     item.Apply(this);
 }