Exemplo n.º 1
0
    public void createSceneItemsList(string xmlfilename)
    {
        // <Item prefab="Chair" x="1" y="10" rot="90" />
        foreach (DeserializedLevels.Item deserializedItem in getCurLevel(xmlfilename).items)
        {
            // caching prefabString i.e. "phone"
            string prefabString = deserializedItem.prefab;

            // if the prefab in the item XmlNode has not been loaded then add it to the prefabsDict dictionary,
            if (!prefabPool.ContainsKey(prefabString))
            {
                // load prefab
                GameObject prefabObject = Resources.Load(prefabsFolder + prefabString, typeof(GameObject)) as GameObject;

                // if unsuccesful, error message and jump to next in the foreach loop
                if (prefabObject == null)
                {
                    Debug.LogError("Prefab \"" + prefabString + "\" does not exists.");
                    continue;
                }

                // otherwise add to dictionary
                prefabPool.Add(prefabString, prefabObject);
            }

            ItemStruct item = new ItemStruct(prefabPool[prefabString], deserializedItem);

            sceneItemsList.Add(item);
        }
    }
Exemplo n.º 2
0
    // 아이템 삽입 ( 상호작용 아이템과 수집템만 인벤토리에 삽입 할 수 있다)
    public void Insert(ItemStruct item)
    {
        if(item.function.Equals((int)ItemFunction.Interaction) ||
            item.function.Equals((int)ItemFunction.Collection))
            ownItems.Add(item);

    }
Exemplo n.º 3
0
 // Remove item from eq
 public void RemoveItem(ItemStruct item)
 {
     if (items.ContainsKey(item) && items[item] > 0)
     {
         items[item]--;                                             // remove 1 item if it is in dictionary and it's quantity is greater than 0
     }
 }
Exemplo n.º 4
0
    public void Update()
    {
        ItemStruct itemData = new ItemStruct();

        if (Inventory.myInv.GetItemFromIndex(index, ref itemData))
        {
            //dont show picture if we are dragging the current item
            if (Inventory.myInv.CurrentSelectedItem != index)
            {
                imageComp.enabled = true;
            }

            imageComp.texture = itemData.itemTexture;

            if (itemData.numberOfItemsInStack > 1)
            {
                textComp.text = itemData.numberOfItemsInStack.ToString();
            }
            else
            {
                textComp.text = "";
            }
        }
        else
        {
            imageComp.enabled = false;
            textComp.text     = "";
        }
    }
Exemplo n.º 5
0
        void OnGUI()
        {
            if (list == null)
            {
                return;
            }
            EditorGUILayout.LabelField(key);
            for (int i = 0; i < list.Count; i++)
            {
                ItemStruct str = list[i];

                EditorGUILayout.LabelField(str.lang.ToString());
                EditorGUI.BeginChangeCheck();
                newS = EditorGUILayout.TextArea(str.currentString);
                if (EditorGUI.EndChangeCheck())
                {
                    str.currentString = newS;
                    if (str.entry == null)
                    {
                        list[i].entry = new LanguageFileEntry(key, newS);
                        str.langFile.entries.Add(str.entry);
                    }
                    else
                    {
                        str.entry.value = newS;
                    }
                    EditorUtility.SetDirty(str.langFile);
                }

                EditorGUILayout.Space();
            }
        }
Exemplo n.º 6
0
 public void SetSectionItemsByIndex(int index, ItemStruct itemStruct)
 {
     if (index == (int)SectionIndex.torso)
     {
         equippedTorsoItems = itemStruct;
     }
     else if (index == (int)SectionIndex.head)
     {
         equippedHeadItems = itemStruct;
     }
     else if (index == (int)SectionIndex.legs)
     {
         equippedLegItems = itemStruct;
     }
     else if (index == (int)SectionIndex.leftArm)
     {
         equippedLeftArmWeapons = itemStruct;
     }
     else if (index == (int)SectionIndex.rightArm)
     {
         equippedRightArmWeapons = itemStruct;
     }
     else if (index == (int)SectionIndex.leftShoulder)
     {
         equippedLeftShoulderWeapons = itemStruct;
     }
     else if (index == (int)SectionIndex.rightShoulder)
     {
         equippedRightShoulderWeapons = itemStruct;
     }
     else
     {
         return;
     }
 }
