Esempio n. 1
0
        public static IDictionary <string, Item> BuildDictionary(ItemsConfig config, IDictionary <string, Tag> tags)
        {
            IDictionary <string, Item> items = new Dictionary <string, Item>();

            foreach (IList <object> row in config.Query.Data)
            {
                try
                {
                    IList <string> item = row.Select(r => r.ToString()).ToList();
                    string         name = ParseHelper.SafeStringParse(item, config.Name, "Name", false);
                    if (string.IsNullOrEmpty(name))
                    {
                        continue;
                    }

                    if (!items.TryAdd(name, new Item(config, item, tags)))
                    {
                        throw new NonUniqueObjectNameException("item");
                    }
                }
                catch (Exception ex)
                {
                    throw new ItemProcessingException((row.ElementAtOrDefault(config.Name) ?? string.Empty).ToString(), ex);
                }
            }

            return(items);
        }
Esempio n. 2
0
    public bool IsFixGet;   // 传递给服务器,用来区分两个配表中的物品

    public void Deserialize(PGeneralGood data)
    {
        EntityID   = data.id;
        ConfigID   = data.id;
        ContainNum = data.num;
        IsSoldOut  = !data.isCanBuy;
        IsFixGet   = data.isFixGet;

        if (data.isFixGet)
        {
            ShopFixGoodConfig cfg = ShopFixGoodConfigLoader.GetConfig(ConfigID);
            ItemConfigID = cfg.ItemId;
            ItemsConfig itemCfg = ItemsConfigLoader.GetConfig(ItemConfigID);
            if (itemCfg != null)
            {
                Name    = itemCfg.Name;
                Quality = itemCfg.Quality;
                Price   = cfg.Price * ContainNum;
            }
        }
        else
        {
            ShopConstConfig cfg = ShopConstConfigLoader.GetConfig(ConfigID);
            ItemConfigID = cfg.ItemId;
            ItemsConfig itemCfg = ItemsConfigLoader.GetConfig(ItemConfigID);
            if (itemCfg != null)
            {
                Name    = itemCfg.Name;
                Quality = itemCfg.Quality;
                Price   = cfg.Price * ContainNum;
            }
        }
    }
Esempio n. 3
0
    public override void OnRefreshWindow()
    {
        if (_itemID > 0)
        {
            ItemsConfig cfg = ItemsConfigLoader.GetConfig(_itemID);
            _txtTitle.text = string.Format(Str.Get("UI_TAVERN_BUY_EXP"), (_count > 1 ? cfg.Name + "x" + _count : cfg.Name));
        }

        for (int i = 0; i < _listWidget.Length; ++i)
        {
            ItemWidget widget = _listWidget[i];
            if (i < _itemList.Count)
            {
                widget.gameObject.SetActive(true);
                ItemInfo itemInfo = _itemList[i];
                widget.SetInfo(itemInfo);
                _originPosition.Add(widget.transform.position);
                widget.gameObject.SetActive(false);
            }
            else
            {
                widget.gameObject.SetActive(false);
            }
        }

        StartCoroutine(PlayAnimation());
    }
Esempio n. 4
0
    public void OnPointerDown(PointerEventData eventData)
    {
        if (!_enableTip)
        {
            return;
        }
        // TODO 显示tip界面

        ItemsConfig cfg = ItemsConfigLoader.GetConfig(_itemCfgID);

        if (cfg.Type <= (int)ItemType.BOOK)
        {
            // 装备
            if (_itemInfo == null)
            {
                UIManager.Instance.OpenWindow <UIDummyEquipInfoView>(_itemCfgID);
            }
            else
            {
                UIManager.Instance.OpenWindow <UIEquipInfoView>(_itemInfo, _itemCfgID);
            }
        }
        else
        {
            // 其他物品
            UIManager.Instance.OpenWindow <UIItemInfoView>(_itemInfo, _itemCfgID);
        }
    }
