Beispiel #1
0
        public void UpdateEquipmentSlot(int uniqueId, EquipmentSlot eqSlot, Itemtype itemType)
        {
            ItemInventoryInstance invInstance = null;

            switch (itemType)
            {
            case Itemtype.Weapon:
                invInstance = SessionManager.Instance.GetWeaponItem(uniqueId);
                break;

            case Itemtype.Spell:
                break;

            case Itemtype.Consumable:
                invInstance = SessionManager.Instance.GetConsumableItem(uniqueId);
                break;

            case Itemtype.Equipment:
                break;

            default:
                break;
            }

            if (invInstance == null)
            {
                return;
            }

            Item item = ResourcesManager.Instance.GetItem(invInstance.itemId, itemType);

            eqSlot.iconBase.icon.sprite  = item.itemIcon;
            eqSlot.iconBase.icon.enabled = true;
            eqSlot.iconBase.id           = invInstance.uniqueId;
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Itemtype itemtype = db.Itemtypes.Find(id);

            db.Itemtypes.Remove(itemtype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        private void Drop(Itemtype _itmeKind, Vector2 _dropPos)
        {
            //테스트
            string path = "Prefabs/Item/" + _itmeKind.ToString();
            var    obj  = Instantiate(Resources.Load(path) as GameObject);

            obj.transform.position = _dropPos;
            obj.transform.SetParent(manager.transform);
        }
Beispiel #4
0
 public Item(int _itemID, string _itemName, string itemDes, Itemtype _itemtype, int _itemcount = 1)
 {
     itemID          = _itemID;
     itemName        = _itemName;
     itemDescription = itemDes;
     itemType        = _itemtype;
     itemCount       = _itemcount;
     itemIcon        = Resources.Load("itemIcon/" + _itemID.ToString(), typeof(Sprite)) as Sprite;
 }
 public ActionResult Edit([Bind(Include = "ItemTypeID,ItemType1")] Itemtype itemtype)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemtype).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(itemtype));
 }
 public Item()
 {
     itemId = 0;
     itemName = "Empty";
     itemPrice = 0;
     itemType = Item.Itemtype.Empty;
     itemIconType = Item.ItemIconType.Empty;
     itemStats = new Dictionary<string, int>();
     itemTextStats = "";
 }
 public Item(int id, string name, int price, Itemtype type, ItemIconType iconType, Dictionary<string, int> stats)
 {
     itemId = id;
     itemName = name;
     itemPrice = price;
     itemType = type;
     itemIconType = iconType;
     itemStats = stats;
     itemTextStats = GetItemStatsText();
 }
        public ActionResult Create([Bind(Include = "ItemTypeID,ItemType1")] Itemtype itemtype)
        {
            if (ModelState.IsValid)
            {
                db.Itemtypes.Add(itemtype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(itemtype));
        }
Beispiel #9
0
        /// <summary>
        ///Load items to inventory UI in Left Equipment Panel
        /// </summary>
        /// <param name="itemType">Item Type</param>
        public void LoadCurrentItems(Itemtype itemType)
        {
            //List<Item> itemList = session.GetItemsAsList(item);
            List <ItemInventoryInstance> itemList = session.GetItemInstanceList(itemType);

            if (itemList == null || itemList.Count == 0)
            {
                return;
            }

            GameObject prefabSlot = equipment_Left.leftInventory.inventorySlotTemplate;
            Transform  parent     = equipment_Left.leftInventory.slotGrid.transform;

            int diff  = iconSlotsCreated.Count - itemList.Count;
            int extra = (diff > 0) ? diff : 0;

            maxInv_Index        = itemList.Count;
            currentCreatedItems = new List <IconBase>();

            //By default, set currently selected item the first one in the inventory list
            currentInv_Index = 0;

            for (int i = 0; i < itemList.Count + extra; i++)
            {
                if (i > itemList.Count - 1)
                {
                    iconSlotsCreated[i].gameObject.SetActive(false);
                    continue;
                }

                Item item = ResourcesManager.Instance.GetItem(itemList[i].itemId, itemType);

                IconBase icon = null;
                if (iconSlotsCreated.Count - 1 < i)
                {
                    GameObject go = Instantiate(prefabSlot) as GameObject;
                    go.transform.SetParent(parent);
                    go.SetActive(true);
                    icon = go.GetComponent <IconBase>();
                    iconSlotsCreated.Add(icon);
                }
                else
                {
                    icon = iconSlotsCreated[i];
                }

                currentCreatedItems.Add(icon);
                icon.gameObject.SetActive(true);
                icon.icon.enabled = true;
                icon.icon.sprite  = item.itemIcon;
                icon.id           = itemList[i].uniqueId;
            }
        }
        public List <Item> GetAllItemsFromList(List <string> listOfItems, Itemtype itemType)
        {
            List <Item> tmp = new List <Item>();

            for (int i = 0; i < listOfItems.Count; i++)
            {
                Item item = GetItem(listOfItems[i], itemType);
                tmp.Add(item);
            }

            return(tmp);
        }
        public Item GetItem(string id, Itemtype itemType)
        {
            ItemsScriptableObject obj = Resources.Load(StaticStrings.ItemsScriptableObject_FileName) as ItemsScriptableObject;

            if (obj == null)
            {
                Debug.Log("Couldn't find the file: " + StaticStrings.ItemsScriptableObject_FileName + " under Resources!");
            }

            Dictionary <string, int> dict = null;
            List <Item> listItem          = null;

            switch (itemType)
            {
            case Itemtype.Weapon:
                dict     = item_Weapons;
                listItem = obj.weapon_Items;
                break;

            case Itemtype.Spell:
                dict     = item_Spells;
                listItem = obj.spell_Items;
                break;

            case Itemtype.Consumable:
                dict     = item_Consumables;
                listItem = obj.consumable_Items;
                break;

            case Itemtype.Equipment:
            default:
                return(null);
            }

            if (dict == null)
            {
                return(null);
            }
            if (listItem == null)
            {
                return(null);
            }

            int index = GetIndexFromString(dict, id);

            if (index == -1)
            {
                return(null);
            }

            return(listItem[index]);
        }
Beispiel #12
0
 public Item(int _itemID, string _itemName, string itemDes, Itemtype _itemtype, int _itemDu, int _sellPrice, int _buyPrice, int _itemcount = 1, int _hunger = 0)
 {
     itemID          = _itemID;
     itemName        = _itemName;
     itemDescription = itemDes;
     itemType        = _itemtype;
     itemCount       = _itemcount;
     itemDurable     = _itemDu;
     sellPrice       = _sellPrice;
     buyPrice        = _buyPrice;
     hunger          = _hunger;
     itemIcon        = Resources.Load("itemIcon/" + _itemID.ToString(), typeof(Sprite)) as Sprite;
 }
        // GET: Itemtypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Itemtype itemtype = db.Itemtypes.Find(id);

            if (itemtype == null)
            {
                return(HttpNotFound());
            }
            return(View(itemtype));
        }