Exemplo n.º 7
0
        public void RefreshRewardData(Hashtable activityData)
        {
            m_ChiefRewardList = new List <LTActivityChiefRewardData>(4);
            for (int i = 0; i < m_TimeRewardlist.Count; i++)
            {
                var template = m_TimeRewardlist[i];
                LTActivityChiefRewardData itemData = new LTActivityChiefRewardData();

                int receivedValue = EB.Dot.Integer(string.Format("stages.{0}", template.id), activityData, 0);

                itemData.ActivityID   = m_ActivityId;
                itemData.HasReceived  = receivedValue == 1;
                itemData.RequiredWins = template.stage;
                itemData.ID           = template.id;
                itemData.WinCount     = m_WinCount;
                itemData.RewardData   = new List <LTShowItemData>();

                for (int j = 0; j < template.reward_items.Count; j++)
                {
                    ItemStruct rewardStruct = template.reward_items[j];
                    itemData.RewardData.Add(new LTShowItemData(rewardStruct.id, rewardStruct.quantity, rewardStruct.type));
                }

                itemData.Controller = this;
                m_ChiefRewardList.Add(itemData);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 控制层:增加当某个道具的数量
 /// </summary>
 /// <param name="item"></param>
 /// <param name="number"></param>
 public void AddItemCount(ItemStruct item, int number)
 {
     if (number > 0)
     {
         Mod_PlayerPackageDataProxy.GetInstance().AddItemCount(item, number);
     }
 }
Exemplo n.º 9
0
    private void CreateSceneItemsList()
    {
        foreach (DeserializedLevels.Item deserializedItem in GetCurrentLevel().items)
        {
            string prefabName = deserializedItem.prefab;

            // if the prefab in the item XmlNode has not been loaded then add it to the prefabPool
            if (!prefabPool.ContainsKey(prefabName))
            {
                GameObject prefabObject = GlobalPrefabs.GetPrefab(prefabName);

                if (prefabObject == null)
                {
                    // If we couldn't find the object, break out and continue the loop
                    continue;
                }

                prefabPool.Add(prefabName, prefabObject);
            }

            ItemStruct item = new ItemStruct(prefabPool[prefabName], deserializedItem);

            sceneItemsList.Add(item);
        }
    }
Exemplo n.º 10
0
    public void HitMe(ItemStruct hitObj)
    {
        if (hitObj.Name.Contains("Hoe"))
        {
            tileData.tilled = 1;



            TillTile();
        }
        else if (hitObj.Name.Contains("WoodAxe"))
        {
            CheckDestroyCrop();
        }
        else if (hitObj.Name.Contains("PickAxe"))
        {
            CheckDestroyCrop();
        }
        else if (hitObj.Name.Contains("WateringCan"))
        {
            tileData.watered = 1;
            WaterTile();
        }
        else if (hitObj.Name.Contains("Seed"))
        {
            if (tileData.tilled == 1 && tileData.rockID == "-1" && tileData.cropID == "-1" && tileData.type == "farm" && tileData.treeID == "-1" && tileData.collectableID == "-1")
            {
                print(((ItemComponent)hitObj).Name);
                ((ItemComponent)hitObj).SubtractOne();
                PlantCrop(hitObj.Name);
            }
        }
    }
Exemplo n.º 11
0
    // Start is called before the first frame update
    void Start()
    {
        PlayerPrefs.DeleteKey("" + GetInstanceID());

        for (int i = 0; i < 8; i++)
        {
            print(HotBarButtons[i].GetComponentInChildren <Text>().text);
            Quantities[i] = HotBarButtons[i].GetComponentInChildren <Text>();
        }
        if (PlayerPrefs.GetString("" + GetInstanceID(), "none") != "none") // if we have a save
        {
            hotBarData = JsonUtility.FromJson <HotBarData>(PlayerPrefs.GetString("" + GetInstanceID()));
            print("top route");
            ReadHotBarData();
        }
        else
        {
            //load in starting mats;
            SpawnStartingItems();

            //    PlayerPrefs.SetString("" + GetInstanceID(), JsonUtility.ToJson(hotBarData));
        }

        equiptItem = equiptItems[0].GetComponent <ItemStruct>();

        ActivateItem(0);
    }
    private void createSceneItemsList()
    {
        // <Item prefab="Chair" x="1" y="10" rot="90" />
        foreach (DeserializedLevels.Item deserializedItem in getCurLevel().items)
        {
            // caching prefabString i.e. "phone"
            string prefabString = deserializedItem.prefab;

            // if the prefab in the item XmlNode has not been loaded then add it to the prefabsDict dictionary,
            if (!prefabPool.ContainsKey(prefabString))
            {
                // load prefab
                GameObject prefabObject = Resources.Load(prefabsFolder + prefabString, typeof(GameObject)) as GameObject;

                // if unsuccesful, error message and jump to next in the foreach loop
                if (prefabObject == null)
                {
                    Debug.LogError("Prefab \"" + prefabString + "\" does not exists.");
                    continue;
                }

                // otherwise add to dictionary
                prefabPool.Add(prefabString, prefabObject);
            }

            ItemStruct item = new ItemStruct(prefabPool[prefabString], deserializedItem);

            sceneItemsList.Add(item);
        }
    }
Exemplo n.º 13
0
 /// <summary>
 /// 控制层:减少某个道具的数量
 /// </summary>
 /// <param name="item"></param>
 /// <param name="number"></param>
 /// <returns>是否可减</returns>
 public bool SubItemCount(ItemStruct item, int number)
 {
     if (number > 0)
     {
         return(Mod_PlayerPackageDataProxy.GetInstance().SubItemCount(item, number));
     }
     return(false);
 }
Exemplo n.º 14
0
 // Use this for initialization
 void Start()
 {
     for (int i=0; i<size; i++) {
         itemList[i]=new ItemStruct();
         itemList[i].itemName=itemName[i];
         itemList[i].image=sp[i];
         itemList[i].description=description[i];
     }
 }
Exemplo n.º 15
0
        public void Add(K key, V value)
        {
            var item = new ItemStruct
            {
                key   = key,
                value = value
            };

            _ListItens.Add(item);
        }
Exemplo n.º 16
0
        private void item_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item       = (ToolStripMenuItem)sender;
            ItemStruct        itemStruct = getItemStruct(item.Text);

            if (itemStruct.handler != null)
            {
                itemStruct.handler(itemStruct.name, itemStruct.userData);
            }
        }
Exemplo n.º 17
0
 public void addItem(ItemStruct item)
 {
     if (!isNameContainsInMenu(item.name))
     {
         ToolStripMenuItem newItem = new ToolStripMenuItem(item.name);
         newItem.Click += item_Click;
         itemStructs.Add(item);
         Items.Add(newItem);
     }
 }
Exemplo n.º 18
0
    public InventoryComponent(ItemStruct[] inData)
    {
        ItemStruct cachedItem = new ItemStruct();

        cachedItem.Empty();

        item1 = inData.Length > 0 ? inData[0] : cachedItem;
        item2 = inData.Length > 1 ? inData[1] : cachedItem;
        item3 = inData.Length > 2 ? inData[2] : cachedItem;
    }
Exemplo n.º 19
0
 public override void initData(bool isBulkMental)
 {
     playerTr = PlayerCtrl.instance.transform;
     itemData = new ItemStruct();
     // 인핸스 아이템의 정보를 불러온다.
     if (isBulkMental)
         ItemMgr.instance.GetItem().ParseByID(itemData, 2); // 엑셀 시트 ID값 참조
     else
         ItemMgr.instance.GetItem().ParseByID(itemData, 3);
 }
Exemplo n.º 20
0
    public bool AddItem(ItemStruct newItem, Vector3 location)
    {
        bool itemInserted = false;

        //fist look if we already have an entry of the same type
        for (int index = 0; index < MAX_ITEMS; ++index)
        {
            if (itemArray[index] != null)
            {
                if (itemArray[index].itemType == newItem.itemType)
                {
                    Instantiate(newItem.onPickupParticle, location, Quaternion.identity);
                    itemArray[index].numberOfItemsInStack++;
                    itemInserted = true;
                    break;
                }
            }
        }

        //if we can insert the item as a new index
        if (numberOfItems < MAX_ITEMS && itemInserted == false)
        {
            for (int index = 0; index < MAX_ITEMS; ++index)
            {
                if (itemArray[index] == null)
                {
                    itemArray[index] = newItem;
                    itemInserted     = true;
                    numberOfItems++;

                    break;
                }
            }

            if (newItem.soundOnPickup != null)
            {
                AudioSource.PlayClipAtPoint(newItem.soundOnPickup, location);
            }

            if (newItem.onPickupParticle != null)
            {
                Instantiate(newItem.onPickupParticle, location, Quaternion.identity);
            }
        }
        else
        {
            AudioSource.PlayClipAtPoint(soundUnableToPickup, location);
        }

        SortArray();

        GetAllButtons();

        return(itemInserted);
    }
Exemplo n.º 21
0
	private void Update()
	{
        if (Input.GetKeyDown(KeyCode.W))
        {
            CalculateResult_player(itemNum);
            CalculateResult_enemy();
        }
        // for debugging
        if (Input.GetKeyDown(KeyCode.H))
        {
            ItemStruct item = new ItemStruct();
            item.namae = "hammer";
            item.blunt = true;
            item.dmg = 5;
            item.durability = 3;
            itemsPlayersUsing.Add(item);
        }

        if (Input.GetKeyDown(KeyCode.S))
		{
            startBattle = true;
            UpdatePlayer();
            GetEnemy();
		}

        if (player.hp > 0 && enemy.hp > 0 && startBattle)
		{
            //if (itemsPlayersUsing.Count > 0) // this if check is only for debugging
			{
                CalculateResult_player(itemNum);
                CalculateResult_enemy();
            }
		}
        else if (player.hp<=0 || enemy.hp <= 0)
		{
            startBattle = false;
        }
        
        if (Input.GetMouseButtonDown(0))
		{
            //if (enemy.hp > 0 && player.hp > 0)
			{
                ShowText();
            }
            if (textNum < actions.Count - 1)
			{
                textNum++;
            }
			else
			{
                print("over");
			}
		}
    }
Exemplo n.º 22
0
    public Mech()
    {
        equippedTorsoItems = new ItemStruct();
        equippedHeadItems  = new ItemStruct();
        equippedLegItems   = new ItemStruct();

        equippedLeftArmWeapons       = new ItemStruct();
        equippedRightArmWeapons      = new ItemStruct();
        equippedLeftShoulderWeapons  = new ItemStruct();
        equippedRightShoulderWeapons = new ItemStruct();
    }
Exemplo n.º 23
0
 // Add item to eq
 public void AddItem(ItemStruct item)
 {
     // check if item is already set in dictionary
     if (items.ContainsKey(item))
     {
         items[item] += 1;                          // add one to quantity of item
     }
     else
     {
         items.Add(item, 1);  // create first item in dictionary with quantity of 1
     }
 }
Exemplo n.º 24
0
    // Toggle image informing if item is currently equipped
    // If state == 0, then hide image
    // If state == 1, then show image
    public void ToggleEquip(Item item, bool state)
    {
        int id = findItemStruct(item);

        if (id == -1)
        {
            return;
        }
        ItemStruct its = items[id];

        its.itemUI.ToggleEquip(state);
    }
Exemplo n.º 25
0
    public void ChangeItemQuantity(Item item, int newQuantity)
    {
        int id = findItemStruct(item);

        if (id == -1)
        {
            return;
        }
        ItemStruct its = items[id];

        its.item.quantity = newQuantity;
        its.itemUI.ChangeItemQuantity(newQuantity.ToString());
    }
Exemplo n.º 26
0
    public string SerializeInventory(List <Equipable> items = null)
    {
        string serializedString = "";

        foreach (Item i in items)
        {
            ItemStruct item = new ItemStruct();
            item.id           = i.UniqueID;
            item.stack        = i.Stacked;
            serializedString += JsonUtility.ToJson(item) + "#"; //delimiting each item by #
        }
        return(serializedString);
    }
Exemplo n.º 27
0
        /// <summary>
        /// 创建一个对象
        /// 注意只能使用这种方法创建
        /// </summary>
        /// <returns></returns>
        public ItemStruct CreateItem()
        {
            ItemStruct create = new ItemStruct();

            create.ChangedHandle += Create_ChangedHandle;
            Panel ItemPanel = new Panel();

            ItemPanel.Size = new Size(1, 1);
            ItemPanel.Tag  = create;
            FlowLayoutPanel_Release_Other.Controls.Add(ItemPanel);
            items.Add(create);
            return(create);
        }
Exemplo n.º 28
0
    public Mech(MechBase mechBase)
    {
        mechBaseRef = mechBase;

        equippedTorsoItems = new ItemStruct(mechBaseRef.torsoSlots);
        equippedHeadItems  = new ItemStruct(mechBaseRef.headSlots);
        equippedLegItems   = new ItemStruct(mechBaseRef.legSlots);

        equippedLeftArmWeapons       = new ItemStruct(mechBaseRef.leftArmSlotsU, mechBaseRef.leftArmSlotsP, mechBaseRef.leftArmSlotsS, mechBaseRef.leftArmSlotsT);
        equippedRightArmWeapons      = new ItemStruct(mechBaseRef.rightArmSlotsU, mechBaseRef.rightArmSlotsP, mechBaseRef.rightArmSlotsS, mechBaseRef.rightArmSlotsT);
        equippedLeftShoulderWeapons  = new ItemStruct(mechBaseRef.leftShoulderSlotsU, mechBaseRef.leftShoulderSlotsP, mechBaseRef.leftShoulderSlotsS, mechBaseRef.leftShoulderSlotsT);
        equippedRightShoulderWeapons = new ItemStruct(mechBaseRef.rightShoulderSlotsU, mechBaseRef.rightShoulderSlotsP, mechBaseRef.rightShoulderSlotsS, mechBaseRef.rightShoulderSlotsT);
    }
Exemplo n.º 29
0
        public void AddRange(K[] key, V[] value)
        {
            for (int i = 0; i < key.Length; i++)
            {
                var item = new ItemStruct
                {
                    key   = (K)key.GetValue(i),
                    value = (V)value.GetValue(i)
                };

                _ListItens.Add(item);
            }
        }
Exemplo n.º 30
0
    public bool GetItemFromIndex(int index, ref ItemStruct itemRef)
    {
        if (itemArray [index] != null)
        {
            itemRef = itemArray [index];

            return(true);
        }

        else
        {
            return(false);
        }
    }
Exemplo n.º 31
0
    // 이름으로 검색, 반환
    public void ParseByName(ItemStruct data, string name)
    {
        for (int row = 2; row < rowCnt; row++)
        {
            if (!Convert.ToString(stringList[colCnt * row +1 ]).Equals(name))
                continue;

            data.SetData(
                Convert.ToInt32(stringList[colCnt * row]),
                Convert.ToString(stringList[colCnt * row + 1]),
                Convert.ToInt32(stringList[colCnt * row + 2]),
                Convert.ToInt32(stringList[colCnt * row + 3]));

            break;
        }
    }
Exemplo n.º 32
0
        public static ItemStruct CreateItemFromLoot(LootItemStruct loot)
        {
            var itemData = ItemDictionary.GetItem(loot.ItemId);

            if (itemData.parameter != null)
            {
                CalcParameter(ref itemData.parameter, loot.Reality);
            }
            ItemStruct item = new ItemStruct()
            {
                Reality = loot.Reality,
                Amount  = loot.Amount,
                Data    = itemData
            };

            return(item);
        }
Exemplo n.º 33
0
        /// <summary>
        /// 保存函数
        /// </summary>
        public void SaveData()
        {
            if (this.Tag == null || skillAnalysisData == null)
            {
                return;
            }
            string id = (string)this.Tag;

            Panel[] panels = FlowLayoutPanel_Release_Other.Controls.OfType <Panel>().ToArray();
            foreach (Panel panel in panels)
            {
                ItemStruct itemStruct = panel.Tag as ItemStruct;
                if (itemStruct == null || string.IsNullOrEmpty(itemStruct.Tag))
                {
                    continue;
                }
                //判断条件
                Control control = panel.Controls.Find("ItemControl", false).FirstOrDefault();
                if (control != null)
                {
                    //是否是数组
                    if (itemStruct.IsArray)
                    {
                        IChildControlType iChildControlType = control as IChildControlType;
                        if (iChildControlType != null)
                        {
                            skillAnalysisData.SetValues(id, itemStruct.Tag, iChildControlType.TextValues);
                        }
                    }
                    else
                    {
                        ITextValue iTextValue = control as ITextValue;
                        if (iTextValue != null)
                        {
                            skillAnalysisData.SetValue(id, itemStruct.Tag, iTextValue.TextValue);
                        }
                        else
                        {
                            skillAnalysisData.SetValue(id, itemStruct.Tag, control.Text);
                        }
                    }
                }
            }
        }
Exemplo n.º 34
0
    public void ActivateItem(int index)
    {
        if (equiptItems[oldIndex] != null)
        {
            equiptItems[oldIndex].gameObject.SetActive(false);
        }
        if (equiptItems[index] != null)
        {
            equiptItems[index].gameObject.SetActive(true); // set the object true


            equiptItem = equiptItems[index].GetComponent <ItemStruct>();
        }
        else
        {
            equiptItem = null;
        }

        oldIndex = index;
    }
Exemplo n.º 35
0
    public override void BuildClean()
    {
        //base.BuildClean();
        foreach (Transform child in upgradeContent.transform)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in primaryContent.transform)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in SecondaryContent.transform)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in tertiaryContent.transform)
        {
            Destroy(child.gameObject);
        }

        if (HangarManager._instance.currentylSelectedSectionIndex == -1)
        {
            return;
        }

        subsectionItems = GameManager._instance.availableMechs[hangarManager.currentlySelectedMechIndex].GetSectionItemsByIndex(hangarManager.currentylSelectedSectionIndex);

        BuildFromStruct();

        /* Enable the subsection slot icons */
        for (int index = 0; index < subsectionSlotIcon.Count; index++)
        {
            subsectionSlotIcon[index].SetActive(false);

            if (HangarManager._instance.currentylSelectedSectionIndex == -1)
            {
                continue;
            }
        }
    }
