// --------------------------------- // Func // --------------------------------- void _updateQueryGridItems(int m_id) { if (FactoryReplicator == null) { return; } Pathea.Replicator r = UIGraphControl.GetReplicator(); if (null == r) { return; } // Clear first FactoryReplicator.DestroyQueryItems(); foreach (Pathea.Replicator.KnownFormula kf in r.knowFormulas) { Pathea.Replicator.Formula ms = kf.Get(); if (null == ms) { continue; } for (int j = 0; j < ms.materials.Count; j++) { if (ms.materials[j].itemId == m_id) { _createQueryItems(ms.productItemId); } } } }
public UIGraphNode AddGraphItem(int lever_v, UIGraphNode partent, Pathea.Replicator.Formula ms, string[] strSprites, string strAtlas) { UIGraphNode node = new UIGraphNode(lever_v, partent); GameObject o = CreateGraphItem(partent, lever_v); int tempIndex = mGraphItemList.Count; node.mObject = o; node.mIndex = tempIndex; node.mCtrl = o.GetComponent <UIGraphItemCtrl>(); node.mTreeGrid = o.GetComponent <UITreeGrid>(); node.mTipCtrl = node.mCtrl.mTipCtrl; node.ms = ms; if (partent == null) { rootNode = node; } if (node.mCtrl != null) { node.mCtrl.SetCotent(strSprites, strAtlas); node.mCtrl.SetIndex(tempIndex); } mGraphItemList.Add(node); return(node); }
private bool ReDrawGraph(int itemID, int scirptIndex = 0) { if (mGraphCtrl == null) { return(false); } this.AddScriptItemData(itemID); if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0) { return(true); } if (mRootType == ItemLabel.Root.ISO) { // Iso } else { Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex]; Pathea.Replicator.Formula ms = knownFornula.Get(); ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID); if (ms == null || item == null) { return(false); } // 临时处理 bool enable = (ms.workSpace != 0) ? true : false; mLbGraphInfo.enabled = enable; mLbGraphInfo.text = enable ? PELocalization.GetString(8000151) : ""; mGraphCtrl.ClearGraph(); int level_v = 0; UIGraphNode root = mGraphCtrl.AddGraphItem(level_v, null, ms, item.icon, "Icon"); root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID); root.mCtrl.ItemClick += this.GraphItemOnClick; this.m_CurScriptMatIDs.Clear(); for (int j = 0; j < ms.materials.Count; j++) { if (ms.materials[j].itemId != 0) { this.m_CurScriptMatIDs.Add(ms.materials[j].itemId); ItemProto item2 = ItemProto.GetItemData(ms.materials[j].itemId); UIGraphNode node = mGraphCtrl.AddGraphItem(level_v, root, null, item2.icon, "Icon"); node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId); node.mCtrl.ItemClick += this.GraphItemOnClick; } } UpdateItemsTrackState(ms); } mGraphCtrl.DrawGraph(); return(true); }
public bool isCanCreate( ) { if (mGraphItemList.Count == 0) { return(false); } Pathea.Replicator r = GetReplicator(); if (null == r) { return(false); } Pathea.Replicator.Formula formula = Pathea.Replicator.Formula.Mgr.Instance.Find(rootNode.ms.id); if (null == formula) { return(false); } ItemAsset.ItemProto proto = ItemAsset.ItemProto.GetItemData(formula.productItemId); if (proto != null) { if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockProductItemLevel(proto.level)) { return(false); } if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockProductItemType(proto.itemClassId)) { return(false); } } else { return(false); } if (r.MaxProductCount(rootNode.ms.id) < (rootNode.getCount / rootNode.ms.m_productItemCount)) { return(false); } return(true); }
public void UpdateOrAddScript(Pathea.Replicator.Formula ms, int multiple) { if (ms == null) { return; } ItemTrackData data = null; foreach (var nodeData in _nodeDataDic.Values) { if (nodeData.type == TrackType.Script && nodeData.scriptID == ms.id) { data = nodeData; break; } } bool needAdd = false; if (data == null) { data = new ItemTrackData(TrackType.Script); data.scriptID = ms.id; data.itemName = ItemProto.GetName(ms.productItemId); needAdd = true; } else { data.costDic.Clear(); } data.itemCount = multiple * ms.m_productItemCount; foreach (var item in ms.materials) { data.costDic.Add(item.itemId, item.itemCount * multiple); } if (needAdd) { AddTrackData(data); } }
//lz-2016.08.08 点击ScriptItem事件 private void ScriptItemEvent(int itemID, int scriptIndex) { if (!this.m_Formulas.ContainsKey(itemID) || scriptIndex >= this.m_Formulas[itemID].Count || scriptIndex < 0) { return; } //更改new的状态 Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scriptIndex]; Pathea.Replicator r = replicator; if (null != r) { r.SetKnownFormulaFlag(knownFornula.id); } //颜色根据选的脚本改变 List <GameObject> ListItems = m_LeftList.Gos; if (mListSelectedIndex >= 0 && mListSelectedIndex < ListItems.Count) { Pathea.Replicator.Formula formula = knownFornula.Get(); bool isInColony = (formula.workSpace != 0) ? true : false; Color textColor = isInColony ? Color.red : Color.white; UICompoundWndListItem listItem = ListItems[mListSelectedIndex].GetComponent <UICompoundWndListItem>(); listItem.SetTextColor(textColor); } //绘制当前选择的脚本和Item bool ok = ReDrawGraph(itemID, scriptIndex); if (ok) { AddGraphResetList(itemID); SetBottomInfo(); QueryGridItems(itemID); } }
private void QueryGridItems(int m_id) { mQureGridContentPos_x = 30; mQueryListFristIndex = 0; mQureGridContent.transform.localPosition = mQueryGridPos; m_QueryFormula.Clear(); Pathea.Replicator r = replicator; //lz-2016.10.20 避免数据错误报错 if (null != r) { foreach (Pathea.Replicator.KnownFormula kf in r.knowFormulas) { if (null != kf) { Pathea.Replicator.Formula f = kf.Get(); if (null != f && null != f.materials && f.materials.Count > 0) { for (int j = 0; j < f.materials.Count; j++) { if (f.materials[j].itemId == m_id) { m_QueryFormula.Add(f); break; } } } } } } m_QueryList.UpdateList(m_QueryFormula.Count, SetQueryListContent, ClearQueryListContent); UpdateQueryGridBtnState(); }
// Use this for initialization void Start() { m_MatItemList = new List <CSUI_MaterialGrid>(); if (m_Entity == null) { return; } if (null != PeCreature.Instance && null != PeCreature.Instance.mainPlayer) { m_PlayerPackageCmpt = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>(); } Tip = PELocalization.GetString(funcType == FuncType.Delete ? 82201081 : 82201082); //MergeSkill ms = MergeSkill.s_tblMergeSkills.Find( // delegate (MergeSkill hh) // { // return hh.m_productItemId == m_Entity.ItemID; // }); Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_Entity.ItemID); List <MaterialItem> miList = ItemProto.GetRepairMaterialList(m_Entity.ItemID); float percent = 0.0f; if (funcType == FuncType.Repair) { percent = (m_Entity.m_Info.m_Durability - m_Entity.BaseData.m_Durability) / m_Entity.m_Info.m_Durability; } else if (funcType == FuncType.Delete) { percent = m_Entity.BaseData.m_Durability / m_Entity.m_Info.m_Durability; } if (ms != null) { if (funcType == FuncType.Repair && miList != null && miList.Count > 0) { foreach (MaterialItem mi in miList) { int count = Mathf.CeilToInt(mi.count * percent); int playerCnt = m_PlayerPackageCmpt.package.GetCount(mi.protoId); CreateGrid(mi.protoId, playerCnt, count); if (playerCnt < count && funcType == FuncType.Repair) { m_OkBtn.isEnabled = false; } } } else { if (miList == null || miList.Count == 0) { Debug.LogError("no ItemProto.repairMaterialList:" + m_Entity.ItemID); } List <Pathea.Replicator.Formula.Material> m_MSMIlist = ms.materials; foreach (Pathea.Replicator.Formula.Material msmi in m_MSMIlist) { int count = Mathf.CeilToInt(msmi.itemCount * percent); int playerCnt = m_PlayerPackageCmpt.package.GetCount(msmi.itemId); CreateGrid(msmi.itemId, playerCnt, count); if (playerCnt < count && funcType == FuncType.Repair) { m_OkBtn.isEnabled = false; } } m_MatGridRoot.repositionNow = true; } } else { for (int i = 0; i < m_DefItemCostsId.Length; i++) { int count = Mathf.CeilToInt(m_DefItemCostsCnt[i] * percent); int playerCnt = m_PlayerPackageCmpt.package.GetCount(m_DefItemCostsId[i]); CreateGrid(m_DefItemCostsId[i], playerCnt, count); if (playerCnt < count && funcType == FuncType.Repair) { m_OkBtn.isEnabled = false; } } m_MatGridRoot.repositionNow = true; } }
// --------------------------------- // Func // --------------------------------- private bool ReDrawGraph(int itemID, int scirptIndex = 0) { if (FactoryReplicator == null) { return(false); } this.AddScriptItemData(itemID); if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0) { return(true); } UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl; if (m_RootType == ItemLabel.Root.ISO) { // Iso } else { if (itemID != -1) { //Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_id); Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex]; Pathea.Replicator.Formula ms = knownFornula.Get(); ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID); if (ms == null || item == null) { return(false); } FactoryReplicator.ClearGraph(); int level_v = 0; UIGraphNode root = graph_ctrl.AddGraphItem(level_v, null, ms, item.icon, "Icon"); root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID); root.mCtrl.ItemClick += this.OnGraphItemClick; for (int j = 0; j < ms.materials.Count; j++) { if (ms.materials[j].itemId != 0) { ItemProto item2 = ItemProto.GetItemData(ms.materials[j].itemId); string[] strico2 = item2.icon; UIGraphNode node = graph_ctrl.AddGraphItem(level_v, root, null, strico2, "Icon"); node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId); node.mCtrl.ItemClick += this.OnGraphItemClick; } } UpdateItemsTrackState(ms); } } // graph_ctrl.DrawGraph(); FactoryReplicator.DrawGraph(); return(true); }
void UpdateLeftList(bool useSearch = false) { if (null == m_Replicator) { return; } string queryText = FactoryReplicator.GetQueryString(); m_Formulas.Clear(); m_ItemDataList.Clear(); Dictionary <ItemProto, List <Pathea.Replicator.KnownFormula> > itemDic = new Dictionary <ItemProto, List <Pathea.Replicator.KnownFormula> >(); foreach (Pathea.Replicator.KnownFormula kf in m_Replicator.knowFormulas) { if (kf == null) { continue; } Pathea.Replicator.Formula f = kf.Get(); if (null == f) { continue; } ItemProto item = ItemProto.GetItemData(f.productItemId); if (item == null) { continue; } bool AddItem = false; if (m_RootType == ItemLabel.Root.ISO) { // Iso } else if (m_RootType == ItemLabel.Root.all || (m_RootType == item.rootItemLabel && (m_ItemType == 0 || m_ItemType == item.itemLabel))) { if (useSearch) { if (QueryItem(queryText, item.GetName())) { AddItem = true; } } else { AddItem = true; } } if (AddItem) { //lz-2016.08.09 这里要用Any()不能用Container() if (!itemDic.Keys.Any(a => a.id == item.id)) { itemDic.Add(item, new List <Replicator.KnownFormula>()); } ItemProto itemKey = itemDic.Keys.First(a => a.id == item.id); if (!itemDic[itemKey].Any(a => a.id == kf.id)) { itemDic[itemKey].Add(kf); } } } //lz-2016.08.08根据Item的Sort字段来排序 itemDic = itemDic.OrderBy(a => a.Key.sortLabel).ToDictionary(k => k.Key, v => v.Value); m_Formulas = itemDic.ToDictionary(k => k.Key.id, v => v.Value); m_ItemDataList = itemDic.Keys.ToList(); FactoryReplicator.m_MenuContent.gridList.UpdateList(m_ItemDataList.Count, SetMenuListItemContent, ClearMenuListItemContent); FactoryReplicator.m_MenuContent.scrollBox.m_VertScrollBar.scrollValue = 0; }
public bool _updateLeftList = true;//使更新不过于太频繁 //log:lz-2016.04.12: 这里加一个参数为了搜索和切换类型分开 public void UpdateLeftList(bool useSearch = false) { if (!_updateLeftList) { return; } _updateLeftList = false; mListSelectedIndex = -1; string queryText = mQueryInput.text; // replace some # queryText = queryText.Replace("*", ""); queryText = queryText.Replace("$", ""); queryText = queryText.Replace("(", ""); queryText = queryText.Replace(")", ""); queryText = queryText.Replace("@", ""); queryText = queryText.Replace("^", ""); queryText = queryText.Replace("[", ""); queryText = queryText.Replace("]", ""); //lz-2016.08.12 "\"增加字符过滤 queryText = queryText.Replace("\\", ""); //queryText = queryText.Replace(" ", ""); mQueryInput.text = queryText; m_Formulas.Clear(); m_ItemDataList.Clear(); Pathea.Replicator r = replicator; Dictionary <ItemProto, List <Pathea.Replicator.KnownFormula> > itemDic = new Dictionary <ItemProto, List <Pathea.Replicator.KnownFormula> >(); foreach (Pathea.Replicator.KnownFormula kf in r.knowFormulas) { if (kf == null) { continue; } Pathea.Replicator.Formula f = kf.Get(); if (null == f) { continue; } ItemProto item = ItemProto.GetItemData(f.productItemId); if (item == null) { continue; } bool AddItem = false; if (mRootType == ItemLabel.Root.ISO) { // Iso } else if (mRootType == ItemLabel.Root.all || (mRootType == item.rootItemLabel && (mItemType == 0 || mItemType == item.itemLabel))) { if (useSearch) { if (QueryItem(queryText, item.GetName())) { AddItem = true; } } else { AddItem = true; } } if (AddItem) { //lz-2016.08.09 这里要用Any()不能用Container() if (!itemDic.Keys.Any(a => a.id == item.id)) { itemDic.Add(item, new List <Replicator.KnownFormula>()); } ItemProto itemKey = itemDic.Keys.First(a => a.id == item.id); if (!itemDic[itemKey].Any(a => a.id == kf.id)) { itemDic[itemKey].Add(kf); } } } //lz-2016.08.08根据Item的Sort字段来排序 itemDic = itemDic.OrderBy(a => a.Key.sortLabel).ToDictionary(k => k.Key, v => v.Value); m_Formulas = itemDic.ToDictionary(k => k.Key.id, v => v.Value); m_ItemDataList = itemDic.Keys.ToList(); m_LeftList.UpdateList(m_ItemDataList.Count, SetLeftListContent, ClearLeftListContent); mListScrolBar.scrollValue = 0; }