Esempio n. 5
0
    public ItemData(ItemsConfig _config)
    {
        id = _config.id;

        ApplySelfParameters(_config.selfParameters);
        ApplyShipParameters(_config.shipParameters);
        ApplySkills(_config.skills);
    }
Esempio n. 6
0
    // 选择模具
    public List <ItemInfo> SelectModelEquip(int equipCfgID)
    {
        List <ItemInfo> ret = new List <ItemInfo>();

        ItemsConfig cfg         = ItemsConfigLoader.GetConfig(equipCfgID);
        int         demandCount = 0;

        if (cfg.Type < (int)ItemType.BOOK)
        {
            EquipmentConfig cfgEquip = EquipmentConfigLoader.GetConfig(equipCfgID);
            demandCount = cfgEquip.MoldDemand;

            // 遍历所有装备,获取比当前装备低一级的所有装备(低一级是底线,可以等级更高)
            foreach (var item in UserManager.Instance.ItemList)
            {
                if (item.Cfg.Type < (int)ItemType.BOOK)
                {
                    EquipmentConfig itemCfg = EquipmentConfigLoader.GetConfig(item.ConfigID);
                    if (itemCfg.Level >= cfgEquip.Level - 1 && itemCfg.Type == cfgEquip.Type)
                    {
                        ret.Add(item);
                    }
                }
            }
        }
        else
        {
            BingfaConfig cfgBook = BingfaConfigLoader.GetConfig(equipCfgID);
            demandCount = cfgBook.MoldDemand;

            // 遍历所有装备,获取比当前装备低一级的所有装备(低一级是底线,可以等级更高)
            foreach (var item in UserManager.Instance.ItemList)
            {
                if (item.Cfg.Type == (int)ItemType.BOOK)
                {
                    BingfaConfig itemCfg = BingfaConfigLoader.GetConfig(item.ConfigID);
                    if (itemCfg.Level >= cfgBook.Level - 1 && itemCfg.Type == cfgBook.Type)
                    {
                        ret.Add(item);
                    }
                }
            }
        }


        SortItem(ret);

        if (demandCount < ret.Count)
        {
            return(ret.GetRange(0, demandCount));
        }
        else
        {
            return(ret);
        }
    }
Esempio n. 7
0
    public override void OnRefreshWindow()
    {
        if (_itemInfo != null)
        {
            // 有这个物品
            _txtResNumber.text          = _itemInfo.Number.ToString();
            _imageResIconBg.sprite      = ResourceManager.Instance.GetIconBgByQuality(_itemInfo.Cfg.Quality);
            _imageResIconBgCover.sprite = ResourceManager.Instance.GetIconBgCoverByQuality(_itemInfo.Cfg.Quality);
            _imageResIcon.sprite        = ResourceManager.Instance.GetItemIcon(_itemInfo.Cfg.CfgId);
            _txtResName.text            = _itemInfo.Cfg.Name;
            _txtResName.color           = ResourceManager.Instance.GetColorByQuality(_itemInfo.Quality);
        }
        else
        {
            ItemInfo itemInfo = UserManager.Instance.GetItemByConfigID(_itemCfgID);
            if (itemInfo != null)
            {
                _txtResNumber.color = Color.white;
                _txtResNumber.text  = itemInfo.Number.ToString();
            }
            else
            {
                int number = 0;
                if (_itemCfgID == GameConfig.ITEM_CONFIG_ID_WOOD)
                {
                    number = UserManager.Instance.Wood;
                }
                else if (_itemCfgID == GameConfig.ITEM_CONFIG_ID_STONE)
                {
                    number = UserManager.Instance.Stone;
                }
                else if (_itemCfgID == GameConfig.ITEM_CONFIG_ID_MONEY)
                {
                    number = UserManager.Instance.Money;
                }

                if (number == 0)
                {
                    _txtResNumber.color = Color.red;
                    _txtResNumber.text  = "0";
                }
                else
                {
                    _txtResNumber.color = Color.white;
                    _txtResNumber.text  = number.ToString();
                }
            }
            ItemsConfig cfg = ItemsConfigLoader.GetConfig(_itemCfgID);

            _imageResIconBg.sprite      = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
            _imageResIconBgCover.sprite = ResourceManager.Instance.GetIconBgCoverByQuality(cfg.Quality);
            _imageResIcon.sprite        = ResourceManager.Instance.GetItemIcon(cfg.CfgId);
            _txtResName.text            = cfg.Name;
            _txtResName.color           = ResourceManager.Instance.GetColorByQuality(cfg.Quality);
        }
    }
