//lz-2016.08.08 通过ItemID找到所有可以合成这个Item的脚本 private void AddScriptItemData(int itemID) { if (!this.m_Formulas.ContainsKey(itemID)) { List <Pathea.Replicator.Formula> formulaList = Pathea.Replicator.Formula.Mgr.Instance.FindAllByProDuctID(itemID); if (null == formulaList || formulaList.Count <= 0) { return; } List <Pathea.Replicator.KnownFormula> knownFormulaList = new List <Replicator.KnownFormula>(); for (int i = 0; i < formulaList.Count; i++) { Pathea.Replicator.KnownFormula knownFormula = UIGraphControl.GetReplicator().GetKnownFormula(formulaList[i].id); if (null != knownFormula) { knownFormulaList.Add(knownFormula); } } ItemProto item = ItemProto.GetItemData(itemID); this.m_ItemDataList.Add(item); this.m_Formulas.Add(itemID, knownFormulaList); } if (this.m_Formulas.ContainsKey(itemID) && itemID != this.m_CurItemID) { this.UpdateCurItemScriptList(itemID); this.SelectFirstScritItem(false); } }
// Update is called once per frame void Update() { if (m_RefCommon == null) { return; } m_NameUI.text = m_RefCommon.Name; ItemProto itemData = ItemProto.GetItemData(m_RefCommon.ItemID); if (itemData != null) { string[] iconStr = ItemProto.GetItemData(m_RefCommon.ItemID).icon; if (iconStr.Length != 0) { m_IconUI.spriteName = iconStr[0]; } else { m_IconUI.spriteName = ""; } } float percent = m_RefCommon.BaseData.m_Durability / m_RefCommon.m_Info.m_Durability; m_LifeProgressUI.sliderValue = percent; string str = ""; str += Mathf.RoundToInt(m_RefCommon.BaseData.m_Durability).ToString(); str += " / "; str += Mathf.RoundToInt(m_RefCommon.m_Info.m_Durability).ToString(); m_LifeUI.text = str; }
void UpdateBuyItemList(ItemLabel.Root _type) { //lz-2016.01.03 crash bug 错误 #8074 if (mTypeOfBuyItemList == null || null == mBuyItemList || null == m_TypeShopIDList || null == m_ShopIDList) { return; } mTypeOfBuyItemList.Clear(); for (int i = 0; i < mBuyItemList.Count; i++) { if (_type == ItemLabel.Root.all) { mTypeOfBuyItemList.Add(mBuyItemList[i]); } else { //lz-2017.02.27 错误 #9323 crash bug if (null != mBuyItemList[i] && null != mBuyItemList[i].protoData && null != mBuyItemList[i].protoData) { ItemLabel.Root roottype = mBuyItemList[i].protoData.rootItemLabel; if (roottype == _type) { mTypeOfBuyItemList.Add(mBuyItemList[i]); } } } } m_TypeShopIDList.Clear(); for (int i = 0; i < m_ShopIDList.Count; i++) { if (_type == ItemLabel.Root.all) { m_TypeShopIDList.Add(m_ShopIDList[i]); } else { ShopData sd = ShopRespository.GetShopData(m_ShopIDList[i]); if (sd == null) { continue; } ItemProto data = ItemProto.GetItemData(sd.m_ItemID); if (null != data) { ItemLabel.Root roottype = data.rootItemLabel; if (roottype == _type) { m_TypeShopIDList.Add(m_ShopIDList[i]); } } } } }
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); }
// Update is called once per frame void Update() { if (m_RefNpc == null) { return; } if (m_RefNpc != null) { if (m_RefNpc.WorkRoom == m_RefCommon) { m_NPCCntLb.color = m_LivingColor; m_BuildingNameLb.color = m_LivingColor; } else { m_NPCCntLb.color = m_NormalColor; m_BuildingNameLb.color = m_NormalColor; } } if (m_RefCommon == null) { return; } int npcCount = m_RefCommon.WorkerCount; int npcMaxCount = m_RefCommon.WorkerMaxCount; m_NPCCntLb.text = "[" + m_RefCommon.WorkerCount + "/" + m_RefCommon.WorkerMaxCount + "]"; ItemProto itemData = ItemProto.GetItemData(m_RefCommon.ItemID); if (itemData != null) { string[] iconStr = ItemProto.GetItemData(m_RefCommon.ItemID).icon; if (iconStr.Length != 0) { m_IconSprite.spriteName = iconStr[0]; } else { m_IconSprite.spriteName = ""; } } m_BuildingNameLb.text = m_RefCommon.Name; if (npcCount >= npcMaxCount || !m_Active) { m_LivingBtn.isEnabled = false; } else { m_LivingBtn.isEnabled = true; } }
public bool Destroy(int prototypeId, int count) { ItemProto itemData = ItemProto.GetItemData(prototypeId); if (itemData.category == quest_item) { return(_missionPak.Destroy(prototypeId, count)); } else { return(_playerPak.Destroy(prototypeId, count)); } }
public bool Add(int prototypeId, int count, bool newFlag = false) { ItemProto itemData = ItemProto.GetItemData(prototypeId); if (itemData.category == quest_item) { return(_missionPak.Add(prototypeId, count, newFlag)); } else { return(_playerPak.Add(prototypeId, count, newFlag)); } }
void SetQueryListContent(int index, GameObject go) { UIGridItemCtrl grid = go.GetComponent <UIGridItemCtrl>(); grid.mIndex = index; grid.SetToolTipInfo(ListItemType.mItem, m_QueryFormula[index].productItemId); grid.mItemClick -= GridListItemOnClick; grid.mItemClick += GridListItemOnClick; ItemProto item = ItemProto.GetItemData(m_QueryFormula[index].productItemId); grid.SetCotent(item.icon); }
public static void RPC_S2C_RequestUGCData(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int[] objIDs = stream.Read <int[]>(); foreach (int id in objIDs) { CreationData data = CreationMgr.GetCreation(id); if (null == data) { CreationOriginData cData = CreationList.Find(iter => iter.ObjectID == id); if (cData != null) { CreationMgr.NewCreation(cData.ObjectID, cData.HashCode, (float)cData.Seed); } else { MessageBox_N.ShowOkBox(PELocalization.GetString(8000500)); LogManager.Error("Creation item create failed. ID:" + id); GameClientNetwork.Disconnect(); } return; } ItemProto item = ItemProto.GetItemData(id); if (null != item) { byte[] itemData = ItemProto.GetBuffer(item); NetworkManager.SyncServer(EPacketType.PT_Common_UGCItem, id, itemData); var components = from component in data.m_IsoData.m_Components where VCUtils.IsSeat(component.m_Type) select(int) component.m_Type; float hp = data.m_Attribute.m_Durability; float energy = data.m_Attribute.m_MaxFuel; if (components.Count() >= 1) { NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy, data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), true, components.ToArray()); } else { NetworkManager.SyncServer(EPacketType.PT_Common_UGCData, id, hp, energy, data.m_Attribute.m_Cost.Keys.ToArray(), data.m_Attribute.m_Cost.Values.ToArray(), false); } } } }
// Update is called once per frame void Update() { //lz-2016.10.14 m_Factory空对象 if (FactoryReplicator == null || null == m_Factory) { return; } UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl; if (graph_ctrl.isCanCreate()) { FactoryReplicator.m_RightContent.compoundBtn.isEnabled = true; } else { FactoryReplicator.m_RightContent.compoundBtn.isEnabled = false; } // Queue for (int i = 0; i < m_CompoudItems.Count; i++) { if (i < m_Factory.CompoudItemsCount) { ItemProto data = ItemProto.GetItemData(m_Factory.Data.m_CompoudItems[i].itemID); string[] iconStr = data.icon; if (iconStr.Length != 0) { m_CompoudItems[i].IcomName = iconStr[0]; } else { m_CompoudItems[i].IcomName = ""; } m_CompoudItems[i].Count = m_Factory.Data.m_CompoudItems[i].itemCnt; m_CompoudItems[i].SliderValue = m_Factory.Data.m_CompoudItems[i].curTime / m_Factory.Data.m_CompoudItems[i].time; m_CompoudItems[i].ShowSlider = true; } else { m_CompoudItems[i].IcomName = "Null"; m_CompoudItems[i].Count = 0; m_CompoudItems[i].SliderValue = 0; m_CompoudItems[i].ShowSlider = false; } } }
void _createQueryItems(int ID) { GameObject go = FactoryReplicator.InstantiateQueryItem(""); UIGridItemCtrl grid = go.GetComponent <UIGridItemCtrl>(); grid.SetToolTipInfo(ListItemType.mItem, ID); UIEventListener el = go.GetComponent <UIEventListener>(); el.onClick = OnQueryGridItemClick; ItemProto item = ItemProto.GetItemData(ID); grid.SetCotent(item.icon); }
public bool ContainsItem(int prototypeId) { ItemProto itemData = ItemProto.GetItemData(prototypeId); if (itemData == null) { return(false); } if (itemData.category == quest_item) { return(_missionPak.ContainsItem(prototypeId)); } else { return(_playerPak.ContainsItem(prototypeId)); } }
//public void DeleteItem(ItemObject itemObj) //{ // if (itemObj == null) // return; // if (itemObj.protoData.category == quest_item) // { // _missionPak.RemoveItem(itemObj); // ItemManager.RemoveItem(itemObj.instanceId); // } // else // { // _playerPak.RemoveItem(itemObj); // ItemManager.RemoveItem(itemObj.instanceId); // } //} //internal void RemoveItem(int itemID, int count, ref List<ItemObject> effItems) //{ // ItemProto itemData = ItemProto.GetItemData(itemID); // if (null == itemData) // return; // if (itemData.category == ItemCategory.IC_QuestItem) // { // _missionPak.RemoveItem(itemID, count, ref effItems); // } // else // { // _playerPak.RemoveItem(itemID, count, ref effItems); // } //} //internal ItemObject[] RemoveItem(IEnumerable<ItemSample> items) //{ // var finalItems = new List<ItemObject>(10); // foreach (ItemSample item in items) // RemoveItem(item.protoId, item.stackCount, ref finalItems); // return finalItems.ToArray(); //} //internal void AddSameItems(int itemID, int count, ref List<ItemObject> effItems) //{ // ItemProto itemData = ItemProto.GetItemData(itemID); // if (null == itemData) // return; // if (itemData.category == ItemCategory.IC_QuestItem) // _missionPak.AddSameItems(itemID, count, ref effItems); // else // _playerPak.AddSameItems(itemID, count, ref effItems); //} //internal ItemObject[] AddSameItems(IEnumerable<ItemSample> items) //{ // if (!CanAdd(items)) // return null; // var finalItems = new List<ItemObject>(10); // foreach (ItemSample iter in items) // { // if (iter.protoData.category == ItemCategory.IC_QuestItem) // _missionPak.AddSameItems(iter, ref finalItems); // else // _playerPak.AddSameItems(iter, ref finalItems); // } // return finalItems.ToArray(); //} //internal void AddSameItems(ItemSample item, ref List<ItemObject> effItems) //{ // AddSameItems(item.protoId, item.stackCount, ref effItems); //} //public ItemObject GetItemById(int objId) //{ // ItemObject item = ItemManager.GetItemByID(objId); // if (item == null) // return null; // if (item.protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.GetItemById(objId); // else // return _playerPak.GetItemById(objId); //} //public int RemoveItem(ItemObject itemObj) //{ // if (null == itemObj) // return -1; // if (itemObj.protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.RemoveItem(itemObj); // else // return _playerPak.RemoveItem(itemObj); //} //public List<ItemObject> GetValidItemList(int type) //{ // return _playerPak.GetValidItemList(type); //} //public byte[] GetChangedIndex() //{ // return _playerPak.GetChangedIndex(); //} //internal IEnumerable<int> GetItemObjIDs(int tab) //{ // return _playerPak.GetItemObjIDs(tab); //} //public void ExtendPackage(int itemMax, int equipmentMax, int resourceMax, int armorMax) //{ // _playerPak.ExtendPackage(itemMax, equipmentMax, resourceMax, armorMax); //} //public int AddItem(ItemObject item, int index) //{ // if (!CanAdd(item)) // return -1; // if (item.protoData.category == ItemCategory.IC_QuestItem) // { // return _missionPak.AddItem(item, index); // } // else // { // return _playerPak.AddItem(item, index); // } //} //public bool CanAdd(IEnumerable<ItemSample> items) //{ // foreach (ItemObject iter in items) // { // if (iter.protoData.category == ItemCategory.IC_QuestItem) // if (!_missionPak.CanAdd(iter)) // return false; // else // if (!_playerPak.CanAdd(iter)) // return false; // } // return true; //} //public bool CanAdd(ItemObject item) //{ // if (item == null) // return false; // if (item.protoData.category == ItemCategory.IC_QuestItem) // { // return _missionPak.CanAdd(item); // } // else // { // return _playerPak.CanAdd(item); // } //} //public bool CanAdd(ItemSample item) //{ // return CanAdd(item.protoId, item.stackCount); //} //public bool CanAdd(int itemId, int num) //{ // ItemProto itemData = ItemProto.GetItemData(itemId); // if (null == itemData) // return false; // if (itemData.category == ItemCategory.IC_QuestItem) // { // return _missionPak.CanAdd(itemId, num); // } // else // { // return _playerPak.CanAdd(itemId, num); // } //} //public void AddItemList(IEnumerable<ItemObject> items) //{ // foreach (ItemObject iter in items) // { // if (iter.protoData.category == ItemCategory.IC_QuestItem) // _missionPak.AddItem(iter, -1); // else // _playerPak.AddItem(iter, -1); // } //} //public int GetEmptyGridCount(ItemProto protoData) //{ // if (protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.GetEmptyGridCount(protoData.tabIndex); // else // return _playerPak.GetEmptyGridCount(protoData.tabIndex); //} //public ItemObject[] Sort(int type) //{ // return _playerPak.Sort(type); //} //public bool HasEnoughItems(IEnumerable<ItemSample> items) //{ // foreach (ItemSample item in items) // { // if (null == item || -1 == item.protoId) // continue; // if (item.protoData.category == ItemCategory.IC_QuestItem) // if (!_missionPak.HasEnoughItems(items)) // return false; // else // if (!_playerPak.HasEnoughItems(items)) // return false; // } // return true; //} //public ItemObject GetItemByIndex(int idx, int type) //{ // return _playerPak.GetItemByIndex(idx, type); //} //internal bool ExistID(ItemObject item) //{ // if (null == item) // return false; // if (item.protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.ExistID(item); // else // return _playerPak.ExistID(item); //} //internal bool ExistID(int objID) //{ // ItemObject itemObj = ItemManager.GetItemByID(objID); // if (null == itemObj) // { // return false; // } // if (itemObj.protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.ExistID(objID); // else // return _playerPak.ExistID(objID); //} //public int GetEmptyIndex(ItemProto protoData) //{ // if (protoData == null) // return -1; // if (protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.GetEmptyIndex(protoData.tabIndex); // else // return _playerPak.GetEmptyIndex(protoData.tabIndex); //} //public int ItemNotBindCount() //{ // return _playerPak.ItemNotBindCount(); //} //public List<ItemObject> GetValidItemListNotBind(int type) //{ // return _playerPak.GetValidItemListNotBind(type); //} //public int GetItemCount(int itemId) //{ // ItemProto proto = ItemProto.GetItemData(itemId); // if (proto == null) // return -1; // if (proto.category == ItemCategory.IC_QuestItem) // return _missionPak.GetItemCount(itemId); // else // return _playerPak.GetItemCount(itemId); //} //public bool HasEnoughSpace(List<MissionIDNum> missionItems) //{ // int itemcount = 0; // int equipcount = 0; // int resourcescount = 0; // int armorcount = 0; // int mItemcount = 0; // int mEquipcount = 0; // int mResourcescount = 0; // int mArmorcount = 0; // int itemempty = _playerPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Item); // int equipempty = _playerPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Equipment); // int resourcesempty = _playerPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Resource); // int armorempty = _playerPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Armor); // int mItemempty = _missionPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Item); // int mEquipempty = _missionPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Equipment); // int mResourcesempty = _missionPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Resource); // int mArmorempty = _missionPak.GetEmptyGridCount((int)ItemPackage.ESlotType.Armor); // for (int i = 0; i < missionItems.Count; i++) // { // ItemProto itemdata = ItemProto.GetItemData(missionItems[i].id); // if (itemdata == null) // continue; // if (itemdata.category == ItemCategory.IC_QuestItem) // { // if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Item) // { // if (itemdata.maxStackNum > 0) // mItemcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Equipment) // { // if (itemdata.maxStackNum > 0) // mEquipcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Resource) // { // if (itemdata.maxStackNum > 0) // mResourcescount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Armor) // { // if (itemdata.maxStackNum > 0) // mArmorcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // } // else // { // if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Item) // { // if (itemdata.maxStackNum > 0) // itemcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Equipment) // { // if (itemdata.maxStackNum > 0) // equipcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Resource) // { // if (itemdata.maxStackNum > 0) // resourcescount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // else if (itemdata.tabIndex == (int)ItemPackage.ESlotType.Armor) // { // if (itemdata.maxStackNum > 0) // armorcount += ((missionItems[i].num - 1) / itemdata.maxStackNum) + 1; // } // } // } // if (itemcount > itemempty || equipcount > equipempty || resourcescount > resourcesempty || armorcount > armorempty) // return false; // if (mItemcount > mItemempty || mEquipcount > mEquipempty || mResourcescount > mResourcesempty || mArmorcount > mArmorempty) // return false; // return true; //} //public int GetItemIndex(ItemObject item) //{ // if (item == null) // return -1; // if (item.protoData.category == ItemCategory.IC_QuestItem) // return _missionPak.GetItemIndex(item); // else // return _playerPak.GetItemIndex(item); //} //public void Clear(ItemPackage.ESlotType type = ItemPackage.ESlotType.Max) //{ // _playerPak.Clear(type); // _missionPak.Clear(type); //} #endregion #region Helper public int GetCount(int prototypeId) { ItemProto itemData = ItemProto.GetItemData(prototypeId); if (itemData == null) { return(0); } if (itemData.category == quest_item) { return(_missionPak.GetCount(prototypeId)); } else { return(_playerPak.GetCount(prototypeId)); } }
public SlotList GetSlotList(int prototypeId) { ItemProto itemData = ItemProto.GetItemData(prototypeId); if (itemData == null) { return(null); } if (itemData.category == quest_item) { return(_missionPak.GetSlotList(ItemPackage.GetSlotType(prototypeId))); } else { return(_playerPak.GetSlotList(ItemPackage.GetSlotType(prototypeId))); } }
public ItemObject FindItemByProtoId(int itemId) { ItemProto itemData = ItemProto.GetItemData(itemId); if (null == itemData) { return(null); } if (itemData.category == quest_item) { return(_missionPak.FindItemByProtoId(itemId)); } else { return(_playerPak.FindItemByProtoId(itemId)); } }
private void SetBottomInfo() { UIGraphNode rootNode = mGraphCtrl.rootNode; if (rootNode.mCtrl.mContentSprites[0].gameObject.activeSelf) { int m_id = rootNode.GetItemID(); ItemProto item = ItemProto.GetItemData(m_id); mButtomGrid.SetCotent(item.icon); mButtomGrid.SetToolTipInfo(ListItemType.mItem, m_id); } else { mButtomGrid.SetCotent(rootNode.mCtrl.mContentTexture.mainTexture); mButtomGrid.SetToolTipInfo(ListItemType.mItem, rootNode.GetItemID()); } mBottomCountLb.text = rootNode.ms.m_productItemCount.ToString(); }
void _setCompundInfo(int id) { UIGraphNode rootNode = FactoryReplicator.m_MiddleContent.graphCtrl.rootNode; if (rootNode.mCtrl.mContentSprites[0].gameObject.activeSelf) { int m_id = rootNode.GetItemID(); ItemProto item = ItemProto.GetItemData(m_id); m_RightGridItem.SetCotent(item.icon); m_RightGridItem.SetToolTipInfo(ListItemType.mItem, m_id); } else { m_RightGridItem.SetCotent(rootNode.mCtrl.mContentTexture.mainTexture); m_RightGridItem.SetToolTipInfo(ListItemType.mItem, rootNode.GetItemID()); } FactoryReplicator.m_RightContent.countInput.text = rootNode.ms.m_productItemCount.ToString(); }
public void ResetPackageItems(int tab, int[] ids) { if (ids.Any(delegate(int tmp) { ItemProto protoData = ItemProto.GetItemData(tmp); if (protoData.category == quest_item) { return(true); } return(false); })) { _missionPak.ResetPackageItems(tab, ids); } else { _playerPak.ResetPackageItems(tab, ids); } }
public bool Add(IEnumerable <ItemAsset.MaterialItem> list) { if (list.Any(delegate(ItemAsset.MaterialItem tmp) { ItemProto itemData = ItemProto.GetItemData(tmp.protoId); if (itemData.category == quest_item) { return(true); } return(false); })) { return(_missionPak.Add(list)); } else { return(_playerPak.Add(list)); } }
public void Init(BlockBuilding building, Block45CurMan perfab) { mBlockBuilding = building; Vector3 size; List <Vector3> npcPosition; List <CreatItemInfo> itemList; Dictionary <int, BuildingNpc> npcIdNum; mBlockBuilding.GetBuildingInfo(out size, out mBlocks, out npcPosition, out itemList, out npcIdNum); BoxCollider col = gameObject.AddComponent <BoxCollider>(); col.center = 0.5f * size + 0.5f * Vector3.up; col.size = size; mB45Building = Instantiate(perfab) as Block45CurMan; mB45Building.transform.parent = transform; mB45Building.transform.localPosition = Vector3.zero; mB45Building.transform.localRotation = Quaternion.identity; mB45Building.transform.localScale = Vector3.one; Invoke("BuildBuilding", 0.5f); foreach (CreatItemInfo item in itemList) { ItemProto itemData = ItemProto.GetItemData(item.mItemId); // AssetBundleReq req = AssetBundlesMan.Instance.AddReq(itemData.m_ModelPath, Vector3.zero, Quaternion.identity); // req.ReqFinishWithReqHandler += OnSpawned; // mReqList[req] = item; GameObject go = Instantiate(Resources.Load(itemData.resourcePath)) as GameObject; go.transform.parent = transform; go.transform.transform.localPosition = item.mPos; go.transform.transform.localRotation = item.mRotation; go.transform.transform.localScale = Vector3.one; } }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtFactory, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtFactory, ref ddata); } m_Data = ddata as CSFactoryData; if (isNew) { Data.m_Name = CSUtils.GetEntityName(m_Type); Data.m_Durability = Info.m_Durability; } else { StartRepairCounter(Data.m_CurRepairTime, Data.m_RepairTime, Data.m_RepairValue); StartDeleteCounter(Data.m_CurDeleteTime, Data.m_DeleteTime); // Clear old record for (int i = 0; i < Data.m_CompoudItems.Count;) { ItemProto item_data = ItemProto.GetItemData(Data.m_CompoudItems[i].itemID); if (item_data == null) { Data.m_CompoudItems.RemoveAt(i); } else { i++; } } } }
void OnLoadBtn() { if (mFileName.text == "") { return; } string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/"; if (!Directory.Exists(_strFilePath)) { Directory.CreateDirectory(_strFilePath); } for (int i = 0; i < mItemList.Count; i++) { Destroy(mItemList[i].gameObject); } mItemList.Clear(); for (int i = 0; i < mNpcList.Count; i++) { Destroy(mNpcList[i].gameObject); } mNpcList.Clear(); if (null != Block45Man.self.DataSource) { Block45Man.self.DataSource.Clear(); } if (File.Exists(_strFilePath + mFileName.text + ".txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + ".txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int readVersion = _in.ReadInt32(); switch (readVersion) { case 2: int Size = _in.ReadInt32(); for (int i = 0; i < Size; i++) { IntVector3 index = new IntVector3(_in.ReadInt32(), _in.ReadInt32(), _in.ReadInt32()); Block45Man.self.DataSource.SafeWrite(new B45Block(_in.ReadByte(), _in.ReadByte()), index.x, index.y, index.z, 0); } break; } _in.Close(); } } if (File.Exists(_strFilePath + mFileName.text + "SubInfo.txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + "SubInfo.txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int version = _in.ReadInt32(); int count = _in.ReadInt32(); switch (version) { case 1: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } break; case 2: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } count = _in.ReadInt32(); for (int i = 0; i < count; i++) { Vector3 itemPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); Quaternion ItemRot = Quaternion.Euler(new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle())); int itemID = _in.ReadInt32(); ItemProto itemData = ItemProto.GetItemData(itemID); if (null == itemData || !itemData.IsBlock()) { continue; } CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.ItemSetting; req.mItemId = itemID; // req.mReq = AssetBundlesMan.Instance.AddReq(ItemData.GetItemData(itemID).m_ModelPath, itemPos, ItemRot); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load(ItemProto.GetItemData(itemID).resourcePath)) as GameObject; obj.transform.position = itemPos; obj.transform.localRotation = ItemRot; CreateMode(obj, req); // CreateMode(Instantiate(Resources.Load(ItemData.GetItemData(itemID).m_ModelPath)) as GameObject, req); } break; } _in.Close(); } } }
void RPC_S2C_FCT_Fetch(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int itemId = stream.Read <int>(); bool succ = stream.Read <bool>(); if (succ) { //1.success UI CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayCompoundItem.GetString(), ItemProto.GetItemData(itemId).GetName())); } }
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; }
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; }
// --------------------------------- // Callback // --------------------------------- void OnCompoudClick(CSUI_CompoundItem ci) { if (!GameConfig.IsMultiMode) { int index = m_CompoudItems.FindIndex(item0 => item0 == ci); if (index != -1) { if (!CSUI_MainWndCtrl.IsWorking()) { return; } if (m_Factory.CompoudItemsCount <= index) { return; } Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>(); if (pkg == null) { Debug.LogError("CSUI_Factory.OnCompoundClick: pkg is null!"); return; } CompoudItem ci_data = null; ItemProto item_data; if (!m_Factory.GetTakeAwayCompoundItem(index, out ci_data)) { if (ci_data != null) { item_data = ItemProto.GetItemData(ci_data.itemID); CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mIsCompounding.GetString(), item_data.GetName()), Color.red); } return; } item_data = ItemProto.GetItemData(ci_data.itemID); int pacakgeEmptyCount = pkg.package.GetSlotList(ci_data.itemID).vacancyCount; if (!pkg.package.CanAdd(m_Factory.Data.m_CompoudItems[index].itemID, ci.Count)) { // Status bar //lz-2016.07.16 背包空间不足这条提示是基地复制器和玩家复制器通用的,在基地用的时候,基地的提示只能显示一行,不能换行 string tip = PELocalization.GetString(8000050).Replace("\\n", " "); CSUI_MainWndCtrl.ShowStatusBar(tip, Color.red); if (item_data.maxStackNum > 1 || pacakgeEmptyCount == 0) { return; } } int originalCount = ci_data.itemCnt; int addCount = originalCount; if (item_data.maxStackNum > 1) { pkg.Add(ci_data.itemID, ci_data.itemCnt); } else { if (originalCount > pacakgeEmptyCount) { addCount = pacakgeEmptyCount; } pkg.Add(ci_data.itemID, addCount); } ci_data.itemCnt = originalCount - addCount; if (ci_data.itemCnt == 0) { m_Factory.TakeAwayCompoudItem(index); CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayCompoundItem.GetString(), item_data.GetName())); } } } else { int index = m_CompoudItems.FindIndex(item0 => item0 == ci); if (index != -1) { if (m_Factory.CompoudItemsCount <= index || m_Factory.Data.m_CompoudItems[index] == null || m_Factory.Data.m_CompoudItems[index].curTime < m_Factory.Data.m_CompoudItems[index].time) { return; } m_Factory._ColonyObj._Network.FCT_Fetch(index); } } }
// --------------------------------- // 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); }
public void OnCompoundBtnClickSuccess(int item_id, CSFactory entity) { if (m_Factory == entity) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mJoinCompoudingQueue.GetString(), ItemProto.GetItemData(item_id).GetName())); } }
void OnCompoundBtnClick(GameObject go) { if (!GameConfig.IsMultiMode) { UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl; if (!graph_ctrl.isCanCreate()) { return; } int item_id = graph_ctrl.rootNode.GetItemID(); int item_num = graph_ctrl.rootNode.getCount; //lz-2016.09.26 时间使用份数计算的,所有要除掉productItemCount float time = graph_ctrl.rootNode.ms.timeNeed * item_num / graph_ctrl.rootNode.ms.m_productItemCount; if (RandomMapConfig.useSkillTree) { if (GameUI.Instance.mSkillWndCtrl._SkillMgr != null) { time = GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckReduceTime((float)time); } } if (m_Factory.SetCompoudItem(item_id, item_num, time)) { for (int i = 0; i < graph_ctrl.mGraphItemList.Count; i++) { if (graph_ctrl.mGraphItemList[i].mPartent == graph_ctrl.rootNode) { PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>().package.Destroy(graph_ctrl.mGraphItemList[i].GetItemID(), graph_ctrl.mGraphItemList[i].needCount); } } // Status bar CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mJoinCompoudingQueue.GetString(), ItemProto.GetItemData(item_id).GetName())); //.... if (GameUI.Instance.mItemPackageCtrl != null) { GameUI.Instance.mItemPackageCtrl.ResetItem(); } } } else { UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl; if (!graph_ctrl.isCanCreate()) { return; } int skill_id = graph_ctrl.rootNode.ms.id; //lz-2016.09.26 多人的接口需要的是productCount int productCount = graph_ctrl.rootNode.getCount / graph_ctrl.rootNode.ms.m_productItemCount; //to do--skillid,num if (m_Factory.Data.m_CompoudItems.Count >= CSFactory.c_CompoudItemCount) { return; } //lz-2016.09.26 多人的接口需要的是productCount m_Factory._ColonyObj._Network.FCT_Compoud(skill_id, productCount); } }