public bool Create(int id) { if (MaterialModule.GetMaterialByMaterialID(id) == null) { return(false); } _id = id; return(true); }
public MaterialInfo(int id) { material = MaterialModule.GetMaterialByMaterialID(id); if (material != null) { ID = id; dataModel = new MaterialDataModel(); dataModel.Create(ID); mainType = MaterialModule.GetMaterialType(id); subType = MaterialModule.GetMaterialSubType(id); } }
public Dictionary <Material, ushort> GetOrderRewardMaterial(OrderContent.OrderReward reward) { Dictionary <Material, ushort> result = new Dictionary <Material, ushort>(); foreach (KeyValuePair <string, ushort> kvp in reward.Reward_Mateiral) { var ma = MaterialModule.GetMaterialByMaterialID(Utility.TryParseInt(kvp.Key)); if (ma != null) { result.Add(ma, kvp.Value); } } return(result); }
public Dictionary <Material, int> GetMaterialCost(DistrictData data) { Dictionary <Material, int> MaterialCostDic = new Dictionary <Material, int> (); Dictionary <int, int> cost = GetDistrictMaterialCostDic(data); foreach (KeyValuePair <int, int> kvp in cost) { Material ma = MaterialModule.GetMaterialByMaterialID(kvp.Key); if (ma != null) { MaterialCostDic.Add(ma, kvp.Value); } } return(MaterialCostDic); }
/// <summary> /// 获取建造材料消耗 /// </summary> /// <param name="data"></param> /// <returns></returns> public Dictionary <Material, ushort> GetBuildMaterialCost(BuildingPanelData data) { Dictionary <Material, ushort> result = new Dictionary <Material, ushort>(); List <string> maList = Utility.TryParseStringList(data.MaterialCost, ','); for (int i = 0; i < maList.Count; i++) { List <int> str = Utility.TryParseIntList(maList[i], ':'); if (str.Count != 2) { Debug.LogError("BuildPanel Parse Error , ID=" + data.BuildID); return(result); } result.Add(MaterialModule.GetMaterialByMaterialID(str[0]), (ushort)str[1]); } return(result); }
/// <summary> /// 获取原料列表 /// </summary> /// <param name="formulaID"></param> /// <param name="Gettype"></param> /// <returns></returns> public static List <FormulaItem> GetFormulaItemList(int formulaID, MaterialProductType Gettype) { List <FormulaItem> result = new List <FormulaItem>(); Dictionary <int, ushort> infoDic = GetFormulaMaterialList(formulaID, Gettype); if (infoDic.Count == 0) { return(result); } if (infoDic != null) { foreach (KeyValuePair <int, ushort> kvp in infoDic) { Material ma = MaterialModule.GetMaterialByMaterialID(kvp.Key); FormulaItem item = new FormulaItem(ma, kvp.Value); result.Add(item); } } return(result); }
public void SetUpItem(GeneralRewardItem item) { _item = item; if (item.type == GeneralRewardItem.RewardType.Material) { if (MaterialModule.GetMaterialByMaterialID(item.ItemID) != null) { var icon = MaterialModule.GetMaterialSprite(item.ItemID); _icon.sprite = icon; _count.text = item.count.ToString(); } } else if (item.type == GeneralRewardItem.RewardType.Tech_Unlock) { if (TechnologyModule.GetTechDataByID(item.ItemID) != null) { var icon = TechnologyModule.GetTechIcon(item.ItemID); _icon.sprite = icon; } } }
public static Dictionary <int, int> parseTechParam_Require_Material(string content) { Dictionary <int, int> result = new Dictionary <int, int>(); var list = Utility.TryParseStringList(content, ','); for (int i = 0; i < list.Count; i++) { var countList = Utility.TryParseIntList(list[i], ':'); if (countList.Count != 2) { Debug.LogError("Parse TechRequire Error! content=" + content); break; } var maData = MaterialModule.GetMaterialByMaterialID(countList[0]); if (maData != null) { result.Add(countList[0], countList[1]); } } return(result); }
public void AddMaterialStoreData(int materialID, ushort count) { Action <MaterialStorageItem> sendMsg = (m) => { UIManager.Instance.SendMessage(new UIMessage(UIMsgType.UpdateWarehouseData, new List <object>(1) { m })); }; if (materialStorageDataDic.ContainsKey(materialID)) { var maCount = materialStorageDataDic[materialID]; maCount += count; //if (maCount > material.info.material.BlockCapacity) //{ // //超出上限 ,TODO // sendMsg(material); //} //else if (material.count <= 0) //{ // materialStorageDataDic.Remove(materialID); //} //else //{ // sendMsg(material); //} } else { if (MaterialModule.GetMaterialByMaterialID(materialID) != null) { materialStorageDataDic.Add(materialID, count); //sendMsg(data); } } }
/// <summary> /// 事件触发前置 /// </summary> /// <param name="eventID"></param> /// <returns></returns> public static bool CheckEventTrigger(int eventID) { var playerData = GetExploreEventConfigData(eventID).trigger.player; ///Check GlobalFlag var trigger = GetExploreEventGlobalFlag(eventID); if (trigger != null) { foreach (KeyValuePair <string, bool> kvp in trigger) { if (!GlobalEventManager.Instance.CheckGlobalFlagExist(kvp.Key) == kvp.Value) { return(false); } } } ///Currency if (playerData != null) { if (!string.IsNullOrEmpty(playerData.CurrencyCompare)) { if (!Utility.ParseGeneralCompare(playerData.CurrencyValue, playerData.CurrencyCompare)) { return(false); } } if (playerData.Material != null) { foreach (KeyValuePair <string, string> kvp in playerData.Material) { int materialID = Utility.TryParseInt(kvp.Key); if (MaterialModule.GetMaterialByMaterialID(materialID) != null) { if (!Utility.ParseGeneralCompare(PlayerManager.Instance.GetMaterialStoreCount(materialID), kvp.Value)) { return(false); } } } } if (playerData.Technology != null) { foreach (KeyValuePair <string, string> kvp in playerData.Technology) { int techID = Utility.TryParseInt(kvp.Value); if (TechnologyModule.GetTechDataByID(techID) != null) { var techData = TechnologyDataManager.Instance.GetTechInfo(techID); if (techData != null) { if (string.Compare(kvp.Value, "Complete") == 0) { if (techData.currentState != TechnologyState.Done) { return(false); } } else if (string.Compare(kvp.Value, "Lock") == 0) { if (techData.currentState != TechnologyState.Lock) { return(false); } } else { Debug.LogError("ExploreEvent Tech Format Error! EventID=" + eventID); } } } } } } /// CheckPre Event var preList = GetExploreEventConfigData(eventID).trigger.PreEvent; if (preList != null) { for (int i = 0; i < preList.Count; i++) { if (ExploreEventManager.Instance.CheckRandomEventFinish(eventID) == false) { return(false); } } } return(true); }