Beispiel #14
0
    public Item(string name, int ID, string desc, int quantity, int power, int weight, string requirement1, string requirement2, Itemtype type)
    {
        // var convertType = (Itemtype)Enum.Parse(typeof(Itemtype), type);

        itemName         = name;
        itemID           = ID;
        itemDesc         = desc;
        itemIcon         = Resources.Load <Texture2D>("Item Icons/" + name);
        itemQuantity     = quantity;
        itemPower        = power;
        itemWeight       = weight;
        itemRequirement1 = requirement1;
        itemRequirement2 = requirement2;
        itemType         = type;//convertType;
    }
        public List <ItemInventoryInstance> GetItemInstanceList(Itemtype itemtype)
        {
            switch (itemtype)
            {
            case Itemtype.Weapon:
                return(_weapon_items);

            case Itemtype.Spell:
            case Itemtype.Consumable:
                return(_consumable_items);

            case Itemtype.Equipment:
            default:
                return(null);
            }
        }
        public List <Item> GetItemsAsList(Itemtype type)
        {
            switch (type)
            {
            case Itemtype.Weapon:
                return(ResourcesManager.Instance.GetAllItemsFromList(weaponItemList, Itemtype.Weapon));

            case Itemtype.Spell:
                return(ResourcesManager.Instance.GetAllItemsFromList(spellItemList, Itemtype.Spell));

            case Itemtype.Consumable:
                return(ResourcesManager.Instance.GetAllItemsFromList(consumableItemList, Itemtype.Consumable));

            case Itemtype.Equipment:
                break;

            default:
                return(null);
            }

            return(null);
        }
Beispiel #17
0
        void UpdateItemSlotInfo(ResourcesManager resManager, IconBase iconBase, Itemtype itemtype)
        {
            ItemInventoryInstance invInstance = null;

            if (!centerOverlayIsOpen)
            {
                centerOverlay.SetActive(false);
            }

            centerOverlay.SetActive(false);

            switch (itemtype)
            {
            case Itemtype.Spell:
                break;

            case Itemtype.Consumable:
                invInstance = session.GetConsumableItem(iconBase.id);
                centerOverlay.SetActive(true);
                break;

            case Itemtype.Equipment:
                //invInstance = session.GetArmorItem(iconBase.id);
                centerOverlay.SetActive(true);
                break;

            default:
                break;
            }

            string itemID = invInstance.itemId;
            Item   item   = resManager.GetItem(itemID, itemtype);

            UpdateCenterOverlay(item);
            equipment_Left.currentItem.text = item.name_item;
        }
        public void AddItem(string itemID, Itemtype type)
        {
            switch (type)
            {
            case Itemtype.Weapon:
                weaponItemList.Add(itemID);
                ItemInventoryInstance invItem = new ItemInventoryInstance();
                invItem.itemId   = itemID;
                invItem.uniqueId = max_Weapon_Item_Index;
                max_Weapon_Item_Index++;
                _weapon_items.Add(invItem);
                break;

            case Itemtype.Spell:
                break;

            case Itemtype.Consumable:
                ItemInventoryInstance consumableItem = new ItemInventoryInstance();
                consumableItem.itemId   = itemID;
                consumableItem.uniqueId = max_Consumable_Item_Index;
                max_Consumable_Item_Index++;
                _consumable_items.Add(consumableItem);
                break;

            case Itemtype.Equipment:
                AddArmorItem(itemID);
                break;

            default:
                break;
            }

            Item item = resourcesManager.GetItem(itemID, type);

            UIManager.Instance.AddAnnounceCard(item);
        }