Exemplo n.º 36
0
 public void addItem(ItemStruct itemStruct)
 {
     haveItemList.Add (itemStruct);
     Debug.Log (haveItemList [0].description);
 }
 private TreeNode GenerateNodes( XElement element, TreeNode mnu )
 {
   TreeNode menuNodes = null;
   var xFolder = from xItem in element.Elements()
                      select xItem;
   foreach ( XElement xItem in xFolder )
   {
     ItemStruct tmpItem = new ItemStruct();
     switch (xItem.Name.ToString())
     {
       case "folder":
         tmpItem.itmType = ItemType.ITM_Folder;
         tmpItem.menuAttr = new Dictionary<string, string>();
         foreach ( var xAttr in xItem.Attributes() )
         {
           tmpItem.menuAttr.Add( xAttr.Name.ToString(), xAttr.Value.ToString() );
         }
         menuNodes = new TreeNode( xItem.Attribute( "short_name" ).Value );
         menuItemAttrs.Add( menuNodes, tmpItem );
         if ( null == mnu )
           mnu = GenerateNodes( xItem, menuNodes );
         else
           mnu.Nodes.Add( GenerateNodes( xItem, menuNodes ) );
         break;
       case "application":
         menuNodes = mnu.Nodes.Add( xItem.Attribute( "uid" ).Value );
         tmpItem.itmType = ItemType.ITM_Folder;
         tmpItem.menuAttr = new Dictionary<string, string>();
         foreach ( var xAttr in xItem.Attributes() )
         {
           tmpItem.menuAttr.Add( xAttr.Name.ToString(), xAttr.Value.ToString() );
         }
         menuItemAttrs.Add(menuNodes, tmpItem);
         break;
       case "mmc":
         continue;
     }
   }
   return mnu;
 }
