//called by mainplayer public static bool SetNpcFollower(PeEntity npc) { CSPersonnel csp = GetColonyNpc(npc.Id); if (csp != null) { if (csp.TrySetOccupation(CSConst.potFollower)) { return(npc.SetFollower(true)); } return(false); } return(npc.SetFollower(true)); }
void OnSelectionChange(string item) { if (null == m_RefNpc || null == m_RefNpc.NPC) { return; } //lz-2016.09.14 npc死亡之后不可以切换职业 if (m_RefNpc.NPC.aliveEntity.isDead) { CSUI_StatusBar.ShowText(UIMsgBoxInfo.mNpdDeadNotChangeProfession.GetString(), Color.red, 5.5f); m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); return; } HideAllProfessionalSpr(); if (item == CSUtils.GetOccupaName(CSConst.potDweller)) { if (m_RefNpc.TrySetOccupation(CSConst.potDweller)) { m_DwellerIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForDweller.GetString(), m_RefNpc.FullName), 5.5f); } } else { //lz-2016.10.26 不能去直接设置m_OccupationUI.textLabel.text的值,那样m_OccupationUI.selection没有被改变,影响UIPoupList的正常功能 m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } else if (item == CSUtils.GetOccupaName(CSConst.potWorker)) { if (m_RefNpc.TrySetOccupation(CSConst.potWorker)) { m_WorkerIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForWorker.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } else if (item == CSUtils.GetOccupaName(CSConst.potFarmer)) { if (CSMain.s_MgCreator.Farmers.Count >= CSFarm.MAX_WORKER_COUNT) { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.OCCUPATION_NPC_TOO_MANY), m_RefNpc.FullName), 5.5f); } return; } if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potFarmer)) { m_FarmerIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForFarmer.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } else if (item == CSUtils.GetOccupaName(CSConst.potSoldier)) { if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potSoldier)) { m_SoldierIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForSolider.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } else if (item == CSUtils.GetOccupaName(CSConst.potFollower)) { if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potFollower)) { m_FollowerIcomUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForFollower.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } else if (item == CSUtils.GetOccupaName(CSConst.potProcessor)) { if (CSMain.s_MgCreator.Processors.Count >= ProcessingConst.WORKER_AMOUNT_MAX) { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(PELocalization.GetString(ColonyMessage.OCCUPATION_NPC_TOO_MANY), m_RefNpc.FullName), 5.5f); } return; } if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potProcessor)) { m_ProcessorIcomUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForProcessor.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } else if (item == CSUtils.GetOccupaName(CSConst.potDoctor)) { if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potDoctor)) { m_DoctorIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForDoctor.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } else if (item == CSUtils.GetOccupaName(CSConst.potTrainer)) { if (m_RefNpc != null) { if (m_RefNpc.TrySetOccupation(CSConst.potTrainer)) { m_InstructorIconUI.enabled = true; if (onSelectChange != null) { onSelectChange(item); } if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionForInstructor.GetString(), m_RefNpc.FullName), 5.5f); } } else { m_OccupationUI.selection = CSUtils.GetOccupaName(m_RefNpc.m_Occupation); if (ShowStatusTips) { CSUI_MainWndCtrl.ShowStatusBar(CSUtils.GetNoFormatString(UIMsgBoxInfo.mProfessionFailed.GetString(), m_RefNpc.FullName), 5.5f); } } } } if (GameConfig.IsMultiMode) { //--to do: wait //if(m_RefNpc.m_Npc.Netlayer is AiAdNpcNetwork) // ((AiAdNpcNetwork)m_RefNpc.m_Npc.Netlayer).SetClnOccupation(m_RefNpc.m_Occupation); } }