Beispiel #19
0
        void HandleSlotInput(InputUI inputUI)
        {
            if (currentEqSlot == null)
            {
                return;
            }

            #region X Input --> Switching
            if (inputUI.x_input)
            {
                isSwitching = !isSwitching;
                Debug.Log("Changed is switching to : " + isSwitching);

                if (isSwitching)
                {
                    Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType);
                    LoadCurrentItems(type);
                }
                else
                {
                    Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType);
                    if (type == Itemtype.Weapon)
                    {
                        int targetIndex = currentEqSlot.itemPosition;

                        //If slot index is greater than 2, it is left hand weapon,
                        //since first 3 slots belong to right hand weapons
                        bool isLeft = (currentEqSlot.itemPosition > 2) ? true : false;
                        if (isLeft)
                        {
                            targetIndex -= 3;
                            invManager.leftHandWeapons[targetIndex] = currentInvIcon.id;
                            ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.leftHandWeapons[targetIndex]);
                            if (invInstance.slot != null)
                            {
                                equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon);
                                ClearOnIndex(invInstance.equip_Index);
                            }
                        }
                        else
                        {
                            invManager.rightHandWeapons[targetIndex] = currentInvIcon.id;
                            ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.rightHandWeapons[targetIndex]);
                            if (invInstance.slot != null)
                            {
                                equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon);
                                ClearOnIndex(invInstance.equip_Index);
                            }
                        }
                    }
                    else
                    {
                        ItemInventoryInstance invInstance = session.GetConsumableItem(invManager.consumableItems[currentEqSlot.itemPosition]);
                        if (invInstance.slot != null)
                        {
                            equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Consumable);
                            //Set as empty item
                            invManager.consumableItems[invInstance.equip_Index] = -1;
                        }

                        invManager.consumableItems[currentEqSlot.itemPosition] = currentInvIcon.id;
                    }

                    LoadEquipment(invManager, true);
                }

                ChangeToSwitching();
            }

            #endregion

            //b --> back button
            if (inputUI.b_input)
            {
                if (isSwitching)
                {
                    isSwitching = false;
                    ChangeToSwitching();
                }
                else
                {
                    isMenu = false;
                    CloseUI();
                }
            }

            #region Y Input
            if (inputUI.y_input)
            {
                if (isSwitching)
                {
                    centerOverlayIsOpen = !centerOverlayIsOpen;
                    centerOverlay.SetActive(centerOverlayIsOpen);
                }
                else
                {
                    Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType);
                    if (type == Itemtype.Weapon)
                    {
                        int  targetIndex = currentEqSlot.itemPosition;
                        bool isLeft      = (currentEqSlot.itemPosition > 2) ? true : false;
                        if (isLeft)
                        {
                            targetIndex -= 3;
                            invManager.leftHandWeapons[targetIndex] = -1;

                            ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.leftHandWeapons[targetIndex]);
                            if (invInstance.slot != null)
                            {
                                equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon);
                            }
                        }
                        else
                        {
                            invManager.rightHandWeapons[targetIndex] = -1;

                            ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.rightHandWeapons[targetIndex]);
                            if (invInstance.slot != null)
                            {
                                equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon);
                            }
                        }
                    }
                    else if (type == Itemtype.Consumable)
                    {
                        int targetIndex = currentEqSlot.itemPosition;
                        if (targetIndex < invManager.consumableItems.Count)
                        {
                            invManager.consumableItems[currentEqSlot.itemPosition] = -1;

                            ItemInventoryInstance invInstance = session.GetConsumableItem(invManager.consumableItems[targetIndex]);
                            if (invInstance.slot != null)
                            {
                                equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Consumable);
                            }
                        }
                    }

                    LoadEquipment(invManager, true);
                }
            }

            #endregion
        }
Beispiel #20
0
 public void ClearEquipmentSlot(EquipmentSlot eqSlot, Itemtype itemType)
 {
     eqSlot.iconBase.icon.enabled = false;
     eqSlot.iconBase.id           = -1;
 }