public void UpdateStore(InventoryItemInfo info)
        {
            Inventory inventory = PlayerManager.Instance.Player.Inventory;

            coinText.text = string.Format("錢幣數量: 金幣{0} 銀幣{1} 銅幣{2}", inventory.ItemCount(6), inventory.ItemCount(7), inventory.ItemCount(8));
            Initial(store);
        }
Esempio n. 2
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
    private void Setup(InventoryItemInfo templateArg)
    {
        itemId          = templateArg.itemId;
        itemName        = templateArg.itemName;
        itemDescription = templateArg.itemDescription;

        itemPrefixName = templateArg.itemPrefixName;

        itemRarity = new RarityTier(templateArg.itemRarity);
    }
Esempio n. 4
0
    private void Setup(WeaponData templateArg)
    {
        itemInfo = new InventoryItemInfo(templateArg.itemInfo);

        weaponType = templateArg.weaponType;

        fireMethod = templateArg.fireMethod;

        weaponStats = new WeaponStats(templateArg.weaponStats);

        // setup weapon stats based on weapon rarity
        weaponStats.SetupRarityModifiers(itemInfo.itemRarity);
    }
Esempio n. 5
0
    private void Setup()
    {
        itemInfo = new InventoryItemInfo();

        weaponType = WeaponType.None;

        fireMethod = ProjectileFireMethodType.None;

        weaponStats = new WeaponStats();

        // setup weapon stats based on weapon rarity
        weaponStats.SetupRarityModifiers(itemInfo.itemRarity);
    }
Esempio n. 6
0
        public bool AddItem(Item item, int count)
        {
            InventoryItemInfo info = FindInventoryItemInfo(item.ItemID);

            if (info == null)
            {
                info = new InventoryItemInfo(item.ItemID, count);
                itemInfoDictionary.Add(info.ItemID, info);
            }
            else
            {
                info.Count += count;
            }
            onItemChange?.Invoke(info);
            return(true);
        }
Esempio n. 7
0
    public void SetItem(InventoryItemInfo refItem)
    {
        if (iType != refItem.iType)
        {
            return;
        }

        if (refItemInfo != null)
        {
            refItemInfo.SetEquipped(false);
        }

        refItemInfo            = refItem;
        equippedItemImg.sprite = refItemInfo.itemImg.sprite;
        equippedItemImg.color  = new Color(1, 1, 1, 1);
        itemID = refItemInfo.itemNum;
        refItemInfo.SetEquipped(true);
        LobbyUIManager.Instance.SetEquippedItem((int)equipType, itemID);
    }
