void ImmediatelyRepairUnit() // 立即完成维修 { UIHelper.LoadingPanelIsOpen(true); RepairUnitRequest request = new RepairUnitRequest(); request.api = new Model_ApiRequest().api; if (_tankRepairItemDic != null) { foreach (KeyValuePair <int, TankRepairItem> kv in _tankRepairItemDic) { TankRepairItem tankItem = kv.Value; Model_Unit modelUnit = tankItem.GetCurrentModelUnit(); int tankNum = tankItem.GetCurrentRepairTankNum(); if (tankNum != null && tankNum > 0) { SlgPB.Unit unit = new SlgPB.Unit(); unit.unitId = modelUnit.unitId; unit.num = tankItem.GetCurrentRepairTankNum(); request.units.Add(unit); } } } request.buyCd = 1; (new PBConnect_repairUnit()).Send(request, OnImmediatelyRepairUnit); }
// 全选 void OnAllChoose() { if (_tankRepairItemDic != null) { foreach (KeyValuePair <int, TankRepairItem> kv in _tankRepairItemDic) { Trace.trace("全选" + kv.Key, Trace.CHANNEL.UI); TankRepairItem tankItem = kv.Value; tankItem.SetRepairAllTank(); } } }
// void OnUpateItem(GameObject go, int index, int realIndex, List <Model_Unit> dataList, Dictionary <int, TankRepairItem> dataDic) { int index_ = 0; int indexList = Mathf.Abs(realIndex); int tankCount = dataList.Count; TankRepairItem Item1 = go.transform.Find("TankRepairItem1").GetComponent <TankRepairItem>(); TankRepairItem tankItem2 = go.transform.Find("TankRepairItem2").GetComponent <TankRepairItem>(); index_ = indexList * 2; if (index_ > (tankCount - 1)) { Item1.gameObject.SetActive(false); tankItem2.gameObject.SetActive(false); return; } else { Item1.gameObject.SetActive(true); Item1.Init(dataList[index_]); if (!dataDic.ContainsKey(dataList[index_].unitId)) { dataDic.Add(dataList[index_].unitId, Item1); } else { dataDic.Remove(dataList[index_].unitId); dataDic.Add(dataList[index_].unitId, Item1); } } index_ = indexList * 2 + 1; if (index_ > (tankCount - 1)) { tankItem2.gameObject.SetActive(false); return; } else { tankItem2.gameObject.SetActive(true); tankItem2.Init(dataList[index_]); if (!dataDic.ContainsKey(dataList[index_].unitId)) { dataDic.Add(dataList[index_].unitId, tankItem2); } else { dataDic.Remove(dataList[index_].unitId); dataDic.Add(dataList[index_].unitId, tankItem2); } } }
void CreateWrapTankItem(List <Model_Unit> dataList) { int count = dataList.Count; if (_repairGrid != null) { _repairGrid.DestoryAllChildren(); } _tankRepairItemDic.Clear(); for (int i = 0; i < count; i++) { if (_repairGrid.gameObject != null) { GameObject tankItem = (GameObject)Resources.Load(AppConfig.FOLDER_PROFAB_UI + "RepairFactory/TankRepairItem"); GameObject item = NGUITools.AddChild(_repairGrid.gameObject, tankItem); TankRepairItem repairItem = item.GetComponent <TankRepairItem>(); repairItem.Init(dataList[i]); _tankRepairItemDic.Add(dataList[i].unitId, repairItem); } } _repairGrid.Reposition(); }
void ResData() { if (_tankRepairItemDic != null) { int foodCount = 0; int oilCount = 0; int matelCount = 0; int rareCount = 0; int timeCount = 0; int cashCount = 0; foreach (KeyValuePair <int, TankRepairItem> kv in _tankRepairItemDic) { TankRepairItem tankItem = kv.Value; Dictionary <int, int> resCountDic = tankItem.GetResCountDic(); int res_1 = 0; resCountDic.TryGetValue(1, out res_1); foodCount = foodCount + res_1; int res_2 = 0; resCountDic.TryGetValue(2, out res_2); oilCount = oilCount + res_2; int res_3 = 0; resCountDic.TryGetValue(3, out res_3); matelCount = matelCount + res_3; int res_4 = 0; resCountDic.TryGetValue(4, out res_4); rareCount = rareCount + res_4; int res_5 = 0; resCountDic.TryGetValue(5, out res_5); timeCount = timeCount + res_5; int res_6 = 0; resCountDic.TryGetValue(6, out res_6); cashCount = cashCount + res_6; } if (_allResCountDic != null) { _allResCountDic.Clear(); _allResCountDic.Add(1, foodCount); _allResCountDic.Add(2, oilCount); _allResCountDic.Add(3, matelCount); _allResCountDic.Add(4, rareCount); _allResCountDic.Add(5, timeCount); _allResCountDic.Add(6, cashCount); } } if (_allResCountDic != null) { int allTime; _allResCountDic.TryGetValue(5, out allTime); _RepairTime_Value.text = UIHelper.setTimeDHMS(Mathf.RoundToInt(allTime)).ToString(); int allCash; _allResCountDic.TryGetValue(6, out allCash); _immediatelyRepair_CoinValue.text = (int)allCash + ""; for (int i = 1; i <= 4; i++) { int resNum = 0; _allResCountDic.TryGetValue(i, out resNum); int requst = -1; if (i == 1) { requst = ConnectionValidateHelper.IsEnoughFoodUse((int)resNum); if (requst == 0) { _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaFoodRes()); } else { _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaFoodRes()); } } else if (i == 2) { requst = ConnectionValidateHelper.IsEnoughOilUse((int)resNum); if (requst == 0) { _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaOilRes()); } else { _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaOilRes()); } } else if (i == 3) { requst = ConnectionValidateHelper.IsEnoughMetalUse((int)resNum); if (requst == 0) { _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaMatelRes()); } else { _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaMatelRes()); } } else if (i == 4) { requst = ConnectionValidateHelper.IsEnoughRareUse((int)resNum); if (requst == 0) { _resLabelList[i - 1].text = Mathf.RoundToInt(resNum).ToString() + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaRareRes()); } else { _resLabelList[i - 1].text = UIHelper.SetStringColor(Mathf.RoundToInt(resNum).ToString()) + "/" + UIHelper.SetResourcesShowFormat(Model_Helper.GetPlayerHavaRareRes()); } } } } }