Esempio n. 8
0
    // 获取物品图标
    public Sprite GetItemIcon(int itemID)
    {
        ItemsConfig cfg = ItemsConfigLoader.GetConfig(itemID);

        if (cfg == null || string.IsNullOrEmpty(cfg.Icon))
        {
            return(GetSprite("Texture/ItemIcon/19"));
        }
        return(GetSprite("Texture/ItemIcon/" + cfg.Icon));
    }
Esempio n. 9
0
    //public void Init(BattleTeam team, UnitConfig cfg)
    //{
    //    Team = team;

    //    // 根据不同的阵营创建模型
    //    if (team == BattleTeam.BLUE_TEAM) {
    //        ModelName = cfg.PrefabBlue;
    //    } else if (team == BattleTeam.RED_TEAM) {
    //        ModelName = cfg.PrefabRed;
    //    }
    //}

    public ItemInfo GetItemByType(ItemType itemType)
    {
        foreach (var item in EquipedItem)
        {
            ItemsConfig cfg = ItemsConfigLoader.GetConfig(item.ConfigID);
            if (cfg != null && (ItemType)cfg.Type == itemType)
            {
                return(item);
            }
        }
        return(null);
    }
Esempio n. 10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <exception cref="AnyIntegerException"></exception>
        public Item(ItemsConfig config, IList <string> data, IDictionary <string, Tag> tags)
        {
            this.Name          = ParseHelper.SafeStringParse(data, config.Name, "Name", true);
            this.SpriteURL     = ParseHelper.SafeURLParse(data, config.SpriteURL, "Sprite URL", false);
            this.Category      = ParseHelper.SafeStringParse(data, config.Category, "Category", true);
            this.WeaponRank    = ParseHelper.SafeStringParse(data, config.WeaponRank, "Weapon Rank", false);
            this.UtilizedStats = ParseHelper.StringCSVParse(data, config.UtilizedStats);
            this.DealsDamage   = (ParseHelper.SafeStringParse(data, config.DealsDamage, "Deals Damage", true) == "Yes");
            this.MaxUses       = ParseHelper.Int_Positive(data, config.Uses, "Uses");
            this.Range         = new ItemRange(data, config.Range.Minimum, config.Range.Maximum, config.Range.Shape);
            this.TextFields    = ParseHelper.StringListParse(data, config.TextFields);

            this.Tags = ParseHelper.StringCSVParse(data, config.Tags).Distinct().ToList();
            MatchTags(tags);

            this.Stats = new Dictionary <string, int>();
            foreach (NamedStatConfig stat in config.Stats)
            {
                int val = ParseHelper.Int_Any(data, stat.Value, stat.SourceName);
                this.Stats.Add(stat.SourceName, val);
            }

            this.EquippedStatModifiers = new Dictionary <string, int>();
            foreach (NamedStatConfig stat in config.EquippedStatModifiers)
            {
                int val = ParseHelper.OptionalInt_Any(data, stat.Value, $"{stat.SourceName} (Equipped)");
                if (val == 0)
                {
                    continue;
                }
                this.EquippedStatModifiers.Add(stat.SourceName, val);
            }

            this.InventoryStatModifiers = new Dictionary <string, int>();
            foreach (NamedStatConfig stat in config.InventoryStatModifiers)
            {
                int val = ParseHelper.OptionalInt_Any(data, stat.Value, $"{stat.SourceName} (Inventory)");
                if (val == 0)
                {
                    continue;
                }
                this.InventoryStatModifiers.Add(stat.SourceName, val);
            }
        }