Esempio n. 8
0
 public bool RemoveItem(int itemID, int count)
 {
     if (ContainsItem(itemID) && ItemCount(itemID) >= count)
     {
         InventoryItemInfo info = FindInventoryItemInfo(itemID);
         info.Count -= count;
         if (info.Count == 0)
         {
             if (itemInfoDictionary.ContainsKey(info.ItemID))
             {
                 itemInfoDictionary.Remove(info.ItemID);
             }
         }
         onItemChange?.Invoke(info);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 9
0
    public void Init()
    {
        inventoryEachTopPanels = new InventoryEachTopPanel[nInventoryTotalCount];
        togglePanel            = new GameObject[nInventoryTotalCount];
        toggle = new Toggle[nInventoryTotalCount];

        //Debug.Log(GameManager.Instance.GetPlayer().LIST_ITEM.Count);

        for (int i = 0, j = 5; i < nInventoryTotalCount; i++, j--)
        {
            //각각의 인벤토리 종류 탭의 패널
            inventoryEachTopPanels[i] = this.gameObject.transform.GetChild(j).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).gameObject.AddComponent <InventoryEachTopPanel>();
            inventoryEachTopPanels[i] = this.gameObject.transform.GetChild(j).transform.GetChild(0).transform.GetChild(0).transform.GetChild(0).GetComponent <InventoryEachTopPanel>();
            //해당 패널의 리스트 컨텐츠 초기화
            inventoryEachTopPanels[i].Init(i);
            //토글을 하기위한 할당
            togglePanel[i] = inventoryEachTopPanels[i].ContentsPanels;
            toggle[i]      = this.gameObject.transform.GetChild(j).gameObject.GetComponent <Toggle>();
        }

        inventoryItemInfo       = this.gameObject.transform.GetChild(6).gameObject.AddComponent <InventoryItemInfo>();
        inventoryItemInfo       = this.gameObject.transform.GetChild(6).GetComponent <InventoryItemInfo>();
        inventoryItemSellPanel  = this.gameObject.transform.GetChild(8).gameObject.AddComponent <InventoryItemSellPanel>();
        inventoryItemSellPanel  = this.gameObject.transform.GetChild(8).GetComponent <InventoryItemSellPanel>();
        inventoryDecomposePanel = this.gameObject.transform.GetChild(9).gameObject.AddComponent <InventoryDecomposePanel>();
        inventoryDecomposePanel = this.gameObject.transform.GetChild(9).GetComponent <InventoryDecomposePanel>();

        inventoryItemSellPanel.Init();
        inventoryDecomposePanel.Init();

        inventoryItemInfo.itemSellPanel      = inventoryItemSellPanel;
        inventoryItemInfo.itemDecomposePanel = inventoryDecomposePanel;

        inventoryItemInfo.Init();
        InitToggle();
    }
Esempio n. 10
0
        public void Initial(InventoryItemInfo info)
        {
            Item          item          = ItemFactory.Instance.FindItem(info.ItemID);
            StringBuilder stringBuilder = new StringBuilder(string.Format("{0} ({1})\n", item.ItemName, info.Count));

            if (item is Consumable)
            {
                useButton.GetComponentInChildren <Text>().text = "使用";
                Consumable consumable = item as Consumable;
                useButton.onClick.AddListener(() =>
                {
                    if (consumable.Use(PlayerManager.Instance.Player.AbilityFactors))
                    {
                        PlayerManager.Instance.Player.Inventory.RemoveItem(consumable.ItemID, 1);
                    }
                });
                stringBuilder.Append("效果: ");
                foreach (var effector in consumable.Effectors)
                {
                    stringBuilder.AppendFormat("{0} ", effector.Information);
                }
            }
            else if (item is Equipment)
            {
                useButton.GetComponentInChildren <Text>().text = "裝備";
                Equipment equipment = item as Equipment;
                stringBuilder.Append("數值: ");
                foreach (var effector in equipment.EquipmentEffectors)
                {
                    stringBuilder.AppendFormat("{0} ", effector.Information);
                }
                if (!equipment.IsMatchedAbilityCodition(PlayerManager.Instance.Player))
                {
                    useButton.enabled = false;
                }
                else
                {
                    useButton.onClick.AddListener(() =>
                    {
                        switch (equipment.EquipmentType)
                        {
                        case EquipmentType.Weapon:
                            if (PlayerManager.Instance.Player.Weapon != null)
                            {
                                PlayerManager.Instance.Player.Inventory.AddItem(PlayerManager.Instance.Player.Weapon, 1);
                            }
                            PlayerManager.Instance.Player.Weapon = equipment;
                            break;

                        case EquipmentType.Head:
                            if (PlayerManager.Instance.Player.HeadEquipment != null)
                            {
                                PlayerManager.Instance.Player.Inventory.AddItem(PlayerManager.Instance.Player.HeadEquipment, 1);
                            }
                            PlayerManager.Instance.Player.HeadEquipment = equipment;
                            break;

                        case EquipmentType.Body:
                            if (PlayerManager.Instance.Player.BodyEquipment != null)
                            {
                                PlayerManager.Instance.Player.Inventory.AddItem(PlayerManager.Instance.Player.BodyEquipment, 1);
                            }
                            PlayerManager.Instance.Player.BodyEquipment = equipment;
                            break;

                        case EquipmentType.Foot:
                            if (PlayerManager.Instance.Player.FootEquipment != null)
                            {
                                PlayerManager.Instance.Player.Inventory.AddItem(PlayerManager.Instance.Player.FootEquipment, 1);
                            }
                            PlayerManager.Instance.Player.FootEquipment = equipment;
                            break;

                        case EquipmentType.Accessory:
                            if (PlayerManager.Instance.Player.Accessory != null)
                            {
                                PlayerManager.Instance.Player.Inventory.AddItem(PlayerManager.Instance.Player.Accessory, 1);
                            }
                            PlayerManager.Instance.Player.Accessory = equipment;
                            break;
                        }
                        PlayerManager.Instance.Player.Inventory.RemoveItem(equipment.ItemID, 1);
                    });
                }
            }
            else
            {
                useButton.gameObject.SetActive(false);
            }
            itemInfoText.text = stringBuilder.ToString();
        }
Esempio n. 11
0
 public InventoryItemInfo(InventoryItemInfo templateArg)
 {
     Setup(templateArg);
 }
Esempio n. 12
0
        public List <InventoryInfo> GetInventoryList(int userId)
        {
            List <InventoryInfo> items         = new List <InventoryInfo>();
            InventoryInfo        inventoryInfo = new InventoryInfo();
            InventoryItemInfo    inventoryItemInfo;

            SqlParameter[] parameters = SQLHelper.GetCachedParameters("SQL_GET_INVENTORY_DETAILS");

            if (parameters == null)
            {
                parameters = new SqlParameter[] {
                    new SqlParameter("@user_id", SqlDbType.Int)
                };

                SQLHelper.CacheParameters("SQL_GET_INVENTORY_DETAILS", parameters);
            }

            parameters[0].Value = userId;

            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                  CommandType.StoredProcedure, SQLHelper.GetSQLStatement(MODULE_NAME, "SP_GET_INVENTORY_DETAILS"),
                                                                  parameters))
            {
                while (reader.Read())
                {
                    bool isExists = false;
                    foreach (InventoryInfo inventoryAddedInfo in items)
                    {
                        if ((int)inventoryAddedInfo.CategoryType == (int)reader["category_code"])
                        {
                            isExists      = true;
                            inventoryInfo = inventoryAddedInfo;
                            break;
                        }
                    }
                    if (!isExists)
                    {
                        inventoryInfo = new InventoryInfo();
                        inventoryInfo.CategoryType   = (ProductCategory)(Convert.ToInt32(reader["category_code"]));
                        inventoryInfo.InventoryItems = new List <InventoryItemInfo>();
                    }
                    inventoryItemInfo = new InventoryItemInfo();
                    inventoryItemInfo.OrderTransactionType = (TransactionType)(Convert.ToInt32(reader["order_type"]));
                    inventoryItemInfo.Quantity             = Convert.ToInt32(reader["Quantity"]);
                    inventoryItemInfo.Remarks         = (string)reader["cc_trxn_message"];
                    inventoryItemInfo.TransactionDate = Convert.ToDateTime(reader["order_date"]);
                    inventoryItemInfo.TransactionId   = Convert.ToInt32(reader["cc_trxn_code"]);
                    inventoryInfo.InventoryItems.Add(inventoryItemInfo);
                    if (!isExists)
                    {
                        items.Add(inventoryInfo);
                    }
                }
            }
            Product product = new Product();
            List <ProductItemInfo> products = product.GetInventoryTotalCount(userId);

            foreach (ProductItemInfo itemInfo in products)
            {
                foreach (InventoryInfo inventoryInfoItem in items)
                {
                    if (itemInfo.ProductType == inventoryInfoItem.CategoryType.ToString().Replace("_", " "))
                    {
                        inventoryInfoItem.QuantityOnHand = itemInfo.Quantity;
                    }
                }
            }
            return(items);
        }