CSUI_PlantGrid _createPlantGrid(FarmPlantLogic p) { CSUI_PlantGrid pg = Instantiate(m_PlantPart.m_PlantGridPrefab) as CSUI_PlantGrid; pg.transform.parent = m_PlantPart.m_Root.transform; CSUtils.ResetLoacalTransform(pg.transform); pg.m_Plant = p; pg.OnDestroySelf = OnPlantGridDestroySelf; //ItemObject itemObj = ItemMgr.Instance.Get( pg.m_Plant.mInstanceId); //if (itemObj != null) //{ string[] iconStr = ItemProto.Mgr.Instance.Get(pg.m_Plant.protoTypeId).icon; if (iconStr.Length != 0) { pg.IconSpriteName = iconStr[0]; } else { pg.IconSpriteName = ""; } //} m_PlantGrids.Add(pg); UICheckbox cb = pg.gameObject.GetComponent <UICheckbox>(); cb.radioButtonRoot = m_PlantPart.m_Root.transform; cb.startsChecked = false; return(pg); }
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); } }
//lz-2016.08.15 增加基地NPC召回按钮 void OnCallBtn(GameObject go) { if (null != m_RefNpc && null != m_RefNpc.NPC) { //m_RefNpc.NPC ECsNpcState state; if (!NpcMgr.CallBackColonyNpcToPlayer(m_RefNpc.NPC, out state)) { switch (state) { case ECsNpcState.None: break; case ECsNpcState.Working: CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(82201077), m_RefNpc.FullName)); break; case ECsNpcState.InMission: CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(82201078), m_RefNpc.FullName)); break; case ECsNpcState.OutOfRadiu: CSUI_MainWndCtrl.ShowStatusBar(PELocalization.GetString(82201079)); break; } } else { CSUI_MainWndCtrl.ShowStatusBar(PELocalization.GetString(82201080)); } } }
void OnStorageMainOpStateEvent(CSUI_StorageMain.EEventType type, object obj1, object obj2) { if (type == CSUI_StorageMain.EEventType.CantWork) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mCantWorkWithoutElectricity.GetString(), (string)obj1), Color.red); } else if (type == CSUI_StorageMain.EEventType.PutItemInto) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutIntoMachine.GetString(), (string)obj1, (string)obj2)); } else if (type == CSUI_StorageMain.EEventType.DeleteItem) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mDeleteItem.GetString(), (string)obj1, (string)obj2)); } else if (type == CSUI_StorageMain.EEventType.TakeAwayItem) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayFromMachine.GetString(), (string)obj1, (string)obj2)); } else if (type == CSUI_StorageMain.EEventType.ResortItem) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mResortTheItems.GetString()); } else if (type == CSUI_StorageMain.EEventType.SplitItem) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mSplitItems.GetString(), (string)obj1, (string)obj2)); } }
void Update() { if (null != GameUI.Instance.mMainPlayer && mMachinePos != Vector3.zero) { if (Vector3.Distance(GameUI.Instance.mMainPlayer.position, mMachinePos) > 8f) { OnClose(); } } if (mRepairItem == null || mRepairItem.ItemObj == null) { return; } if (this.mRepairMachine.m_Repair != null && this.mRepairMachine.m_Repair.IsRepairingM) { this.m_CostTimeLabel.text = CSUtils.GetRealTimeMS((int)mRepairMachine.m_Repair.CostsTime); } else { this.m_CostTimeLabel.text = "00:00"; } //if(null != PlayerFactory.mMainPlayer && null != mRepairMachine) //{ // if(Vector3.Distance(PlayerFactory.mMainPlayer.transform.position,mRepairMachine.transform.position) > 10f) // OnClose(); //} }
public void GetItemMaterialFromFactory(CSFactory factory, List <ItemIdCount> itemsNeedToGet, ref bool transferedItem) { foreach (ItemIdCount iic in itemsNeedToGet) { Replicator.KnownFormula[] msList = UIGraphControl.GetReplicator().GetKnowFormulasByProductItemId(iic.protoId); if (msList == null || msList.Length == 0) { continue; } Replicator.Formula ms = Replicator.Formula.Mgr.Instance.Find(msList[0].id); foreach (Replicator.Formula.Material mt in ms.materials) { int itemCount = factory.GetCompoundEndItemCount(mt.itemId); if (itemCount > 0) { if (CSUtils.AddToStorage(mt.itemId, itemCount, core)) { factory.CountDownItem(mt.itemId, itemCount); transferedItem = true; } } } } }
void OnItemGridChanged(ItemObject item, ItemObject oldItem, int index) { //--to do: wait npcpackage //if (oldItem != null) // RefNpc.m_Npc.RemoveFromBag(oldItem); //if (item != null) // RefNpc.m_Npc.AddToBag(item); if (oldItem != null) { if (item == null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayItemFromNpc.GetString(), oldItem.protoData.GetName(), m_RefNpc.FullName)); } else if (item == oldItem) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mNotEnoughGrid.GetString(), Color.red); } else { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutItemToNpc.GetString(), item.protoData.GetName(), m_RefNpc.FullName)); } } else if (item != null) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mPutItemToNpc.GetString(), item.protoData.GetName(), m_RefNpc.FullName)); } }
void RPC_S2C_BeginRecycle(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _ColonyObj._RecordData.m_DeleteTime = stream.Read <float>(); m_Entity.StartDeleteCounter(0, _ColonyObj._RecordData.m_DeleteTime); CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToDelete.GetString(), m_Entity.Name)); }
public void TrySetProcessingIndex(int index) { if (processingIndex == index) { return; } if (index >= 0) { //--to do: can't work if (!CanProcess) { CSUtils.ShowCannotWorkReason(CannotWorkReason, FullName); return; } } if (PeGameMgr.IsMulti) { if ((AiAdNpcNetwork)NetworkInterface.Get(ID) != null) { ((AiAdNpcNetwork)NetworkInterface.Get(ID)).RPCServer(EPacketType.PT_CL_CLN_SetProcessingIndex, index); } } else { ProcessingIndex = index; } }
public void OnCompoundBtnClickSuccess(int item_id, CSFactory entity) { if (m_Factory == entity) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mJoinCompoudingQueue.GetString(), ItemProto.GetItemData(item_id).GetName())); } }
void UpdateModeUI() { if (!m_Active) { _activate(); return; } m_ModeUI.items.Clear(); if (m_RefNpc != null) { if (m_RefNpc.m_Occupation == CSConst.potWorker) { m_ModeUI.items.Add(CSUtils.GetWorkModeName(CSConst.pwtNormalWork)); m_ModeUI.items.Add(CSUtils.GetWorkModeName(CSConst.pwtWorkWhenNeed)); m_ModeUI.items.Add(CSUtils.GetWorkModeName(CSConst.pwtWorkaholic)); } ShowStatusTips = false; m_ModeUI.selection = CSUtils.GetWorkModeName(m_RefNpc.m_WorkMode); ShowStatusTips = true; } else { m_ModeUI.items.Add("None"); } }
/****************************************************** * 基地仓库给特定npc补给(从仓库移除,添加到NPC背包) * ***************************************************/ public static bool CsStorageSupply(PeEntity npc, CSAssembly assembly, int protoId, int count) { if (assembly == null || assembly.Storages == null || npc.packageCmpt == null) { return(false); } int curCount = CSUtils.GetItemCounFromFactoryAndAllStorage(protoId, assembly); if (curCount > count) { if (CSUtils.CountDownItemFromAllStorage(protoId, count, assembly)) { return(npc.packageCmpt.Add(protoId, count)); } } else if (curCount > 0) { if (CSUtils.CountDownItemFromAllStorage(protoId, curCount, assembly)) { return(npc.packageCmpt.Add(protoId, curCount)); } } return(false); }
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 delegate void TriggerEvent(GameObject go); // public TriggerEvent onEnterTrigger; void OnTriggerEnter(Collider target) { if ((Pathea.PeGameMgr.IsSingleAdventure && Pathea.PeGameMgr.yirdName == Pathea.AdventureScene.MainAdventure.ToString()) || Pathea.PeGameMgr.IsMultiAdventure) { Debug.Log("enter dungen"); if (null == target.GetComponentInParent <Pathea.MainPlayerCmpt>()) { return; } if (isShow == true) { return; } // isShow = true; if (level >= DungeonConstants.TASK_LEVEL_START) { ob = MessageBox_N.ShowYNBox(PELocalization.GetString(DungenMessage.TASK_ENTER_DUNGEN), SceneTranslate, SetFalse); } else { ob = MessageBox_N.ShowYNBox(CSUtils.GetNoFormatString(PELocalization.GetString(DungenMessage.ENTER_DUNGEN), level.ToString()), SceneTranslate, SetFalse); } } }
void OnSelectionChange(string item) { if (item == CSUtils.GetWorkModeName(CSConst.pwtPatrol)) { if (m_RefNpc != null) { m_RefNpc.m_WorkMode = CSConst.pwtPatrol; if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mSoldierForPatrol.GetString(), 6f); } } } else if (item == CSUtils.GetWorkModeName(CSConst.pwtGuard)) { if (m_RefNpc != null) { m_RefNpc.m_WorkMode = CSConst.pwtGuard; if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mSoldierForGuard.GetString(), 6f); } } } m_PatrolInfoUI.gameObject.SetActive(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; }
void UpdateWorkingTime() { // float restTime = Mathf.Max(m_PPCoal.Data.m_WorkedTime - m_PPCoal.Data.m_CurWorkedTime, 0); // float percent = restTime / m_PPCoal.Data.m_WorkedTime; float restTime = m_PPCoal.RestTime; float percent = m_PPCoal.RestPercent; m_Work.m_TimePer.text = ((int)(percent * 100)).ToString() + " %"; m_Work.m_TimeLeft.text = CSUtils.GetRealTimeMS((int)restTime); bool canAdd = true; foreach (CSUI_MaterialGrid mg in m_MatGrids) { if (mg.ItemID != 0) { mg.NeedCnt = Mathf.Max(1, Mathf.RoundToInt(mg.MaxCnt * (1 - percent))); mg.ItemNum = playerPackageCmpt.package.GetCount(mg.ItemID); if (mg.NeedCnt > mg.ItemNum) { canAdd = false; } } else { mg.ItemNum = -1; } } m_Work.m_Button.isEnabled = canAdd; }
void RPC_S2C_RepairStart(uLink.BitStream stream, uLink.NetworkMessageInfo info) { _ColonyObj._RecordData.m_CurRepairTime = stream.Read <float>(); _ColonyObj._RecordData.m_RepairTime = stream.Read <float>(); _ColonyObj._RecordData.m_RepairValue = stream.Read <float>(); m_Entity.StartRepairCounter(_ColonyObj._RecordData.m_CurRepairTime, _ColonyObj._RecordData.m_RepairTime, _ColonyObj._RecordData.m_RepairValue); CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mStartToRepair.GetString(), m_Entity.Name)); }
public bool Add(List <ItemIdCount> itemList) { List <MaterialItem> miList = CSUtils.ItemIdCountToMaterialItem(itemList); bool flag = m_Package.Add(miList); UpdateDataToUI(); return(flag); }
//lz-2016.12.28 回收完成,物品放进了玩家背包 void RPC_S2C_RCY_End(uLink.BitStream stream, uLink.NetworkMessageInfo info) { if (TeamId == BaseNetwork.MainPlayer.TeamId) { CSUtils.ShowTips(RecycleConst.INFORM_FINISH_TO_PACKAGE); ResetRecycle(); } }
public bool CheckNpcState(CSPersonnel trainerNpc) { if (!trainerNpc.CanTrain) { CSUtils.ShowCannotWorkReason(trainerNpc.CannotWorkReason, trainerNpc.FullName); return(false); } return(true); }
void OnSelectionChange(string item) { if (item == CSUtils.GetWorkModeName(CSConst.pwtFarmForMag)) { m_ManageUI.enabled = true; m_HarvestUI.enabled = false; m_PlantUI.enabled = false; if (m_RefNpc != null) { m_RefNpc.TrySetWorkMode(CSConst.pwtFarmForMag); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mFarmerForManage.GetString(), 6f); } } else if (item == CSUtils.GetWorkModeName(CSConst.pwtFarmForHarvest)) { m_ManageUI.enabled = false; m_HarvestUI.enabled = true; m_PlantUI.enabled = false; if (m_RefNpc != null) { m_RefNpc.TrySetWorkMode(CSConst.pwtFarmForHarvest); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mFarmerForHarvest.GetString(), 6f); } } else if (item == CSUtils.GetWorkModeName(CSConst.pwtFarmForPlant)) { m_ManageUI.enabled = false; m_HarvestUI.enabled = true; m_PlantUI.enabled = false; if (m_RefNpc != null) { m_RefNpc.TrySetWorkMode(CSConst.pwtFarmForPlant); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mFarmerForPlant.GetString(), 6f); } } if (onSelectChange != null) { onSelectChange(item); } }
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); } } }
void OnSelectionChange(string item) { if (item == CSUtils.GetWorkModeName(CSConst.pwtNormalWork)) { m_NormalModeUI.enabled = true; m_WorkWhenNeedUI.enabled = false; m_WorkaholicUI.enabled = false; if (m_RefNpc != null) { m_RefNpc.m_WorkMode = CSConst.pwtNormalWork; } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mWorkerForNormal.GetString(), 6f); } } else if (item == CSUtils.GetWorkModeName(CSConst.pwtWorkWhenNeed)) { m_NormalModeUI.enabled = false; m_WorkWhenNeedUI.enabled = true; m_WorkaholicUI.enabled = false; if (m_RefNpc != null) { m_RefNpc.m_WorkMode = CSConst.pwtWorkWhenNeed; } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mWorkerForWorkWhenNeed.GetString(), 6f); } } else if (item == CSUtils.GetWorkModeName(CSConst.pwtWorkaholic)) { m_NormalModeUI.enabled = false; m_WorkWhenNeedUI.enabled = false; m_WorkaholicUI.enabled = true; if (m_RefNpc != null) { m_RefNpc.m_WorkMode = CSConst.pwtWorkaholic; } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mWorkerForWorkaholic.GetString(), 6f); } } if (onSelectChange != null) { onSelectChange(item); } }
void RPC_S2C_FCT_Fetch(uLink.BitStream stream, uLink.NetworkMessageInfo info) { int itemId = stream.Read <int>(); bool succ = stream.Read <bool>(); if (succ) { //1.success UI CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mTakeAwayCompoundItem.GetString(), ItemProto.GetItemData(itemId).GetName())); } }
void OnOccupationChanged(CSPersonnel person, int prvState) { if (person != m_RefNpc || !person.IsRandomNpc) { return; } if (m_OccupationUI.selection != CSUtils.GetOccupaName(person.Occupation)) { m_OccupationUI.selection = CSUtils.GetOccupaName(person.Occupation); } }
void RPC_S2C_PRC_FinishToStorage(uLink.BitStream stream, uLink.NetworkMessageInfo info) { if (PlayerNetwork.mainPlayer == null) { return; } if (TeamId == BaseNetwork.MainPlayer.TeamId) { CSUtils.ShowTips(ProcessingConst.INFORM_FINISH_TO_STORAGE); } }
CSUI_Grid _createGrid(Transform parent, int index = -1) { CSUI_Grid grid = Instantiate(m_GridPrefab) as CSUI_Grid; grid.transform.parent = parent; CSUtils.ResetLoacalTransform(grid.transform); grid.m_Index = index; return(grid); }
//lz-2016.12.28 回收完成,物品放进了基地仓库 void RPC_S2C_RCY_MatsToStorage(uLink.BitStream stream, uLink.NetworkMessageInfo info) { if (PlayerNetwork.mainPlayer == null) { return; } if (TeamId == BaseNetwork.MainPlayer.TeamId) { CSUtils.ShowTips(RecycleConst.INFORM_FINISH_TO_STORAGE); ResetRecycle(); } }
public override bool MeetDemands(List <ItemIdCount> supplyItems) { if (CSUtils.CanAddListToStorage(supplyItems, Assembly)) { CSUtils.AddItemListToStorage(supplyItems, Assembly); return(true); } else { CSAutocycleMgr.Instance.ShowTips(ETipType.storage_full); return(false); } }