Esempio n. 11
0
    public void SetInfo(HeroInfo info, ItemType itemType)
    {
        _itemBg.sprite = ResourceManager.Instance.GetItemBgByStar(info.StarLevel);
        _itemIcon.gameObject.SetActive(false);
        _itemIconBg.gameObject.SetActive(false);
        _itemFlagY.gameObject.SetActive(false);
        _itemFlagG.gameObject.SetActive(false);
        ItemInfo itemInfo = info.GetItemByType(itemType);

        if (itemInfo != null)
        {
            // 已经装备
            _itemIcon.gameObject.SetActive(true);
            _itemIcon.sprite = ResourceManager.Instance.GetItemIcon(itemInfo.ConfigID);
            _itemIconBg.gameObject.SetActive(true);
            _itemIconBg.sprite = ResourceManager.Instance.GetIconBgByQuality(itemInfo.Quality);
        }
        else
        {
            _itemIcon.gameObject.SetActive(false);

            ItemInfo itemInfoInBag = UserManager.Instance.GetItemByType(itemType);
            if (itemInfoInBag != null)
            {
                // 背包中有对应物品
                ItemsConfig itemConfig = ItemsConfigLoader.GetConfig(itemInfoInBag.ConfigID);
                if (info.Level >= itemConfig.Level)
                {
                    // 可以装备,显示绿色+
                    _itemFlagG.gameObject.SetActive(true);
                }
                else
                {
                    // 不可以装备,显示黄色+
                    _itemFlagY.gameObject.SetActive(true);
                }
            }
            else
            {
                // 背包中没有对应物品,直接留空
            }
        }
    }
Esempio n. 12
0
    public void SetInfo(int cfgID, WidgetType type, int count, int needCount)
    {
        _itemCfgID = cfgID;
        _type      = type;

        _imgBg.gameObject.SetActive(true);
        _imgIcon.gameObject.SetActive(true);
        _txtName.gameObject.SetActive(true);
        if (_txtCount != null)
        {
            _txtCount.gameObject.SetActive(true);
        }
        ItemsConfig cfg = ItemsConfigLoader.GetConfig(_itemCfgID);

        if (cfg == null)
        {
            gameObject.SetActive(false);
            return;
        }

        _imgBg.sprite = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
        if (_imgBgCover != null)
        {
            _imgBgCover.sprite = ResourceManager.Instance.GetIconBgCoverByQuality(cfg.Quality);
        }
        _imgIcon.sprite = ResourceManager.Instance.GetItemIcon(_itemCfgID);
        if (_txtCount != null && needCount > 0)
        {
            if (count < needCount)
            {
                _txtCount.text = string.Format("<color=red>{0}</color>/{1}", count, needCount);
            }
            else
            {
                _txtCount.text = string.Format("{0}/{1}", count, needCount);
            }
        }

        if (_txtName != null)
        {
            _txtName.text = cfg.Name;
        }
    }
Esempio n. 13
0
    public override void SetInfo(object data)
    {
        _info = (ShopItemInfo)data;

        ItemsConfig cfg = ItemsConfigLoader.GetConfig(_info.ItemConfigID);

        if (cfg == null)
        {
            return;
        }

        _itemIcon.sprite      = ResourceManager.Instance.GetItemIcon(_info.ItemConfigID);
        _itemBg.sprite        = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
        _itemBgCover.sprite   = ResourceManager.Instance.GetIconBgCoverByQuality(cfg.Quality);
        _itemName.text        = cfg.Name + "x" + _info.ContainNum;
        _itemName.color       = _info.IsSoldOut ? new Color(128 / 255f, 128 / 255f, 128 / 255f, 1) : ResourceManager.Instance.GetColorByQuality(cfg.Quality);
        _itemMoneyIcon.sprite = ResourceManager.Instance.GetPriceIcon(_info.PriceType);
        _itemMoneyIcon.SetNativeSize();
        _itemSoldout.material = _info.IsSoldOut ? GUIGrayScale : null;
        _itemMoneyNumber.text = _info.Price.ToString();
    }