Exemplo n.º 38
0
 private int ItemCompare(ItemStruct x, ItemStruct y)
 {
     int num = x.Location.Y + x.Size.Height;
     return num.CompareTo((int) (y.Location.Y + y.Size.Height));
 }
Exemplo n.º 39
0
 private List<ItemStruct> GetNodeItems(XmlNodeList list)
 {
     List<ItemStruct> list2 = new List<ItemStruct>();
     int num = 0;
     foreach (XmlNode node in list)
     {
         ItemStruct item = new ItemStruct {
             Location = getLocationAttribute(node),
             Size = getSizeAttribute(node),
             NodeIndex = num
         };
         list2.Add(item);
         num++;
     }
     list2.Sort(new Comparison<ItemStruct>(this.ItemCompare));
     return list2;
 }
Exemplo n.º 40
0
    private Transform thisTr;               // 위치 확인

    void Start()
    {
        itemData = new ItemStruct();
        ItemMgr.instance.GetItem().ParseByID(itemData, itemID); // 엑셀 시트 ID값 참조
    }
Exemplo n.º 41
0
    public void RemoveItem(int index)
    {
        CountUnusedSlots();
        ItemInfoContainer item = this._itemInfoList[index]._itemInfo;

        if (item._itemRole == ItemRole.WEAPON)
        {
            if (this._itemWeaponCount > 3)
            {
                IncreaseInventorySizeBy(6);
            }
            if (this._itemWeaponCount > 0) this._itemWeaponCount--;
        }
        else if (item._itemRole == ItemRole.ARMOR)
        {
            if (this._itemArmorCount > 3)
            {
                IncreaseInventorySizeBy(4);
            }
            if (this._itemArmorCount > 0) this._itemArmorCount--;
        }
        else if (item._itemRole == ItemRole.RESOURCE)
        {
            //take out of inventory
            //put into resource object inactive pool
            GameObject obj = this._itemContainerObject.GetComponent<ItemContainer>().GetItem(item._uniqueItemID);
            int[] stackIDs = obj.GetComponent<ResourceItem>()._resrcStack.ToArray();
            for (int i = 0; i < stackIDs.Length; i++)
            {
                if (stackIDs[i] != item._uniqueItemID) //don't want to remove itself since removed after this loop
                {
                    this._itemContainerObject.GetComponent<ItemContainer>().RemoveItem(stackIDs[i]).transform.SetParent(obj.transform.GetChild(0));
                }
            }
        }
        //child destroyed in InventoryRemove.OnDrop
        //instantiate into world
        InstantiateItem(item._uniqueItemID);
        //fill up _itemInfoList with nulls
        this._itemContainerObject.GetComponent<ItemContainer>().RemoveItem(item._uniqueItemID);
        _itemInfoList[index] = new ItemStruct(null, true);
    }