public static bool HasEnoughResource(DataUnit.BasicCost cost) { if (cost.costFood > InstancePlayer.instance.model_User.model_Resource.GetIntFood()) { return(false); } if (cost.costOil > InstancePlayer.instance.model_User.model_Resource.GetIntOil()) { return(false); } if (cost.costRare > InstancePlayer.instance.model_User.model_Resource.GetIntRare()) { return(false); } if (cost.costMetal > InstancePlayer.instance.model_User.model_Resource.GetIntMetal()) { return(false); } if (cost.costCash > InstancePlayer.instance.model_User.model_Resource.GetIntCash()) { return(false); } return(true); }
public void Load(LitJson.JSONNode json) { type = JsonReader.Int(json, "Type"); id = JsonReader.Int(json, "ID"); level = JsonReader.Int(json, "Level"); playerLevel = JsonReader.Int(json, "PlayerLevel"); openLevel = JsonReader.Int(json, "OpenLevel"); string str_buildingID = json ["BuildingID"]; buildingID = StringHelper.ReadIntArrayFromString(str_buildingID); string str_buildingLevel = json ["BuildingLevel"]; buildingLevel = StringHelper.ReadIntArrayFromString(str_buildingLevel); upgradeCash = JsonReader.Float(json, "UpgradeCash"); categoryId = JsonReader.Int(json, "CategoryID"); name = json ["Name"]; assset = json ["Asset"]; description = json["Description"]; cost = new DataUnit.BasicCost(); cost.Load(json); }
public void Load(LitJson.JSONNode json) { id = JsonReader.Int(json, "ID"); level = JsonReader.Int(json, "Level"); mainLevel = JsonReader.Int(json, "MainLevel"); battleParam = new DataUnit.BasicBattleParam(); battleParam.Load(json); cost = new DataUnit.BasicCost(); cost.Load(json); itemCost1 = new DataUnit.ItemCost(); itemCost1.Load(json ["Item_1"]); itemCost2 = new DataUnit.ItemCost(); itemCost2.Load(json ["Item_2"]); }
public static CostCheck IsEnoughCost(DataUnit.BasicCost cost) { int r; r = IsEnoughCashBuyResources(cost.costCash); if (r < 0) { return(CostCheck.NEED_CASH); } r = IsEnoughFoodUse(cost.costFood); if (r < 0) { return(CostCheck.NEED_FOOD); } r = IsEnoughOilUse(cost.costOil); if (r < 0) { return(CostCheck.NEED_OIL); } r = IsEnoughMetalUse(cost.costMetal); if (r < 0) { return(CostCheck.NEED_METAL); } r = IsEnoughRareUse(cost.costRare); if (r < 0) { return(CostCheck.NEED_RARE); } return(CostCheck.OK); }