Esempio n. 14
0
    public void SetInfo(int itemID, HeroInfo heroInfo)
    {
        _itemID       = itemID;
        _info         = heroInfo;
        _currentLevel = heroInfo.Level;
        _currentExp   = heroInfo.Exp;

        ItemsConfig cfg = ItemsConfigLoader.GetConfig(itemID);

        if (cfg == null)
        {
            gameObject.SetActive(false);
            return;
        }

        ItemInfo itemInfo = UserManager.Instance.GetItemByConfigID(itemID);

        _itemInfo = itemInfo;

        _imgBg.sprite      = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
        _imgBgCover.sprite = ResourceManager.Instance.GetIconBgCoverByQuality(cfg.Quality);  // 设置新加的遮挡 icon 背景
        _imgIcon.sprite    = ResourceManager.Instance.GetItemIcon(itemID);

        if (itemInfo != null && itemInfo.Number > 0)
        {
            _txtCount.color = Color.white;
            _txtCount.text  = "x" + itemInfo.Number;
            _leftBooksNum   = itemInfo.Number;
        }
        else
        {
            _txtCount.color = Color.red;
            _txtCount.text  = "x0";
        }
        _txtName.text   = cfg.Name;
        _txtAddExp.text = "+" + cfg.ExpIncrease;
        _bookAddExp     = cfg.ExpIncrease;
    }
Esempio n. 15
0
    public override void OnRefreshWindow()
    {
        ItemsConfig cfg = ItemsConfigLoader.GetConfig(_itemCfgID);

        _ImageItemIconBg.sprite = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
        _imageItemIcon.sprite   = ResourceManager.Instance.GetItemIcon(_itemCfgID);
        _txtItemName.text       = cfg.Name;
        _txtItemName.color      = ResourceManager.Instance.GetColorByQuality(cfg.Quality);
        _txtItemType.text       = ItemInfo.GetItemTypeName(cfg.Type);

        if (cfg.Type == (int)ItemType.BOOK)
        {
            // 如果是兵法书
            BingfaConfig cfgBook = BingfaConfigLoader.GetConfig(_itemCfgID);
            _txtItemLevel.text = cfgBook.EquipLevel.ToString();
        }
        else
        {
            // 如果是装备
            EquipmentConfig cfgEquip = EquipmentConfigLoader.GetConfig(_itemCfgID);
            _txtItemLevel.text = cfgEquip.EquipLevel.ToString();
        }
    }
Esempio n. 16
0
    private IEnumerator PlayAnimation()
    {
        const float TIME = 0.2f;

        for (int i = 0; i < Mathf.Min(_itemList.Count, _listWidget.Length); ++i)
        {
            ItemWidget widget = _listWidget[i];
            widget.gameObject.SetActive(true);
            widget.transform.position   = _startPosition.transform.position;
            widget.transform.localScale = Vector3.one * 0.1f;
            widget.transform.Rotate(0, 0, -270);

            Sequence seq = DOTween.Sequence();
            seq.Join(widget.transform.DOMove(_originPosition[i], TIME));
            seq.Join(widget.transform.DOScale(Vector3.one, TIME));
            seq.Join(widget.transform.DORotate(Vector3.zero, TIME));
            seq.Play();

            if (widget._info.IsCard())
            {
                ItemsConfig itemCfg = ItemsConfigLoader.GetConfig(widget._info.ConfigID);
                HeroConfig  heroCfg = HeroConfigLoader.GetConfig(itemCfg.MatchHero);
                // 创建模型
                GameObject prefab = Resources.Load <GameObject>("Effect/UI/Eff_chouka");
                GameObject go     = Instantiate(prefab);
                go.transform.position = Vector3.zero;
                // 等待动画播放完出现底座才显示模型
                yield return(new WaitForSeconds(2));

                CreateHeroModel(heroCfg, go);
                yield return(new WaitForSeconds(3));

                Destroy(go);
            }
            yield return(new WaitForSeconds(TIME));
        }
    }
