void RPC_S2C_CLN_SetWorkMode(uLink.BitStream stream, uLink.NetworkMessageInfo info) { //--to do: wait int workMode = stream.Read <int>(); //int playID = stream.Read<int>(); //if(playID != PlayerFactory.mMainPlayer.OwnerView.viewID.id) //{ CSCreator creator = MultiColonyManager.GetCreator(TeamId, false); if (creator != null) { CSPersonnel[] personnels = creator.GetNpcs(); foreach (CSPersonnel csp in personnels) { if (csp != null && csp.m_Npc != null) { if (Id == csp.m_Npc.Id) { csp.m_WorkMode = workMode; } } } } //} }
void OnEnable() { CSCreator creator = CSUI_MainWndCtrl.Instance.Creator; if (creator == null) { return; } Dictionary <int, CSCommon> commons = creator.GetCommonEntities(); foreach (KeyValuePair <int, CSCommon> kvp in commons) { if (kvp.Value.Assembly != null && kvp.Value.WorkerMaxCount > 0 && (kvp.Value as CSHealth) != null) { CSUI_WorkRoom wr = Instantiate(WorkRoomUIPrefab) as CSUI_WorkRoom; wr.transform.parent = m_WorkRoomRootUI.transform; wr.transform.localPosition = Vector3.zero; wr.transform.localRotation = Quaternion.identity; wr.transform.localScale = Vector3.one; wr.m_RefCommon = kvp.Value; wr.m_RefNpc = RefNpc; m_WorkRooms.Add(wr); } } m_WorkRoomRootUI.repositionNow = true; }
public CSCreator MultiCreateCreator(int TeamNum) { if (otherCreators.ContainsKey(TeamNum)) { Debug.Log("This TeamNum [" + TeamNum.ToString() + "] is exsit"); return(null); } CSCreator creator = null; GameObject go = new GameObject(); go.transform.parent = transform; go.name = "Team " + TeamNum + " Managed Creator"; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; CSMgCreator mgCreator = go.AddComponent <CSMgCreator>(); creator = mgCreator; CSConst.CreatorType type = CSConst.CreatorType.Managed; creator.m_DataInst = CSDataMgr.CreateDataInst(TeamNum, type); mgCreator.m_Clod = CSClodsMgr.CreateClod(TeamNum); mgCreator.teamNum = TeamNum; otherCreators.Add(TeamNum, creator); return(creator); }
public override int Init(CSBuildingLogic csbl, CSCreator creator, bool bFight) { int a = 0; a++; return(base.Init(csbl, creator, bFight)); }
IEnumerator CSTeam(float time) { if (SingleGameStory.curType == SingleGameStory.StoryScene.TrainingShip) { yield break; } yield return(new WaitForSeconds(time)); while (true) { mCScreator = CSMain.GetCreator(CSConst.ciDefMgCamp); if (mCScreator != null) { mCSNpcs = CSMain.GetCSNpcs(mCScreator); mCSnpcTeam.setCSCreator(mCScreator); if (mCScreator.Assembly != null && mCSNpcs.Count > 0) { mCSnpcTeam.InitTeam(); mCSnpcTeam.AddInTeam(mCSNpcs, true); mCSnpcTeam.ReFlashTeam(); } } yield return(new WaitForSeconds(time)); } }
public override int Init(int id, CSCreator creator, bool bFight) { int a = 0; a++; return(base.Init(id, creator, bFight)); }
IEnumerator InitDataRoutine(CSPersonnelData cspd) { PeEntity npc = null; while (true) { npc = EntityMgr.Instance.Get(Id); if (npc == null) { yield return(new WaitForSeconds(0.5f)); } else { break; } } CSCreator creator = null; while (true) { creator = MultiColonyManager.GetCreator(TeamId); if (creator == null) { yield return(new WaitForSeconds(0.5f)); } else { break; } } ((CSMgCreator)creator).AddNpc(npc, cspd, true); // if (TeamId == PlayerNetwork.MainPlayer.TeamId) // { // CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp); // while (creator == null) // { // yield return new WaitForSeconds(0.5f); // creator = MultiColonyManager.GetCreator(CSConst.ciDefMgCamp); // } // // // ((CSMgCreator)creator).AddNpc(npc, cspd, true); // } // else // { // CSCreator creator = CSMain.GetCreator(TeamId); // while (creator == null) // { // yield return new WaitForSeconds(0.5f); // creator = MultiColonyManager.GetCreator(TeamId); // } // // ((CSMgCreator)creator).AddNpc(npc, cspd, true); // } //m_PersonnelDatas.Add(cspd.ID, cspd); }
public override int Init(CSBuildingLogic csbul, CSCreator creator, bool bFight = true) { int r = base.Init(csbul, creator, bFight); if (r == CSConst.rrtSucceed) { CreateEnergySheild(); } return(r); }
public override int Init(int id, CSCreator creator, bool bFight = true) { int r = base.Init(id, creator, bFight); if (r == CSConst.rrtSucceed) { CreateEnergySheild(); } return(r); }
public static List <PeEntity> GetCSNpcs(CSCreator creator) { List <PeEntity> allNpcs = new List <PeEntity>(); foreach (CSPersonnel csp in creator.GetNpcs()) { allNpcs.Add(csp.NPC); } return(allNpcs); }
void Awake() { if (s_Instance != null) { Debug.LogError("CSMain must be only one!"); } else { s_Instance = this; } CSEntityLayerIndex = Pathea.Layer.Building; m_Creators = new Dictionary <int, CSCreator>(); if (GameConfig.IsMultiMode) { otherCreators = new Dictionary <int, CSCreator>(); } CSClodMgr.Init(); CSClodsMgr.Init(); CSCreator defMgCreator = CreateCreator(CSConst.ciDefMgCamp, "Default Managed Creator"); if (GameConfig.IsMultiMode) { defMgCreator.teamNum = BaseNetwork.MainPlayer.TeamId; Debug.Log("Main Creator team: " + defMgCreator.teamNum); } CreateCreator(CSConst.ciDefNoMgCamp, "Default Non-Managed Creator", CSConst.CreatorType.NoManaged); DigTerrainManager.onDirtyVoxel += OnDirtyVoxel; FarmManager.Instance.CreatePlantEvent += OnCreatePlant; FarmManager.Instance.RemovePlantEvent += OnRemovePlant; DigTerrainManager.onDigTerrain += OnDigTerrain; // DefmgCreator UI //if ( CSUI_Main.Instance != null) //{ // CSUI_Main.Instance.Creator = defMgCreator; //} if (CSUI_MainWndCtrl.Instance != null) { CSUI_MainWndCtrl.Instance.Creator = defMgCreator; } if (InitOperatItemEvent != null) { InitOperatItemEvent(); InitOperatItemEvent = null; } }
public override bool OnDragging(Ray cameraRay) { if (Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand || RandomDungenMgrData.InDungeon) { return(false); } bool canPutOut = base.OnDragging(cameraRay); // limited field bLimited = false; for (int i = 0; i < m_LimitedField.Count; i++) { if (Pathea.PeGameMgr.sceneMode != m_LimitedField[i].mode) { continue; } Vector3 pos = transform.position; float sqr_dis = m_LimitedField[i].radius * m_LimitedField[i].radius; if ((pos - m_LimitedField[i].center).sqrMagnitude < sqr_dis) { bLimited = true; break; } } CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp); if (creator != null) { canPutOut = canPutOut && (creator.CanCreate((int)m_CEO.m_Type, transform.position) == CSConst.rrtSucceed && !bLimited); } m_NotInWaterOrCave = transform.position == Vector3.zero || (!CheckPosInCave() && !PETools.PEUtil.CheckPositionUnderWater(transform.position)); if (canPutOut) { canPutOut = canPutOut && m_NotInWaterOrCave; } //if (m_CEO.HasStarted) // OnItemOpGUIActive(); if (null != itemBounds) { itemBounds.activeState = canPutOut; } return(canPutOut); }
void RPC_S2C_CLN_RemoveNpc(uLink.BitStream stream, uLink.NetworkMessageInfo info) { //int playID = stream.Read<int>(); //if(playID == PlayerFactory.mMainPlayer.OwnerView.viewID.id) //{ //} CSCreator mCreator = MultiColonyManager.GetCreator(TeamId); PeEntity npcEntity = EntityMgr.Instance.Get(Id); mCreator.RemoveNpc(npcEntity); npcEntity.Dismiss(); }
public static List <PeEntity> GetCSBuildings(CSCreator creator) { List <PeEntity> allbuildings = new List <PeEntity>(); CSMgCreator mgCreater = creator as CSMgCreator; if (mgCreater != null) { foreach (CSBuildingLogic csb in mgCreater.allBuildingLogic.Values) { allbuildings.Add(csb._peEntity); } } return(allbuildings); }
public static bool HasBuilding(int protoId, CSCreator creator) { CSMgCreator mgCreater = creator as CSMgCreator; if (mgCreater != null) { foreach (CSBuildingLogic csb in mgCreater.allBuildingLogic.Values) { if (csb != null && csb.protoId == protoId) { return(true); } } } return(false); }
public CSCreator CreateCreator(int ID, string desc, CSConst.CreatorType type = CSConst.CreatorType.Managed) { if (m_Creators.ContainsKey(ID)) { Debug.Log("This ID [" + ID.ToString() + "] is exsit"); return(null); } CSCreator creator = null; if (type == CSConst.CreatorType.Managed) { GameObject go = new GameObject(); go.transform.parent = transform; go.name = desc; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; CSMgCreator mgCreator = go.AddComponent <CSMgCreator>(); creator = mgCreator; creator.m_DataInst = CSDataMgr.CreateDataInst(ID, type); mgCreator.m_Clod = CSClodsMgr.CreateClod(ID); m_Creators.Add(ID, creator); } else if (type == CSConst.CreatorType.NoManaged) { GameObject go = new GameObject(); go.transform.parent = transform; go.name = desc; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; creator = go.AddComponent <CSNoMgCreator>(); creator.m_DataInst = CSDataMgr.CreateDataInst(ID, type); m_Creators.Add(ID, creator); } return(creator); }
public CSTrade(CSCreator creator) { m_Creator = creator; m_Type = CSConst.etTrade; m_Workers = new CSPersonnel[1]; m_WorkSpaces = new PersonnelSpace[1]; for (int i = 0; i < m_WorkSpaces.Length; i++) { m_WorkSpaces[i] = new PersonnelSpace(this); } m_Grade = CSConst.egtLow; if (IsMine) { BindEvent(); } }
public static bool HasBuilding(int protoId, CSCreator creator, out Vector3 pos) { CSMgCreator mgCreater = creator as CSMgCreator; pos = Vector3.zero; if (mgCreater != null) { foreach (CSBuildingLogic csb in mgCreater.allBuildingLogic.Values) { if (csb != null && csb.protoId == protoId) { pos = csb.transform.position; return(true); } } } return(false); }
public CSProcessing(CSCreator creator) { m_Creator = creator; m_Type = CSConst.etProcessing; // Init Workers m_Workers = new CSPersonnel[ProcessingConst.WORKER_AMOUNT_MAX]; m_WorkSpaces = new PersonnelSpace[ProcessingConst.WORKER_AMOUNT_MAX]; for (int i = 0; i < m_WorkSpaces.Length; i++) { m_WorkSpaces[i] = new PersonnelSpace(this); } m_Grade = CSConst.egtLow; if (IsMine) { BindEvent(); } }
void RPC_S2C_CLN_SetWorkRoomID(uLink.BitStream stream, uLink.NetworkMessageInfo info) { //--to do: wait int workRoomID = stream.Read <int>(); //int playID = stream.Read<int>(); //if (playID != PlayerFactory.mMainPlayer.OwnerView.viewID.id) //{ CSCreator creator = MultiColonyManager.GetCreator(TeamId, false); if (creator != null) { CSPersonnel[] personnels = creator.GetNpcs(); foreach (CSPersonnel csp in personnels) { if (csp != null && csp.m_Npc != null) { if (Id == csp.m_Npc.Id) { if (workRoomID == 0) { csp.WorkRoom = null; return; } Dictionary <int, CSCommon> commons = creator.GetCommonEntities(); foreach (KeyValuePair <int, CSCommon> kvp in commons) { if (kvp.Value.Assembly != null && kvp.Value.WorkerMaxCount > 0 && kvp.Value.m_Type != CSConst.etFarm) { if (kvp.Value.ID == workRoomID) { csp.WorkRoom = kvp.Value; break; } } } } } } } //} }
public static bool NpcMissionReady(PeEntity npc) { if (npc == null) { return(false); } if (npc.NpcCmpt == null) { return(false); } CSCreator mCScreator = npc.NpcCmpt.Creater; if (mCScreator == null) { mCScreator = CSMain.GetCreator(CSConst.ciDefMgCamp); } if (mCScreator == null || mCScreator.Assembly == null) { return(false); } ItemAsset.ItemObject item; if (npc.UseItem != null && NpcEatDb.CanEatSthFromStorages(npc, mCScreator.Assembly.Storages, out item)) { npc.UseItem.Use(item); } for (int i = 0; i < RecruitBuff.Length; i++) { npc.skEntity.CancelBuffById(RecruitBuff[i]); } for (int i = 0; i < InFeildBuff.Length; i++) { SkillSystem.SkEntity.MountBuff(npc.skEntity, InFeildBuff[i], new List <int>(), new List <float>()); } return(true); }
public static bool CallBackColonyNpcImmediately(PeEntity entity) { if (entity == null) { return(false); } if (entity.NpcCmpt == null) //|| == null || entity.NpcCmpt.Creater.Assembly == null { return(false); } CSCreator creator = entity.NpcCmpt.Creater; if (creator == null) { creator = CSMain.GetCreator(CSConst.ciDefMgCamp); } if (creator == null || creator.Assembly == null) { return(false); } //in assembly radius if (!IsOutRadiu(entity.position, creator.Assembly.Position, creator.Assembly.Radius)) { return(true); } Vector3 backPos = PETools.PEUtil.GetRandomPositionOnGroundForWander(creator.Assembly.Position, creator.Assembly.Radius * 0.7f, creator.Assembly.Radius); if (backPos == Vector3.zero) { backPos = creator.Assembly.Position; } entity.NpcCmpt.Req_Translate(backPos); return(true); }
public CSMedicalTent(CSCreator creator) { m_Creator = creator; m_Type = CSConst.dtTent; // Init Workers m_Workers = new CSPersonnel[WORKER_AMOUNT_MAX]; m_WorkSpaces = new PersonnelSpace[WORKER_AMOUNT_MAX]; for (int i = 0; i < m_WorkSpaces.Length; i++) { m_WorkSpaces[i] = new PersonnelSpace(this); } //allSickbeds = new Sickbed[BED_AMOUNT_MAX]; m_Grade = CSConst.egtLow; if (IsMine) { BindEvent(); } }
// Simulator if need // public CSSimulator m_Simulator; public virtual int Init(CSBuildingLogic csbl, CSCreator creator, bool bFight = true) { this.csbl = csbl; CSEntityAttr attr = new CSEntityAttr(); attr.m_InstanceId = csbl.InstanceId; attr.m_protoId = csbl.protoId; attr.m_Type = (int)csbl.m_Type; attr.m_Pos = csbl.transform.position; attr.m_LogicObj = csbl.gameObject; attr.m_Obj = gameObject; attr.m_Bound = GetObjectBounds(); attr.m_Bound.center = transform.TransformPoint(attr.m_Bound.center); attr.m_ColonyBase = _ColonyObj; int r; r = creator.CreateEntity(attr, out m_Entity); if (r != CSConst.rrtSucceed) { return(r); } m_Creator = creator; m_ObjectId = csbl.InstanceId; // Add ColonyRunner if (bFight) { //--to do: Detectable.cs, if the entity can be attack // if (gameObject.GetComponent<ColonyRunner>() == null) // { // ColonyRunner cr = gameObject.AddComponent<ColonyRunner>(); // cr.m_Entity = m_Entity; // } } return(r); }
// only ColonyNpc public static bool ColonyNpcLostController(PeEntity entity) { if (entity == null) { return(false); } if (entity.NpcCmpt == null) { return(false); } CSCreator creator = entity.NpcCmpt.Creater; if (creator == null || creator.Assembly == null) { return(false); } if (entity.NpcCmpt.Processing) { return(false); } float distance = PETools.PEUtil.MagnitudeH(entity.position, creator.Assembly.Position); if (distance > creator.Assembly.Radius) { Vector3 backPos = PETools.PEUtil.GetRandomPositionOnGroundForWander(creator.Assembly.Position, creator.Assembly.Radius * 0.7f, creator.Assembly.Radius); if (backPos == Vector3.zero) { backPos = creator.Assembly.Position; } entity.NpcCmpt.Req_Translate(backPos); return(true); } return(false); }
//bool bPut = false; public override bool OnCheckPutDown() { //OnItemOpGUIHide(); #if fasle HB_Entity entity = GetComponent <HB_Entity>(); if (entity != null) { if (ColonyManager.Instance == null) { return(false); } EntityMgrInst entityMgr = ColonyManager.Instance.GetEntityMgrSinglePlayer(); BuildingState r = entityMgr.CanRegister(entity); if (r == BuildingState.Succeed) { entity.Register(entityMgr); } // Show message box else if (r == BuildingState.NoAssembly) { MessageBox_N.ShowOkBox( "You need to build an Assembly building with its static field before you can place down other buildings as per colony safety regulations!"); return(false); } else if (r == BuildingState.OutOfMaxCount) { MessageBox_N.ShowOkBox( "The number of buildings of this type allowed by safety regulations in the current static field has been reached!"); return(false); } else if (r == BuildingState.OutOfAssemblyRange) { MessageBox_N.ShowMsgBox(MsgBoxType.Msg_OK, MsgInfoType.Null, "The building cannot be placed outside the static field in compliance with Colony Regulations Article 3 Section 2."); return(false); } } #endif // Put off Colonies if (!m_NotInWaterOrCave) { MessageBox_N.ShowOkBox(PELocalization.GetString(82209011)); return(false); } if (m_CEO != null) { if (bLimited) { MessageBox_N.ShowOkBox(PELocalization.GetString(3002311)); return(false); } CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp); int result = creator.CanCreate((int)m_CEO.m_Type, transform.position); if (result == CSConst.rrtHasAssembly) { MessageBox_N.ShowOkBox( PELocalization.GetString(8000087)); return(false); } else if (result == CSConst.rrtNoAssembly) { MessageBox_N.ShowOkBox( PELocalization.GetString(8000088)); return(false); } else if (result == CSConst.rrtOutOfRange) { MessageBox_N.ShowOkBox( PELocalization.GetString(8000105)); return(false); } else if (result == CSConst.rrtOutOfRadius) { MessageBox_N.ShowOkBox(PELocalization.GetString(8000089)); return(false); } else if (result == CSConst.rrtTooCloseToNativeCamp) { MessageBox_N.ShowOkBox(PELocalization.GetString(ColonyErrorMsg.TOO_CLOSE_TO_NATIVE_CAMP0)); return(false); } else if (result == CSConst.rrtTooCloseToNativeCamp1) { MessageBox_N.ShowOkBox(PELocalization.GetString(ColonyErrorMsg.TOO_CLOSE_TO_NATIVE_CAMP1)); return(false); } else if (result == CSConst.rrtTooCloseToNativeCamp2) { MessageBox_N.ShowOkBox(PELocalization.GetString(ColonyErrorMsg.TOO_CLOSE_TO_NATIVE_CAMP2)); return(false); } else if (result == CSConst.rrtAreaUnavailable) { // MessageBox_N.ShowOkBox(PELocalization.GetString(ColonyErrorMsg.AREA_UNAVAILABLE)); return(false); } m_CEO.m_BoundState = 0; } //bPut = true; return(true); }
public void UpdatePopupList() { if (!m_Active) { _activate(); return; } m_OccupationUI.items.Clear(); if (m_RefNpc == null) { m_OccupationUI.items.Add("None"); return; } //Soldier List <CSEntity> entities = m_RefNpc.GetProtectedEntities(); if (entities != null) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potSoldier)); } //Farm CSMgCreator mgCreator = RefNpc.m_Creator as CSMgCreator; if (null != mgCreator && mgCreator.Assembly != null) { int farmCnt = mgCreator.Assembly.GetEntityCnt(CSConst.ObjectType.Farm); if (farmCnt != 0) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potFarmer)); } } //Doctor CSCreator creator = CSUI_MainWndCtrl.Instance.Creator; if (creator == null) { return; } Dictionary <int, CSCommon> commons = creator.GetCommonEntities(); foreach (KeyValuePair <int, CSCommon> kvp in commons) { if (kvp.Value.Assembly != null && kvp.Value.WorkerMaxCount > 0 && (kvp.Value as CSHealth) != null) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potDoctor)); break; } } //Worker foreach (KeyValuePair <int, CSCommon> kvp in commons) { if (kvp.Value.Assembly != null && kvp.Value.WorkerMaxCount > 0 && (kvp.Value as CSWorkerMachine) != null) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potWorker)); break; } } //Train if (CSUI_MainWndCtrl.Instance.m_Menu.m_TrainingMI.IsShow) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potTrainer)); } //Processor if (CSUI_MainWndCtrl.Instance.m_Menu.m_CollectMI.IsShow) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potProcessor)); } m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potDweller)); //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potWorker)); //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potFarmer)); //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potSoldier)); //if (m_RefNpc.IsRandomNpc)//--to do: test if (m_RefNpc.IsRandomNpc) { m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potFollower)); } //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potProcessor)); //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potDoctor)); //m_OccupationUI.items.Add(CSUtils.GetOccupaName(CSConst.potTrainer)); ShowStatusTips = false; m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); ShowStatusTips = true; }
void AddCSCreatorMission(NpcMissionData missionData) { //if (GameConfig.IsMultiMode) //{ // return; //} CSCreator creator = CSMain.GetCreator(CSConst.ciDefMgCamp); if (creator == null) { return; } if (creator.Assembly == null) { return; } if (m_CurSelNpc != null) { if (m_CurSelNpc.Id < 20000 && m_CurSelNpc.Id > 19990) //冒险模式当中的声望任务id { return; } } int speMisID = 0; if (!m_CurSelNpc.IsRecruited()) { if (!creator.CanAddNpc()) { speMisID = MissionManager.m_SpecialMissionID31; } else { speMisID = MissionManager.m_SpecialMissionID16; } } if (missionData.m_CSRecruitMissionList.Count < 1) { if (speMisID != 0) { m_MissionList.Add(speMisID); } return; } if (missionData.m_CSRecruitMissionList[0] <= 0) { return; } for (int i = 0; i < missionData.m_CSRecruitMissionList.Count; i++) { if (!MissionManager.Instance.HadCompleteMission(missionData.m_CSRecruitMissionList[i])) { return; } } if (speMisID != 0) { m_MissionList.Add(speMisID); } }