public override void OnRefreshWindow() { _listItem.Clear(); foreach (var item in UserManager.Instance.ItemList) { if (item.IsEquip() && item.Cfg.Type == (int)_equipType) { if (item.IsBook()) { BingfaConfig cfg = BingfaConfigLoader.GetConfig(item.ConfigID); if (cfg.Level >= _limitLevel) { _listItem.Add(item); } } else { EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(item.ConfigID); if (cfg.Level >= _limitLevel) { _listItem.Add(item); } } } } SmithyManager.Instance.SortItem(_listItem); _listView.Data = _listItem.ToArray(); _listView.OnClickListItem = OnSelectItem; _listView.Refresh(); }
// 更新预览的内容 private void UpdatePreview() { if (_equipType == ItemType.BOOK) { _imgPreview.sprite = ResourceManager.Instance.GetBookImage(_selectEquipID); _txtRandom.gameObject.SetActive(true); _txtBase.gameObject.SetActive(false); _txtPink.gameObject.SetActive(false); _txtOrange.gameObject.SetActive(false); BingfaConfig cfg = BingfaConfigLoader.GetConfig(_selectEquipID); _txtPreviewName.text = Str.Format("UI_LEVEL", cfg.EquipLevel) + " " + cfg.Name; } else { EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(_selectEquipID); _imgPreview.sprite = ResourceManager.Instance.GetEquipImage(_selectEquipID); _txtRandom.gameObject.SetActive(false); _txtBase.gameObject.SetActive(true); _txtPink.gameObject.SetActive(true); _txtOrange.gameObject.SetActive(true); _txtBaseAttr.text = SmithyManager.Instance.GetBaseAttr(_selectEquipID); _txtPreviewName.text = Str.Format("UI_LEVEL", cfg.EquipLevel) + " " + cfg.Name; _txtPinkAttr[0].text = SmithyManager.Instance.GetAddAttr(cfg.PurpleAttribute1); _txtOrangeAttr[0].text = SmithyManager.Instance.GetAddAttr(cfg.OrangeAttribute1); _txtOrangeAttr[1].text = SmithyManager.Instance.GetAddAttr(cfg.OrangeAttribute2); } }
// 选择模具 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); } }
public override void OnRefreshWindow() { if (_info == null) { return; } HeroInfo heroInfo = UserManager.Instance.GetHeroByItem(_info.EntityID); if (heroInfo != null) { _txtHasEquip.gameObject.SetActive(true); _txtHasEquip.text = string.Format("{0}({1})", Str.Get("UI_HAS_EQUIP"), heroInfo.Cfg.HeroName); } else { _txtHasEquip.gameObject.SetActive(false); } _ImageItemIconBg.sprite = ResourceManager.Instance.GetIconBgByQuality(_info.Cfg.Quality); _imageItemIcon.sprite = ResourceManager.Instance.GetItemIcon(_info.ConfigID); _txtItemName.text = _info.Cfg.Name; _txtItemName.color = ResourceManager.Instance.GetColorByQuality(_info.Cfg.Quality); _txtItemType.text = ItemInfo.GetItemTypeName(_info.Cfg.Type); _itemAttribute.SetInfo(_info); if (_info.IsEquip()) { Color color = ResourceManager.Instance.GetColorByQuality(_info.Quality); _txtQuality.text = ItemInfo.GetQualityName(_info.Quality); _txtQuality.color = color; _txtQualityText.color = color; _txtQualityText.gameObject.SetActive(true); _txtScore.text = _info.GetScore().ToString(); _txtScore.color = color; _txtScoreText.color = color; _txtScoreText.gameObject.SetActive(true); if (_info.IsBook()) { // 如果是兵法书 BingfaConfig cfg = BingfaConfigLoader.GetConfig(_info.ConfigID); _txtItemLevel.text = cfg.EquipLevel.ToString(); } else { // 如果是装备 EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(_info.ConfigID); _txtItemLevel.text = cfg.EquipLevel.ToString(); } } }
// 获取物品大图 public Sprite GetEquipImage(int itemID) { EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(itemID); if (cfg == null || string.IsNullOrEmpty(cfg.CreateIcon)) { return(GetSprite("Texture/ItemIcon2/1")); } return(GetSprite("Texture/ItemIcon2/" + cfg.CreateIcon)); }
// 基础属性的锻造范围 public string GetBaseAttr(int cfgID) { EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(cfgID); List <int> list = new List <int>(); ParseAttr(list, cfg.WhiteLow); ParseAttr(list, cfg.GreenLower); ParseAttr(list, cfg.BlueLower); ParseAttr(list, cfg.PurpleLower); ParseAttr(list, cfg.OrangeLower); list.Sort(); return(string.Format("{0}+ {1}-{2}", ItemInfo.GetAttrName(cfg.BasicType), list[0], list[list.Count - 1])); }
public override void SetInfo(object data) { ItemInfo info = data as ItemInfo; if (info == null) { return; } _info = info; _ImageItemIconBg.sprite = ResourceManager.Instance.GetIconBgByQuality(info.Cfg.Quality); _imageItemIcon.sprite = ResourceManager.Instance.GetItemIcon(info.ConfigID); _txtItemName.text = info.Cfg.Name; _txtItemName.color = ResourceManager.Instance.GetColorByQuality(info.Cfg.Quality); _txtItemType.text = ItemInfo.GetItemTypeName(info.Cfg.Type); _itemAttribute.SetInfo(_info); if (info.IsEquip()) { Color color = ResourceManager.Instance.GetColorByQuality(info.Quality); _txtQuality.text = ItemInfo.GetQualityName(info.Quality); _txtQuality.color = color; _txtQualityText.color = color; _txtQualityText.gameObject.SetActive(true); _txtScore.text = info.GetScore().ToString(); _txtScore.color = color; _txtScoreText.color = color; _txtScoreText.gameObject.SetActive(true); if (info.IsBook()) { // 如果是兵法书 BingfaConfig cfg = BingfaConfigLoader.GetConfig(info.ConfigID); _txtItemLevel.text = cfg.EquipLevel.ToString(); } else { // 如果是装备 EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(info.ConfigID); _txtItemLevel.text = cfg.EquipLevel.ToString(); } } }
private void SelectEquip(int equipID) { _selectEquipID = equipID; if (_equipType == ItemType.BOOK) { // 选择的是兵法 BingfaConfig cfg = BingfaConfigLoader.GetConfig(_selectEquipID); _needMoldCount = cfg.MoldDemand; _needStuffItems = SmithyManager.Instance.ParseItems(cfg.MaterialDemand); _needMoldItems = SmithyManager.Instance.SelectModelBook(_selectEquipID); _needMoney = 0; _needGold = 0; } else { // 选择的是装备 EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(_selectEquipID); _needMoldCount = cfg.MoldDemand; _needStuffItems = SmithyManager.Instance.ParseItems(cfg.MaterialDemand); _needMoldItems = SmithyManager.Instance.SelectModelEquip(_selectEquipID); _needMoney = cfg.GoldDemand; _needGold = cfg.LuckyBuild; } foreach (var item in _itemPanel) { item.gameObject.SetActive(false); } int count = _needMoldCount + _needStuffItems.Count; _currentPanel = _itemPanel[count - 2]; _currentPanel.gameObject.SetActive(true); _currentPanel.SetInfo(equipID, _needMoldItems, _needStuffItems, _needMoldCount); _txtSmithing.text = _needMoney.ToString(); _txtLuckSmithing.text = _needGold.ToString(); UpdatePreview(); }
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(); } }
public void SetItemInfo(ItemInfo info) { _currentItemInfo = info; // 在背包中显示 if (info.CouldUse() || info.IsEquip()) { // 可以使用 _btnUse.gameObject.SetActive(true); _btnDetail.gameObject.SetActive(false); if (info.IsEquip()) { _txtUseText.text = Str.Get("UI_EQUIP"); } else { _txtUseText.text = Str.Get("UI_USE"); } } else { _btnUse.gameObject.SetActive(false); _btnDetail.gameObject.SetActive(true); } _btnSell.gameObject.SetActive(true); _ImageItemIconBg.sprite = ResourceManager.Instance.GetIconBgByQuality(info.Cfg.Quality); _ImageItemIconBgCover.sprite = ResourceManager.Instance.GetIconBgCoverByQuality(info.Cfg.Quality); _imageItemIcon.sprite = ResourceManager.Instance.GetItemIcon(info.ConfigID); _txtItemName.text = info.Cfg.Name; _txtItemName.color = ResourceManager.Instance.GetColorByQuality(info.Cfg.Quality); _txtItemDesc.text = info.Cfg.Decription; _txtItemSellPrice.text = info.Cfg.Price.ToString(); if (info.IsEquip()) { Color color = ResourceManager.Instance.GetColorByQuality(info.Quality); _txtQuality.text = ItemInfo.GetQualityName(info.Quality); _txtQuality.color = color; _txtQualityText.color = color; _txtQualityText.gameObject.SetActive(true); _txtScore.text = info.GetScore().ToString(); _txtScore.color = color; _txtScoreText.color = color; _txtScoreText.gameObject.SetActive(true); _txtBaseAttrText.gameObject.SetActive(false); _txtAddAttrText.gameObject.SetActive(false); _txtAttrText.gameObject.SetActive(false); _txtItemDesc.gameObject.SetActive(false); if (info.IsBook()) { _txtAttrText.gameObject.SetActive(true); // 如果是兵法书 // 显示tip for (int i = 0; i < _txtAttributes.Length; ++i) { string txt = info.GetAttrDesc(i, 0, true); if (!string.IsNullOrEmpty(txt)) { _txtAttributes[i].text = txt; _txtAttributes[i].color = color; _txtAttributes[i].gameObject.SetActive(true); } else { _txtAttributes[i].gameObject.SetActive(false); } } } else { _txtBaseAttrText.gameObject.SetActive(true); // 如果是装备 EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(info.ConfigID); _txtBaseAttr.text = info.GetAttrDesc(0, cfg.BasicType, true); bool showAdd = false; for (int i = 0; i < _txtAddAttr.Length; ++i) { string txt = info.GetAttrDesc(i, cfg.BasicType, false); if (!string.IsNullOrEmpty(txt)) { _txtAddAttr[i].text = txt; _txtAddAttr[i].color = color; _txtAddAttr[i].gameObject.SetActive(true); showAdd = true; } else { _txtAddAttr[i].gameObject.SetActive(false); } } _txtAddAttrText.gameObject.SetActive(showAdd); } } else { _txtItemDesc.gameObject.SetActive(true); _txtItemDesc.text = info.Cfg.Decription; _txtQualityText.gameObject.SetActive(false); _txtScoreText.gameObject.SetActive(false); _txtBaseAttrText.gameObject.SetActive(false); _txtAddAttrText.gameObject.SetActive(false); _txtAttrText.gameObject.SetActive(false); } }
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); } } } }
public void SetInfo(ItemInfo info) { _info = info; if (_info == null || !_info.IsEquip()) { return; } Color color = ResourceManager.Instance.GetColorByQuality(_info.Quality); _txtBaseAttrText.gameObject.SetActive(false); _txtAddAttrText.gameObject.SetActive(false); _txtAttributesText.gameObject.SetActive(false); if (_info.IsBook()) { _txtAttributesText.gameObject.SetActive(true); // 如果是兵法书 // 显示tip for (int i = 0; i < _txtAttributes.Length; ++i) { string txt = _info.GetAttrDesc(i, 0, true); if (!string.IsNullOrEmpty(txt)) { _txtAttributes[i].text = txt; _txtAttributes[i].color = color; _txtAttributes[i].gameObject.SetActive(true); _imgAttributes[i].sprite = ResourceManager.Instance.GetItemAttrFlag(_info.Quality); } else { _txtAttributes[i].gameObject.SetActive(false); } } } else { _txtBaseAttrText.gameObject.SetActive(true); // 如果是装备 EquipmentConfig cfg = EquipmentConfigLoader.GetConfig(_info.ConfigID); _txtBaseAttr.text = _info.GetAttrDesc(0, cfg.BasicType, true); _imgBaseAttr.sprite = ResourceManager.Instance.GetItemAttrFlag(1); bool showAdd = false; for (int i = 0; i < _txtAddAttr.Length; ++i) { string txt = _info.GetAttrDesc(i, cfg.BasicType, false); if (!string.IsNullOrEmpty(txt)) { _txtAddAttr[i].text = txt; _txtAddAttr[i].color = color; _txtAddAttr[i].gameObject.SetActive(true); _imgAddAttr[i].sprite = ResourceManager.Instance.GetItemAttrFlag(_info.Quality); showAdd = true; } else { _txtAddAttr[i].gameObject.SetActive(false); } } _txtAddAttrText.gameObject.SetActive(showAdd); } }