void UpdateBuildingNum() { foreach (CSUI_BuildingNum b in m_BuildingNums) { DestroyImmediate(b.gameObject); } m_BuildingNums.Clear(); foreach (KeyValuePair <CSConst.ObjectType, List <CSCommon> > kvp in m_Assembly.m_BelongObjectsMap) { CSUI_BuildingNum bn = Instantiate(m_BuildingNum.m_BuildingNumPrefab) as CSUI_BuildingNum; bn.transform.parent = m_BuildingNum.m_Root.transform; bn.transform.localRotation = Quaternion.identity; bn.transform.localPosition = Vector3.zero; bn.transform.localScale = Vector3.one; bn.m_Description = CSUtils.GetEntityName((int)(kvp.Key)); bn.m_Count = kvp.Value.Count; bn.m_LimitCnt = m_Assembly.GetLimitCnt(kvp.Key); m_BuildingNums.Add(bn); } Invoke("RepositionNow", 0.1f); //m_BuildingNum.m_Root.repositionNow = true; }
public override void CreateData() { CSDefaultData ddata = null; bool isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.etppSolar, ref ddata); m_Data = ddata as CSPowerPlanetData; 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); // Get Charging Items foreach (KeyValuePair <int, int> kvp in Data.m_ChargingItems) { m_ChargingItems[kvp.Key] = ItemMgr.Instance.Get(kvp.Value).GetCmpt <Energy>(); } } m_IsRunning = true; }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtDwelling, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtDwelling, ref ddata); } m_Data = ddata as CSDwellingsData; 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); } }
void OnRightMouseClicked(Grid_N grid) { if (!CSUI_MainWndCtrl.IsWorking()) { return; } if (!m_IsWorking) { if (OpStatusEvent != null) { OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null); } return; } if (!GameUI.Instance.mItemPackageCtrl.IsOpen()) { GameUI.Instance.mItemPackageCtrl.Show(); } if (grid.ItemObj == null) { return; } //lz-2016.10.26 不允许操作正在操作的东西 if (EqualUsingItem(grid.Item, false)) { return; } if (GameConfig.IsMultiMode) { if (m_storage == null) { PlayerNetwork.mainPlayer.RequestPersonalStorageFetch(grid.ItemObj.instanceId, -1); } else { m_storage._ColonyObj._Network.STO_Fetch(grid.ItemObj.instanceId, -1); } } else { if (PeCreature.Instance.mainPlayer.GetCmpt <PackageCmpt>().Add(grid.ItemObj)) { GameUI.Instance.mItemPackageCtrl.ResetItem(); RemoveOriginItem(grid); } else { //lz-2016.09.14 提示背包已满 PeTipMsg.Register(PELocalization.GetString(9500312), PeTipMsg.EMsgLevel.Warning); } } }
//lz-2016.06.08 获取没有核心的所有名字 public List <string> GetNamesByNotHaveAssembly() { List <string> names = new List <string>(); for (int i = 0; i < m_EntityList.Count; i++) { CSCommon common = m_EntityList[i] as CSCommon; if (common != null && common.Assembly == null) { names.Add(CSUtils.GetEntityName(m_EntityList[i].m_Type)); } } return(names); }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtTreat, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtTreat, ref ddata); } m_Data = ddata as CSTreatData; 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); if (Data.npcIds.Count > 0) { foreach (int id in Data.npcIds) { PeEntity npc = EntityMgr.Instance.Get(id); if (npc != null) { allPatients.Add(npc); } } } if (allPatients.Count > 0) { treatmentInUse = m_MgCreator.FindTreatment(allPatients[0].Id, true); } if (Data.m_ObjID >= 0) { medicineItem = ItemAsset.ItemMgr.Instance.Get(Data.m_ObjID); } StartCounter(Data.m_CurTime, Data.m_Time); //--to do update UI } }
//lz-2016.06.08 获取没有电的所有名字 public List <string> GetNamesByNotHaveElectricity() { List <string> names = new List <string>(); for (int i = 0; i < m_EntityList.Count; i++) { CSCommon common = m_EntityList[i] as CSCommon; //lz-2016.08.21 有核心没有运行说明没有电 if (common != null && common.Assembly != null && !m_EntityList[i].IsRunning) { names.Add(CSUtils.GetEntityName(m_EntityList[i].m_Type)); } } return(names); }
//lz-2016.06.08 获取核心等级不足的所有名字 public List <string> GetNamesByAssemblyLevelInsufficient() { List <string> names = new List <string>(); for (int i = 0; i < m_EntityList.Count; i++) { CSCommon common = m_EntityList[i] as CSCommon; //lz-2016.08.21 在核心范围内,但是没有核心,说明核心等级不足 if (common != null && common.Assembly == null && null != CSUI_MainWndCtrl.Instance.Creator && null != CSUI_MainWndCtrl.Instance.Creator.Assembly && CSUI_MainWndCtrl.Instance.Creator.Assembly.InRange(m_EntityList[i].Position)) { names.Add(CSUtils.GetEntityName(m_EntityList[i].m_Type)); } } return(names); }
void RemoveOriginItem(Grid_N grid) { if (grid == null || grid.ItemIndex < -1 || m_CurPack.Count <= grid.ItemIndex) { Debug.LogWarning("The giving grid is error."); return; } if (OpStatusEvent != null) { OpStatusEvent(EEventType.TakeAwayItem, grid.Item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } m_CurPack[grid.ItemIndex] = null; grid.SetItem(null); }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtStorage, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtStorage, ref ddata); } m_Data = ddata as CSStorageData; 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); foreach (KeyValuePair <int, int> kvp in Data.m_Items) { ItemObject ioject = ItemMgr.Instance.Get(kvp.Value); if (ioject != null) { SlotList slotList = m_Package.GetSlotList(ioject.protoId); int listCnt = slotList.Count; int key = kvp.Key % listCnt; slotList[key] = ioject; } } } //for (int i = 0; i < m_WorkSpaces.Length; i++) //{ // m_WorkSpaces[i].Pos = Position; // m_WorkSpaces[i].m_Rot = Quaternion.identity; //} }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.etppFusion, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.etppFusion, ref ddata); } m_Data = ddata as CSPPFusionData; if (isNew) { Data.m_Name = CSUtils.GetEntityName(m_Type); Data.m_Durability = Info.m_Durability; StartWorkingCounter(); } else { StartRepairCounter(Data.m_CurRepairTime, Data.m_RepairTime, Data.m_RepairValue); StartDeleteCounter(Data.m_CurDeleteTime, Data.m_DeleteTime); StartWorkingCounter(Data.m_CurWorkedTime, Data.m_WorkedTime); // Get Charging Items foreach (KeyValuePair <int, int> kvp in Data.m_ChargingItems) { ItemObject itemObj = ItemMgr.Instance.Get(kvp.Value); if (itemObj != null) { m_ChargingItems[kvp.Key] = ItemMgr.Instance.Get(kvp.Value).GetCmpt <Energy>(); } } } }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtRepair, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtRepair, ref ddata); } m_Data = ddata as CSRepairData; 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); if (ItemMgr.Instance.Get(Data.m_ObjID) == null) { m_Item = null; } else { m_Item = ItemMgr.Instance.Get(Data.m_ObjID).GetCmpt <Repair>(); } StartCounter(Data.m_CurTime, Data.m_Time); } //for (int i = 0; i < m_WorkSpaces.Length; i++) //{ // m_WorkSpaces[i].Pos = Position; // m_WorkSpaces[i].m_Rot = Quaternion.identity; //} }
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++; } } } }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (PeGameMgr.IsMulti) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtProcessing, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtProcessing, ref ddata); } m_Data = ddata as CSProcessingData; InitNPC(); 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); for (int i = 0; i < Data.mTaskTable.Length; i++) { if (Data.mTaskTable[i] != null) { Data.mTaskTable[i].StartCounterFromRecord(); Data.mTaskTable[i].taskAccomplished = TaskAccomplished; } } } }
public void CSStoreResultFetch(bool success, int objId, CSStorage storage) { if (success) { if (storage == m_storage) { ItemObject itemObj = ItemMgr.Instance.Get(objId); if (OpStatusEvent != null) { OpStatusEvent(EEventType.TakeAwayItem, itemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } if ((int)m_Type == itemObj.protoData.tabIndex) { RestItems(); } } } }
void OnDropItem(Grid_N grid) { //lz-2016.11.16 当前包裹数据为空的时候直接返回 if (CSUI_MainWndCtrl.Instance == null || grid == null || null == m_CurPack) { return; } if (!CSUI_MainWndCtrl.IsWorking()) { return; } if (!m_IsWorking) { if (OpStatusEvent != null) { OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null); } return; } if (null == SelectItem_N.Instance.ItemObj || SelectItem_N.Instance.Place == ItemPlaceType.IPT_HotKeyBar) { SelectItem_N.Instance.SetItem(null); return; } if (grid.ItemObj == null) { switch (SelectItem_N.Instance.Place) { default: if (GameConfig.IsMultiMode) { if (SelectItem_N.Instance.GridMask != GridMask.GM_Mission) { if (m_storage == null) { if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_Bag) { PlayerNetwork.mainPlayer.RequestPersonalStorageStore(SelectItem_N.Instance.ItemObj.instanceId, grid.ItemIndex); } else if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_NPCStorage) { PlayerNetwork.mainPlayer.RequestPersonalStorageExchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex); } } else { if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_Bag) { m_storage._ColonyObj._Network.STO_Store(grid.ItemIndex, SelectItem_N.Instance.ItemObj); } else if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_CSStorage) { m_storage._ColonyObj._Network.STO_Exchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex); } return; } if (OpStatusEvent != null) { OpStatusEvent(EEventType.PutItemInto, SelectItem_N.Instance.ItemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } } } else { if (SelectItem_N.Instance.GridMask != GridMask.GM_Mission) { SelectItem_N.Instance.RemoveOriginItem(); grid.SetItem(SelectItem_N.Instance.ItemObj); m_CurPack[grid.ItemIndex] = SelectItem_N.Instance.ItemObj; if (OpStatusEvent != null) { OpStatusEvent(EEventType.PutItemInto, SelectItem_N.Instance.ItemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } } } SelectItem_N.Instance.SetItem(null); break; } } else { if (GameConfig.IsMultiMode) { if (m_storage == null) { if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_NPCStorage) { PlayerNetwork.mainPlayer.RequestPersonalStorageExchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex); } } else { if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_CSStorage) { m_storage._ColonyObj._Network.STO_Exchange(SelectItem_N.Instance.ItemObj.instanceId, SelectItem_N.Instance.Index, grid.ItemIndex); } return; } } else { Pathea.PlayerPackageCmpt pkg = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.PlayerPackageCmpt>(); ItemObject dragItem = SelectItem_N.Instance.ItemObj; ItemObject dropItem = grid.ItemObj; ItemPackage.ESlotType dropType = ItemPackage.GetSlotType(dropItem.protoId); ItemPackage.ESlotType dragType = ItemPackage.GetSlotType(dragItem.protoId); //lz-2016.10.18 如果拖动的Item和放置的Item是同一类型,就直接交换ItemObj数据 if (dropType == dragType && null != SelectItem_N.Instance.Grid) { if (SelectItem_N.Instance.Grid.onGridsExchangeItem != null) { SelectItem_N.Instance.Grid.onGridsExchangeItem(SelectItem_N.Instance.Grid, dropItem); grid.SetItem(dragItem); m_CurPack[grid.ItemIndex] = grid.ItemObj; SelectItem_N.Instance.SetItem(null); } } //lz-2016.10.18 如果不是同一类型,或者没有Grid,就先添加,后移除 else if (pkg.package.CanAdd(dropItem)) { pkg.package.AddItem(dropItem); grid.SetItem(dragItem); SelectItem_N.Instance.RemoveOriginItem(); SelectItem_N.Instance.SetItem(null); } } } }
public void CSStoreResultDelete(bool suc, int index, int objId, CSStorage storage) { ItemObject itemObj = ItemMgr.Instance.Get(objId); int type = itemObj.protoData.tabIndex; if (suc) { if (storage == m_storage) { if (OpStatusEvent != null) { OpStatusEvent(EEventType.DeleteItem, itemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } if (type == (int)m_Type) { if (index != -1) { SetItemWithIndex(null, index); } } } } }
void OnPlayerPackageRightClicked(Grid_N grid) { if (!CSUI_MainWndCtrl.IsWorking(false)) { return; } if (!m_IsWorking) { return; } if (GameConfig.IsMultiMode) { if (m_storage == null) { PlayerNetwork.mainPlayer.RequestPersonalStorageStore(grid.ItemObj.instanceId, -1); } else { m_storage._ColonyObj._Network.STO_Store(-1, grid.ItemObj); } } else { if (SetItemWithEmptyGrid(grid.ItemObj)) { // CSUI_Main.ShowStatusBar("You put the " + grid.Item.mItemData.m_Englishname + " into the storage."); if (OpStatusEvent != null) { OpStatusEvent(EEventType.PutItemInto, grid.Item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } // CSUI_Main.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), grid.Item.mItemData.GetName(), CSUtils.GetEntityName(CSConst.etStorage))); PeCreature.Instance.mainPlayer.GetCmpt <PackageCmpt>().Remove(grid.ItemObj); //GetItemPackage().RemoveItem(grid.ItemObj); grid.SetItem(null); } } }
void OnLeftMouseClicked(Grid_N grid) { if (!CSUI_MainWndCtrl.IsWorking()) { return; } if (!m_IsWorking) { if (OpStatusEvent != null) { OpStatusEvent(EEventType.CantWork, CSUtils.GetEntityName(CSConst.etStorage), null); } return; } if (grid.Item == null) { return; } //lz-2016.10.26 不允许操作正在操作的东西 if (EqualUsingItem(grid.Item, false)) { return; } switch (m_OpType) { case 0: SelectItem_N.Instance.SetItemGrid(grid); break; case 1: { if (grid.Item.GetCount() > 1) { int mark = -1; if (!GameConfig.IsMultiMode) { mark = m_Package.GetVacancySlotIndex(0); } else { mark = PeCreature.Instance.mainPlayer.GetCmpt <PlayerPackageCmpt>().package.GetVacancySlotIndex(0); } if (-1 == mark) { MessageBox_N.ShowOkBox(PELocalization.GetString(8000102)); } else if (m_OpGird == null) { m_SplitWnd.SetActive(true); m_OpGird = grid; m_SplitNumDur = 1; m_SplitNumLb.text = "1"; } } } break; case 2: { if (Input.GetMouseButtonDown(0)) { m_OpGird = grid; //wan // mOpBagID = grid.ItemIndex; if (m_OpGird.Item.protoId / 10000000 == 9) { MessageBox_N.ShowOkBox(PELocalization.GetString(8000054)); } else { MessageBox_N.ShowYNBox(PELocalization.GetString(8000055), OnDeleteItem); } } } break; default: break; } }
public override void CreateData() { CSDefaultData ddata = null; bool isNew; if (GameConfig.IsMultiMode) { isNew = MultiColonyManager.Instance.AssignData(ID, CSConst.dtTent, ref ddata, _ColonyObj); } else { isNew = m_Creator.m_DataInst.AssignData(ID, CSConst.dtTent, ref ddata); } m_Data = ddata as CSTentData; if (isNew) { Data.m_Name = CSUtils.GetEntityName(m_Type); Data.m_Durability = Info.m_Durability; for (int i = 0; i < allSickbeds.Length; i++) { allSickbeds[i].tentBuilding = this; if (pePatient != null) { allSickbeds[i].bedLay = pePatient.Lays[i]; } if (resultTrans != null) { allSickbeds[i].bedTrans = resultTrans[i]; } } } else { StartRepairCounter(Data.m_CurRepairTime, Data.m_RepairTime, Data.m_RepairValue); StartDeleteCounter(Data.m_CurDeleteTime, Data.m_DeleteTime); //--to do if (Data.npcIds.Count > 0) { foreach (int id in Data.npcIds) { PeEntity npc = EntityMgr.Instance.Get(id); if (npc != null) { allPatients.Add(npc); } } } for (int i = 0; i < CSMedicalTentConst.BED_AMOUNT_MAX; i++) { Sickbed sb = allSickbeds[i]; if (sb.npcId >= 0) { sb.npc = EntityMgr.Instance.Get(sb.npcId); } else { sb.npc = null; } sb.StartCounterFromRecord(); sb.tentBuilding = this; if (pePatient != null) { sb.bedLay = pePatient.Lays[i]; } if (resultTrans != null) { sb.bedTrans = resultTrans[i]; } } } }
void OnDeleteItem() { if (GameConfig.IsMultiMode) { if (m_storage == null) { PlayerNetwork.mainPlayer.RequestPersonalStorageDelete(m_OpGird.ItemObj.instanceId); } else { m_storage._ColonyObj._Network.Delete(m_OpGird.ItemObj.instanceId); return; } m_OpGird = null; } else { if (OpStatusEvent != null) { OpStatusEvent(EEventType.DeleteItem, m_OpGird.Item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } m_CurPack[m_OpGird.ItemIndex] = null; m_OpGird.SetItem(null); } }
void OnLivingRoomClick() { if (m_RefNpc == null || !(m_RefNpc.m_Occupation == CSConst.potWorker || m_RefNpc.m_Occupation == CSConst.potDoctor)) { return; } if (m_RefCommon.WorkerCount >= m_RefCommon.WorkerMaxCount) { return; } if (m_RefNpc.WorkRoom != m_RefCommon) { m_RefNpc.TrySetWorkRoom(m_RefCommon); //--to do: wait //if(GameConfig.IsMultiMode) //{ // if(m_RefNpc.m_Npc.Netlayer is AiAdNpcNetwork) // ((AiAdNpcNetwork)m_RefNpc.m_Npc.Netlayer).SetClnWorkRoomID(m_RefNpc.WorkRoom.ID); //} CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mSetWorkRoom.GetString(), m_RefNpc.FullName, CSUtils.GetEntityName(m_RefCommon.m_Type))); } }
public void ShowWndPart(CSUI_LeftMenuItem menuItem, int mWndPartType, CSEntity selectEntity = null) { if (!isShow) { base.Show(); CheckFirstOpenColony(); } if (null == menuItem || !m_ActiveMenuList.Contains(menuItem)) { menuItem = m_Menu.m_PersonnelMI; } if (!menuItem.IsSelected) { menuItem.SelectSprite(true); } if (mSelectedMenuItem != null && mSelectedMenuItem != menuItem) { mSelectedMenuItem.IsSelected = false; } mSelectedMenuItem = menuItem; //log:lz-2016.05.26 只要打开都提示是否有电 if (menuItem.NotHaveAssembly || menuItem.NotHaveElectricity) { string entityNameStr = CSUtils.GetEntityName(menuItem.m_Type); //log:lz-2016.05.26 Hospital里面三个机械要分别提示 if (menuItem == m_Menu.m_HospitalMI && (m_Menu.m_HospitalMI.NotHaveAssembly || m_Menu.m_HospitalMI.NotHaveElectricity)) { List <string> names = new List <string>(); if (menuItem.AssemblyLevelInsufficient) { names = menuItem.GetNamesByAssemblyLevelInsufficient(); } else if (menuItem.NotHaveAssembly) { names = menuItem.GetNamesByNotHaveAssembly(); } else if (menuItem.NotHaveElectricity) { names = menuItem.GetNamesByNotHaveElectricity(); } if (null != names && names.Count > 0) { entityNameStr = ""; for (int i = 0; i < names.Count; i++) { entityNameStr += names[i]; entityNameStr += ","; } entityNameStr = entityNameStr.Substring(0, entityNameStr.Length - 1); } } if (!string.IsNullOrEmpty(entityNameStr)) { //lz-2016.06.08 检测顺序为:1.检测基地核心等级是否足够 2.检测是否有基地核心 3.检测是否有电 (注意:这个顺序不能修改,因为核心等级不足会满足没有核心的条件,具体参见menuItem.AssemblyLevelInsufficient的实现) if (menuItem.AssemblyLevelInsufficient) { ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkAssemblyLevelInsufficient.GetString(), entityNameStr), Color.red); } else if (menuItem.NotHaveAssembly) { ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutAssembly.GetString(), entityNameStr), Color.red); } else if (menuItem.NotHaveElectricity) { ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), entityNameStr), Color.red); } } } m_Windows.m_EngineeringUI.CloseLock(); mWndPartTag = mWndPartType; mSkillLock.gameObject.SetActive(!IsUnLock(mWndPartType)); #if UNITY_5 bool active = isActiveAndEnabled; #endif // Assembly if (mWndPartType == CSConst.dtAssembly) { m_Windows.m_AssemblyUI.gameObject.SetActive(true); m_Windows.m_AssemblyUI.SetEntity(m_Creator.Assembly); mSelectedEnntity = m_Creator.Assembly; } //etStorage else if (mWndPartType == CSConst.dtStorage) { m_Windows.m_StorageUI.gameObject.SetActive(true); m_Windows.m_StorageUI.Replace(menuItem.m_EntityList); } //etPowerPlant else if (menuItem.m_Type == CSConst.dtppCoal) { m_Windows.m_PPCoalUI.gameObject.SetActive(true); m_Windows.m_PPCoalUI.SetEntityList(menuItem.m_EntityList, selectEntity); } //dtDwelling else if (mWndPartType == CSConst.dtDwelling) { m_Windows.m_DwellingsUI.gameObject.SetActive(active); m_Windows.m_DwellingsUI.SetEntityList(menuItem.m_EntityList); } //dtEngineer else if (mWndPartType == CSConst.dtEngineer) { m_Windows.m_EngineeringUI.Replace(menuItem.m_EntityList, selectEntity); m_Windows.m_EngineeringUI.gameObject.SetActive(active); } //dtFarm else if (menuItem.m_Type == CSConst.dtFarm) { if (menuItem.m_EntityList.Count >= 1) { m_Windows.m_FarmUI.gameObject.SetActive(active); CSFarm f = menuItem.m_EntityList[0] as CSFarm; if (menuItem.m_EntityList.Count > 1) { foreach (CSEntity e in menuItem.m_EntityList) { CSFarm tempF = e as CSFarm; if (tempF.IsRunning) { f = tempF; break; } } } m_Windows.m_FarmUI.SetFarm(f); mSelectedEnntity = f; } } //dtFactory else if (menuItem.m_Type == CSConst.dtFactory) { //lz-2016.11.14 错误 #6335 Crush Bug if (menuItem.m_EntityList.Count >= 1) { NGUITools.SetActive(m_Windows.m_FactoryUI.gameObject, active); CSEntity f = menuItem.m_EntityList[0]; if (menuItem.m_EntityList.Count > 1) { foreach (CSEntity e in menuItem.m_EntityList) { if (e.IsRunning) { f = e; break; } } } m_Windows.m_FactoryUI.SetEntity(f); } } //etPersonnel else if (mWndPartType == CSConst.dtPersonnel) { m_Windows.m_PersonnelUI.gameObject.SetActive(true); } //Transaction else if (mWndPartType == CSConst.dtTrade) { m_Windows.m_TradingPostUI.gameObject.SetActive(true); m_Windows.m_TradingPostUI.SetMenu(menuItem); //lz-2016.10.31 刷新OptionWnd和WorkWnd的Entity if (null != menuItem && menuItem.m_EntityList.Count > 0) { mSelectedEnntity = menuItem.m_EntityList[0]; } } //Collect else if (mWndPartType == CSConst.dtProcessing) { m_Windows.m_CollectUI.gameObject.SetActive(true); m_Windows.m_CollectUI.UpdateCollect(); //lz-2016.11.28 错误 #7098 crash bug if (menuItem.m_EntityList.Count > 0) { CSEntity f = menuItem.m_EntityList[0]; if (menuItem.m_EntityList.Count > 1) { foreach (CSEntity e in menuItem.m_EntityList) { if (e.IsRunning) { f = e; break; } } } m_Windows.m_CollectUI.SetEnity(f); } } //Hospital else if (mWndPartType == CSConst.dtCheck || mWndPartType == CSConst.dtTreat || mWndPartType == CSConst.dtTent) { m_Windows.m_HospitalUI.gameObject.SetActive(true); //lw 2017.2.21:治疗的三个机器添加修理功能 m_Windows.m_HospitalUI.RefleshMechine(m_Windows.m_HospitalUI.m_CheckedPartType, menuItem.m_EntityList, selectEntity); } //Train else if (mWndPartType == CSConst.dtTrain) { m_Windows.m_TrainUI.gameObject.SetActive(true); //lz-2016.01.03 选中的entity切换为训练所 if (null != menuItem && menuItem.m_EntityList.Count > 0) { mSelectedEnntity = menuItem.m_EntityList[0]; } } //删除bed界面子窗口 DestroyChildWindowOfBed(); }
void CheckCantWorkTip() { //lz-2016.10.24 如果基地可以工作,说明没有超过距离,并且有核心 if (CSUI_MainWndCtrl.IsWorking()) { if (null != m_CurMenuItem) { //lz-2016.10.24 贸易站核心等级不足提示 if (m_CurMenuItem.AssemblyLevelInsufficient) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkAssemblyLevelInsufficient.GetString(), CSUtils.GetEntityName(m_CurMenuItem.m_Type)), Color.red); } //lz-2016.10.24 贸易站没电提示 else if (m_CurMenuItem.NotHaveElectricity) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_CurMenuItem.m_Type)), Color.red); } } } }
/// <summary> /// check if this grid can put item in /// </summary> /// <param name="item">target_item</param> /// <param name="check_type">operation_type</param> /// <returns></returns> bool OnGridCheckItem(ItemObject item, CSUI_Grid.ECheckItemType check_type) { if (!CSUI_MainWndCtrl.IsWorking()) { return(false); } if (!m_Entity.IsRunning) { CSCommon com = m_Entity as CSCommon; if (com == null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_Type)), Color.red); } else { if (com.Assembly == null) { CSUI_MainWndCtrl.ShowStatusBar("The machine is invalid.", Color.red); } else { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), CSUtils.GetEntityName(m_Type)), Color.red); } } return(false); } if (SelectItem_N.Instance.Place == ItemPlaceType.IPT_HotKeyBar) { return(false); } if (m_Type == CSConst.etEnhance) { if ((m_Entity as CSEnhance).IsEnhancing) { if (m_enhanceItem != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenEnhancingTheItem.GetString(), m_enhanceItem.protoData.GetName()), Color.red); } return(false); } if (item != null) { //if ((item.prototypeData.m_OpType & ItemOperationType.EquipmentItem) == 0 // && item.prototypeId < CreationData.s_ObjectStartID) //{ // return false; //} Strengthen sItem = item.GetCmpt <Strengthen>(); if (null != sItem) { if (sItem.strengthenTime >= 100) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.CANNOT_ENHANCE_MORE), item.protoData.GetName()), Color.red); return(false); } } else { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.CANNOT_ENHANCE_ITEM), item.protoData.GetName()), Color.red); return(false); } } } else if (m_Type == CSConst.etRepair) { if ((m_Entity as CSRepair).IsRepairingM) { if (m_repairItem != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenRepairingTheItem.GetString(), m_repairItem.protoData.GetName()), Color.red); } return(false); } if (item != null) { Repair sItem = item.GetCmpt <Repair>(); if (sItem == null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mNotRequireRepair.GetString(), item.protoData.GetName()), Color.red); return(false); } } } else if (m_Type == CSConst.etRecyle) { if ((m_Entity as CSRecycle).IsRecycling) { if (m_recycleItem != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mHasBeenRecyclingTheItem.GetString(), m_recycleItem.protoData.GetName()), Color.red); } return(false); } if (item != null) { Recycle sItem = item.GetCmpt <Recycle>(); //if (item.prototypeId > CreationData.s_ObjectStartID) //{ // // return true; //} //else //{ // Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(item.prototypeId); // //MergeSkill ms = MergeSkill.s_tblMergeSkills.Find( // // delegate(MergeSkill hh) // // { // // return hh.m_productItemId == item.mItemID; // // }); if (sItem == null || sItem.GetRecycleItems() == null) { if (sItem != null) { Debug.LogError(item.nameText + " " + item.protoId + " should not have Recycle!"); } CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantRecycle.GetString(), item.protoData.GetName()), Color.red); return(false); } //} } } return(true); }
void OnToolsGridItemChanged(ItemObject item, ItemObject oldItem, int index) { m_Farm.SetPlantTool(index, item); if (oldItem != null) { if (item == null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayFromMachine.GetString(), oldItem.protoData.GetName(), CSUtils.GetEntityName(CSConst.etFarm))); } else if (item == oldItem) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mNotEnoughGrid.GetString(), Color.red); } else { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etFarm))); } } else if (item != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), item.protoData.GetName(), CSUtils.GetEntityName(CSConst.etFarm))); } }
public void CSStoreResultStore(bool success, int index, int objId, CSStorage storage) { if (success) { if (storage == m_storage) { ItemObject itemObj = ItemMgr.Instance.Get(objId); if (OpStatusEvent != null) { OpStatusEvent(EEventType.PutItemInto, itemObj.protoData.GetName(), CSUtils.GetEntityName(CSConst.etStorage)); } if ((int)m_Type == itemObj.protoData.tabIndex) { SetItemWithIndex(itemObj, index); } } } }
void OnGirdItemChanged(ItemObject item, ItemObject oldItem, int index) { if (oldItem != null) { if (item == null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayFromMachine.GetString(), oldItem.protoData.GetName(), CSUtils.GetEntityName(m_Type))); } else if (item == oldItem) { //log:lz-2016.04.14: 这里点击的是自己Item不做操作 //CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mNotEnoughGrid.GetString(), Color.red); } else { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), item.protoData.GetName(), CSUtils.GetEntityName(m_Type))); } } else if (item != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), item.protoData.GetName(), CSUtils.GetEntityName(m_Type))); } if (item != null) { m_enhanceItem = item.GetCmpt <Strengthen>(); m_repairItem = item.GetCmpt <Repair>(); m_recycleItem = item.GetCmpt <Recycle>(); } else { m_enhanceItem = null; m_repairItem = null; m_recycleItem = null; } OnItemChanged(item); }