コード例 #1
0
 public PlayerArmor(string armorID)
 {
     armor = DataManager.Instance.SearchArmorID(armorID);
     if (armor != null)
     {
         armor.GenerateDurability();
         durability = armor.MaxDurability;
         owner      = null;
     }
 }
コード例 #2
0
    public void OnShow(string shopid)
    {
        ShopJson shop = FindShopById(shopid);

        if (shop != null)
        {
            charName.text    = shop.shopDialog.name;
            charContext.text = shop.shopDialog.context;
            Sprite texture = Resources.Load <Sprite>(shop.shopDialog.imgPath);
            if (texture)
            {
                charFace.sprite = texture;
            }

            string[] items = shop.shopItemIds;
            int      i     = 0;
            for (; i < items.Length; i++)
            {
                ItemJson item;
                if (items[i].ToLower().Contains("iw"))
                {
                    WeaponJson weapon = DataManager.Instance.SearchWeaponID(items[i]);
                    item = weapon;
                }
                else if (items[i].ToLower().Contains("ia"))
                {
                    ArmorJson armor = DataManager.Instance.SearchArmorID(items[i]);
                    item = armor;
                }
                else
                {
                    item = DataManager.Instance.SearchUsableID(items[i]);
                }
                Sprite sprite = Resources.Load <Sprite>(item.imgPath);
                shopItems[i].gameObject.SetActive(true);
                shopItems[i].OnShow(sprite, item.id);
            }
            for (; i < shopItems.Count; i++)
            {
                shopItems[i].gameObject.SetActive(false);
            }
            shopCanvas.gameObject.SetActive(true);
        }
    }
コード例 #3
0
 public void OnShow(string id, string type, int amount)
 {
     gameObject.SetActive(true);
     if (type.ToLower() != "null")
     {
         string path;
         string tempName;
         if (type.ToLower() == "usable")
         {
             UsableJson usable = DataManager.Instance.SearchUsableID(id);
             path     = usable.imgPath;
             tempName = usable.name;
             quantity.gameObject.SetActive(true);
             quantity.text = "x" + amount;
         }
         else if (type.ToLower() == "weapon")
         {
             WeaponJson weapon = DataManager.Instance.SearchWeaponID(id);
             path     = weapon.imgPath;
             tempName = weapon.name;
             quantity.gameObject.SetActive(false);
         }
         else
         {
             ArmorJson armor = DataManager.Instance.SearchArmorID(id);
             path     = armor.imgPath;
             tempName = armor.name;
             quantity.gameObject.SetActive(false);
         }
         image.sprite  = Resources.Load <Sprite>(path);
         itemName.text = tempName;
     }
     else
     {
         image.color   = new Color(255, 255, 255, 0);
         itemName.text = "";
         quantity.gameObject.SetActive(false);
     }
 }
コード例 #4
0
 public void OnHoverItem(string itemid)
 {
     if (!isItemClicked)
     {
         OnHoverDetailPanel.SetActive(true);
         ItemJson item;
         if (itemid.ToLower().Contains("iw"))
         {
             WeaponJson weapon = DataManager.Instance.SearchWeaponID(itemid);
             item          = weapon;
             itemStat.text = "Require level: " + item.lvlRequirement + "\n" +
                             "Type: " + item.type.ToString() + "\n" +
                             "PATK: " + weapon.patk + "\n" +
                             "MATK: " + weapon.matk;
         }
         else if (itemid.ToLower().Contains("ia"))
         {
             ArmorJson armor = DataManager.Instance.SearchArmorID(itemid);
             item          = armor;
             itemStat.text = "Require level: " + item.lvlRequirement + "\n" +
                             "Type: " + item.type.ToString() + "\n" +
                             "PATK: " + armor.pdef + "\n" +
                             "MATK: " + armor.mdef;
         }
         else
         {
             item          = DataManager.Instance.SearchUsableID(itemid);
             itemStat.text = "";
         }
         itemDescription.text = item.tooltips;
         itemName.text        = item.name;
         itemPrice.text       = item.gold + " Gold";
         itemJson             = item;
     }
     itemId = itemid;
 }