Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_OldRefNpc != m_RefNpc)
        {
            //lz-2016.10.10 每次更新要清除以前的Entities
            ClearEntites();
//            CSCreator creator = CSUI_MainWndCtrl.Instance.Creator;
            List <CSEntity> entities = m_RefNpc.GetProtectedEntities();
            m_RefNpc.GuardEntities = entities;
            if (entities != null)
            {
                foreach (CSEntity cse in entities)
                {
                    CSUI_EntityState es = Instantiate(m_EntityStatePrefab) as CSUI_EntityState;
                    es.transform.parent        = m_EntityRootUI.transform;
                    es.transform.localPosition = Vector3.zero;
                    es.transform.localRotation = Quaternion.identity;
                    es.transform.localScale    = Vector3.one;

                    es.m_RefCommon = cse;

                    m_EntitesState.Add(es);

                    cse.AddEventListener(OnEntityEventListener);
                }

                m_EntityRootUI.repositionNow = true;
                m_ScrollBar.scrollValue      = 0;
            }

            m_OldRefNpc = m_RefNpc;
        }
    }
Пример #2
0
    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;
    }