示例#1
0
 void OnPopupListClick()
 {
     if (!m_Active)
     {
         CSUI_StatusBar.ShowText(UIMsgBoxInfo.mCantHandlePersonnel.GetString(), Color.red, 5.5f);
     }
 }
    public static void ShowStatusBar(string text, Color col, float time = 4.5F)
    {
        if (m_Instance == null)
        {
            return;
        }

        CSUI_StatusBar.ShowText(text, col, time);
    }
    public static void ShowStatusBar(string text, float time = 4.5F)
    {
        if (m_Instance == null)
        {
            return;
        }

        CSUI_StatusBar.ShowText(text, new Color(0.0f, 0.2f, 1.0f, 0.0f), time);
    }
示例#4
0
    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);
        }
    }