void Repair() { Repair repairItem = mRepairItem.ItemObj.GetCmpt <Repair>(); if (null != repairItem && !repairItem.GetValue().IsCurrentMax()) { bool itemenough = true; string des = PELocalization.GetString(8000026) + " [ffff00]"; foreach (ItemAsset.MaterialItem item in repairItem.protoData.repairMaterialList) { int n = Mathf.CeilToInt(item.count * c_MultiplierOfCost * (1 - repairItem.GetValue().percent)); int max = m_PlayerPackageCmpt.package.GetCount(item.protoId); if (max < n) { des += " " + ItemProto.Mgr.Instance.Get(item.protoId).GetName() + ""; itemenough = false; break; } } //if(PlayerFactory.mMainPlayer.GetItemNum(mi.ItemId) < mi.needNum) //{ // itemenough = false; // ItemProto item = ItemProto.GetItemData(mi.ItemId); // des += " " + item.GetName() + ""; // MessageBox_N.ShowOkBox(PELocalization.GetString(8000026) + item.GetName() + " " + PELocalization.GetString(8000027)); // return; //} if (!itemenough) { des += "[-]" + " " + PELocalization.GetString(8000027); MessageBox_N.ShowOkBox(des); return; } if (PeGameMgr.IsMulti) { if (null != mRepairItem.ItemObj) { _net.RequestRepair(mRepairItem.ItemObj.instanceId); } return; } foreach (ItemAsset.MaterialItem item in repairItem.protoData.repairMaterialList) { int n = Mathf.CeilToInt(item.count * c_MultiplierOfCost * (1 - repairItem.GetValue().percent)); m_PlayerPackageCmpt.package.Destroy(item.protoId, n); } GameUI.Instance.mItemPackageCtrl.ResetItem(); this.mRepairMachine.m_Repair.StartCounter(); this.mRepairMachine.m_Repair.onRepairedTimeUp = this.RepairComplate; UpdateItem(repairItem); } }
void UpdateItem(Repair obj) { if (null != obj) { mCurrentD.text = PELocalization.GetString(82220001) + ": " + Mathf.CeilToInt(obj.GetValue().current *0.01f); mAddD.text = "(+" + (Mathf.CeilToInt(obj.GetValue().ExpendValue *0.01f)).ToString() + ")"; } else { mCurrentD.text = PELocalization.GetString(82220001) + ": 0"; mAddD.text = "(+0)"; } foreach (CSUI_MaterialGrid mi in mItemList) { mi.gameObject.SetActive(false); mi.transform.parent = null; Destroy(mi.gameObject); } mItemList.Clear(); if (null == obj) { //lz-2016.08.18 然会的时候需要更新按钮的状态 this.UpdateBtnState(); return; } mRepairItem.SetItem(obj.itemObj); mRepairMachine.m_Repair.m_Item = obj; foreach (ItemAsset.MaterialItem item in obj.protoData.repairMaterialList) { int n = Mathf.CeilToInt(item.count * c_MultiplierOfCost * (1 - obj.GetValue().percent)); AddCostItem(item.protoId, n < 0 ? 0 : n); } mCostItemGrid.Reposition(); this.UpdateBtnState(); }
// Cost Item public Dictionary <int, int> GetCostsItems() { if (m_Item == null) { return(null); } if (m_Item.GetValue().IsCurrentMax()) { return(null); } ////float factor = 1-item.lifePoint.percent; Dictionary <int, int> costItems = new Dictionary <int, int>(); List <MaterialItem> materialItems = m_Item.GetRequirements(); foreach (MaterialItem materialItem in materialItems) { costItems [materialItem.protoId] = materialItem.count; } //if (item.instanceId > CreationData.s_ObjectStartID) //{ // foreach (KeyValuePair<int, int> kvp in item.itemObj.mRepairRequireList)//repairrequireList. // { // if (kvp.Key > 30200000 && kvp.Key < 30300000) // costItems[kvp.Key] = Mathf.CeilToInt(kvp.Value * factor); // } //} //else //{ // foreach (KeyValuePair<int, int> kvp in item.prototypeData.mRepairRequireList) // costItems[kvp.Key] = Mathf.CeilToInt(kvp.Value * factor); //} return(costItems); }
// Update is called once per frame void Update() { if (m_ItemGrid != null) { ItemObject item = m_ItemGrid.m_Grid.ItemObj; if (item == null) { m_ItemPart.m_Name.text = ""; if (m_Type == CSConst.etEnhance) { m_EnhanceProperty.m_Durability.text = "0 ([00BBFF] +0 [ffffff])"; m_EnhanceProperty.m_Atk.text = "0 ([00BBFF] +0 [ffffff])"; m_EnhanceProperty.m_Defense.text = "0 ([00BBFF] +0 [ffffff])"; m_EnhanceProperty.m_TimesEnhcance.text = "0"; } else if (m_Type == CSConst.etRepair) { m_RepairProperty.m_Durability.text = "0 ([00BBFF] +0 [ffffff])"; } else if (m_Type == CSConst.etRecyle) { m_RecycleProperty.m_Durability.text = "0 ([00BBFF] +0 [ffffff])"; } m_ItemPart.m_CostsTime.text = "00:00"; m_PopupHintsPart.m_EnhanceHintGo.SetActive(false); m_PopupHintsPart.m_RepairHintGo.SetActive(false); m_PopupHintsPart.m_RecyleHintGo.SetActive(false); } else { m_ItemPart.m_Name.text = item.protoData.name; // Item property float curValue = 0.0f; float nextValue = 0.0f; if (m_Type == CSConst.etEnhance) { if (m_enhanceItem != null) { curValue = m_enhanceItem.GetCurLevelProperty(Pathea.AttribType.Atk); nextValue = m_enhanceItem.GetNextLevelProperty(Pathea.AttribType.Atk); m_EnhanceProperty.m_Atk.text = Mathf.FloorToInt(curValue).ToString() + " ([00BBFF] + " + Mathf.FloorToInt((nextValue - curValue)).ToString() + "[ffffff])"; curValue = m_enhanceItem.GetCurLevelProperty(Pathea.AttribType.Def); nextValue = m_enhanceItem.GetNextLevelProperty(Pathea.AttribType.Def); m_EnhanceProperty.m_Defense.text = Mathf.FloorToInt(curValue).ToString() + " ([00BBFF] + " + Mathf.FloorToInt((nextValue - curValue)).ToString() + "[ffffff])"; curValue = m_enhanceItem.GetCurMaxDurability(); nextValue = m_enhanceItem.GetNextMaxDurability(); WhiteCat.CreationItemClass isoType = WhiteCat.CreationItemClass.None; if (null != m_enhanceItem.itemObj) { isoType = WhiteCat.CreationHelper.GetCreationItemClass(m_enhanceItem.itemObj); } if (isoType != WhiteCat.CreationItemClass.None) { //lz-2017.01.16 只有一部分ISO物品耐久需要乘一个系数才是显示耐久,其他的直接显示原数 switch (isoType) { case WhiteCat.CreationItemClass.Sword: case WhiteCat.CreationItemClass.Axe: case WhiteCat.CreationItemClass.Bow: case WhiteCat.CreationItemClass.Shield: case WhiteCat.CreationItemClass.HandGun: case WhiteCat.CreationItemClass.Rifle: curValue *= WhiteCat.PEVCConfig.equipDurabilityShowScale; nextValue *= WhiteCat.PEVCConfig.equipDurabilityShowScale; break; } } m_EnhanceProperty.m_Durability.text = Mathf.CeilToInt(curValue).ToString() + " ([00BBFF] + " + Mathf.CeilToInt((nextValue - curValue)).ToString() + "[ffffff])"; // Times Ehance m_EnhanceProperty.m_TimesEnhcance.text = m_enhanceItem.strengthenTime.ToString(); } CSEnhance cse = m_Entity as CSEnhance; m_ItemPart.m_CostsTime.text = CSUtils.GetRealTimeMS((int)cse.CostsTime); m_PopupHintsPart.m_EnhanceHintGo.SetActive(true); m_PopupHintsPart.m_RepairHintGo.SetActive(false); m_PopupHintsPart.m_RecyleHintGo.SetActive(false); } else if (m_Type == CSConst.etRepair) { if (null != m_repairItem) { curValue = m_repairItem.GetValue().current; float expendValue = m_repairItem.GetValue().ExpendValue; WhiteCat.CreationItemClass isoType = WhiteCat.CreationItemClass.None; if (null != m_repairItem.itemObj) { isoType = WhiteCat.CreationHelper.GetCreationItemClass(m_repairItem.itemObj); } if (isoType != WhiteCat.CreationItemClass.None) { //lz-2016.10.25 只有一部分ISO物品耐久需要乘一个系数才是显示耐久,其他的直接显示原数 switch (isoType) { case WhiteCat.CreationItemClass.Sword: case WhiteCat.CreationItemClass.Axe: case WhiteCat.CreationItemClass.Bow: case WhiteCat.CreationItemClass.Shield: case WhiteCat.CreationItemClass.HandGun: case WhiteCat.CreationItemClass.Rifle: curValue *= WhiteCat.PEVCConfig.equipDurabilityShowScale; expendValue *= WhiteCat.PEVCConfig.equipDurabilityShowScale; break; } } else { //lz-2016.10.24 其他物品显示的时候要小于100倍的显示,就和ToolTip上面的防御值一样了 curValue *= 0.01f; expendValue *= 0.01f; } m_RepairProperty.m_Durability.text = Mathf.CeilToInt(curValue).ToString() + " ([00BBFF] + " + Mathf.CeilToInt(expendValue).ToString() + "[ffffff])"; } CSRepair csr = m_Entity as CSRepair; m_ItemPart.m_CostsTime.text = CSUtils.GetRealTimeMS((int)csr.CostsTime); m_PopupHintsPart.m_EnhanceHintGo.SetActive(false); m_PopupHintsPart.m_RepairHintGo.SetActive(true); m_PopupHintsPart.m_RecyleHintGo.SetActive(false); } else if (m_Type == CSConst.etRecyle) { CSRecycle csr = m_Entity as CSRecycle; m_ItemPart.m_CostsTime.text = CSUtils.GetRealTimeMS((int)csr.CostsTime); if (null != m_recycleItem) { if (m_recycleItem.GetCurrent() == null) { curValue = 0; } else { curValue = m_recycleItem.GetCurrent().current;//todocolony } } WhiteCat.CreationItemClass isoType = WhiteCat.CreationItemClass.None; if (null != m_recycleItem.itemObj) { isoType = WhiteCat.CreationHelper.GetCreationItemClass(m_recycleItem.itemObj); } if (isoType != WhiteCat.CreationItemClass.None) { //lz-2017.01.16 只有一部分ISO物品耐久需要乘一个系数才是显示耐久,其他的直接显示原数 switch (isoType) { case WhiteCat.CreationItemClass.Sword: case WhiteCat.CreationItemClass.Axe: case WhiteCat.CreationItemClass.Bow: case WhiteCat.CreationItemClass.Shield: case WhiteCat.CreationItemClass.HandGun: case WhiteCat.CreationItemClass.Rifle: curValue *= WhiteCat.PEVCConfig.equipDurabilityShowScale; break; } } m_RecycleProperty.m_Durability.text = Mathf.CeilToInt(curValue).ToString(); m_PopupHintsPart.m_EnhanceHintGo.SetActive(false); m_PopupHintsPart.m_RepairHintGo.SetActive(false); m_PopupHintsPart.m_RecyleHintGo.SetActive(true); } } } // Worker CSCommon csc = m_Entity as CSCommon; if (csc != null) { int workCount = csc.WorkerCount; for (int i = 0; i < m_NpcGirds.Count; i++) { if (i < workCount) { m_NpcGirds[i].m_Npc = csc.Worker(i); } else { m_NpcGirds[i].m_Npc = null; } } m_NpcPart.m_AuttoSettleBtn.isEnabled = (workCount != csc.WorkerMaxCount); m_NpcPart.m_DisbandAllBtn.isEnabled = (workCount != 0); } }