Esempio n. 17
0
    public void SetInfo(int cfgID, int count)
    {
        _itemCfgID = cfgID;
        ItemsConfig cfg = ItemsConfigLoader.GetConfig(cfgID);

        if (cfg == null)
        {
            gameObject.SetActive(false);
            return;
        }

        _imgBg.sprite   = ResourceManager.Instance.GetIconBgByQuality(cfg.Quality);
        _imgIcon.sprite = ResourceManager.Instance.GetItemIcon(cfgID);
        if (_txtCount != null)
        {
            _txtCount.gameObject.SetActive(count > 1);
            _txtCount.text = count.ToString();
        }

        if (_txtName != null)
        {
            _txtName.text = cfg.Name;
        }
    }
Esempio n. 18
0
    public SmithyItemWidget[] _itemList;   // 物品栏

    public void SetInfo(int equipCfgID, List <ItemInfo> mold, List <SmithyManager.SmithyItemInfo> stuff, int moldNeedCount)
    {
        _itemFinal.SetInfo(equipCfgID, SmithyItemWidget.WidgetType.EQUIP, 1, 0);

        ItemsConfig cfg = ItemsConfigLoader.GetConfig(equipCfgID);

        int level = 0;

        if (cfg.Type < (int)ItemType.BOOK)
        {
            EquipmentConfig cfgDest = EquipmentConfigLoader.GetConfig(equipCfgID);
            level = cfgDest.Level - 1;
        }
        else
        {
            BingfaConfig cfgDest = BingfaConfigLoader.GetConfig(equipCfgID);
            level = cfgDest.Level - 1;
        }


        for (int i = 0; i < _itemList.Length; ++i)
        {
            if (i < moldNeedCount)
            {
                // 排模具
                if (i < mold.Count)
                {
                    // 有足够的模具
                    _itemList[i].SetInfo(mold[i], SmithyItemWidget.WidgetType.MOLD, 1, 1);
                }
                else
                {
                    // 模具不足
                    _itemList[i].SetInfo(null, SmithyItemWidget.WidgetType.MOLD, 1, 1);
                }
                _itemList[i].SetMoldInfo(i, (ItemType)cfg.Type, level);
            }
            else
            {
                // 排材料
                int index = i - moldNeedCount;
                if (index < stuff.Count)
                {
                    // 材料不足
                    SmithyManager.SmithyItemInfo itemInfo = stuff[index];
                    if (itemInfo.CfgID == GameConfig.ITEM_CONFIG_ID_WOOD)
                    {
                        // 木材
                        _itemList[i].SetInfo(itemInfo.CfgID, SmithyItemWidget.WidgetType.MATERIAL, UserManager.Instance.Wood, itemInfo.Count);
                    }
                    else if (itemInfo.CfgID == GameConfig.ITEM_CONFIG_ID_STONE)
                    {
                        // 石材
                        _itemList[i].SetInfo(itemInfo.CfgID, SmithyItemWidget.WidgetType.MATERIAL, UserManager.Instance.Stone, itemInfo.Count);
                    }
                    else
                    {
                        // 普通材料
                        ItemInfo info = UserManager.Instance.GetItemByConfigID(itemInfo.CfgID);
                        if (info != null)
                        {
                            _itemList[i].SetInfo(itemInfo.CfgID, SmithyItemWidget.WidgetType.MATERIAL, info.Number, itemInfo.Count);
                        }
                        else
                        {
                            _itemList[i].SetInfo(itemInfo.CfgID, SmithyItemWidget.WidgetType.MATERIAL, 0, itemInfo.Count);
                        }
                    }
                }
                else
                {
                    // 材料种类充足(并不确定具体每个材料是否充足)
                    _itemList[i].SetInfo(0, SmithyItemWidget.WidgetType.MATERIAL, 0, 0);
                }
            }
        }
    }