Ejemplo n.º 1
0
    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;
    }
Ejemplo n.º 2
0
    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;
                                }
                            }
                        }
                    }
                }
            }
        }
        //}
    }
Ejemplo n.º 3
0
    void RefreshMenu()
    {
        HideAllMenu();
        m_ActiveMenuList.Clear();

        //lz-22016.10.16 Personnel界面无条件开启
        m_Menu.m_PersonnelMI.gameObject.SetActive(true);
        m_ActiveMenuList.Add(m_Menu.m_PersonnelMI);

        bool value = (m_Creator.Assembly != null) ? true : false;

        if (value)
        {
            m_Menu.m_AssemblyMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_AssemblyMI);
        }

        m_Menu.m_AssemblyMI.m_EntityList.Clear();
        m_Menu.m_AssemblyMI.m_EntityList.Add(m_Creator.Assembly);

        // Clear MI EntityList
        m_Menu.m_PPCoalMI.m_EntityList.Clear();
        m_Menu.m_FarmMI.m_EntityList.Clear();
        m_Menu.m_FactoryMI.m_EntityList.Clear();
        m_Menu.m_StorageMI.m_EntityList.Clear();
        m_Menu.m_EngineeringlMI.m_EntityList.Clear();
        m_Menu.m_DwellingsMI.m_EntityList.Clear();
        m_Menu.m_HospitalMI.m_EntityList.Clear();
        m_Menu.m_TrainingMI.m_EntityList.Clear();

        //luwei
        m_Menu.m_TransactionMI.m_EntityList.Clear();
        m_Menu.m_CollectMI.m_EntityList.Clear();

        Dictionary <int, CSCommon> entities = m_Creator.GetCommonEntities();

        foreach (CSCommon entity in entities.Values)
        {
            //			if(!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockColony(entity.m_Type))
            //				continue;
            switch (entity.m_Type)
            {
            // PPCoalMI
            case CSConst.dtPowerPlant:
            case CSConst.dtppCoal:
            case CSConst.dtppSolar:
            case CSConst.dtppFusion:     //lz-2016.07.23 添加核电站
            {
                m_Menu.m_PPCoalMI.m_EntityList.Add(entity);
            }
            break;

            //Farm
            case CSConst.dtFarm:
            {
                m_Menu.m_FarmMI.m_EntityList.Add(entity);
            }
            break;

            //Factory
            case CSConst.dtFactory:
            {
                m_Menu.m_FactoryMI.m_EntityList.Add(entity);
            }
            break;

            // Storage
            case CSConst.dtStorage:
            {
                m_Menu.m_StorageMI.m_EntityList.Add(entity);
            }
            break;

            // Engineering
            case CSConst.dtEnhance:
            case CSConst.dtRepair:
            case CSConst.dtRecyle:
            {
                m_Menu.m_EngineeringlMI.m_EntityList.Add(entity);
            }
            break;

            //Dwellings
            case CSConst.dtDwelling:
            {
                m_Menu.m_DwellingsMI.m_EntityList.Add(entity);
            }
            break;

            //Transaction
            case CSConst.dtTrade:
            {
                m_Menu.m_TransactionMI.m_EntityList.Add(entity);
            }
            break;

            //Collect
            case CSConst.dtProcessing:
            {
                m_Menu.m_CollectMI.m_EntityList.Add(entity);
            }
            break;

            //Hospital
            case CSConst.dtCheck:
            case CSConst.dtTreat:
            case CSConst.dtTent:
            {
                m_Menu.m_HospitalMI.m_EntityList.Add(entity);
            }
            break;

            //Train
            case CSConst.dtTrain:
            {
                m_Menu.m_TrainingMI.m_EntityList.Add(entity);
            }
            break;
            }
        }

        // PPCoalMI
        value = (m_Menu.m_PPCoalMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_PPCoalMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_PPCoalMI);
        }

        //Farm
        value = (m_Menu.m_FarmMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_FarmMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_FarmMI);
        }

        //Factory
        value = (m_Menu.m_FactoryMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_FactoryMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_FactoryMI);
        }

        // Storage
        value = (m_Menu.m_StorageMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_StorageMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_StorageMI);
        }

        //Engineering
        value = (m_Menu.m_EngineeringlMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_EngineeringlMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_EngineeringlMI);
        }

        //Dwellings
        value = (m_Menu.m_DwellingsMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_DwellingsMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_DwellingsMI);
        }

        //Transaction
        value = (m_Menu.m_TransactionMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_TransactionMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_TransactionMI);
        }

        //Collect
        value = (m_Menu.m_CollectMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_CollectMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_CollectMI);
        }

        //Hospital
        value = (m_Menu.m_HospitalMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_HospitalMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_HospitalMI);
        }

        //Train
        value = (m_Menu.m_TrainingMI.m_EntityList.Count) > 0 ? true : false;
        if (value)
        {
            m_Menu.m_TrainingMI.gameObject.SetActive(true);
            m_ActiveMenuList.Add(m_Menu.m_TrainingMI);
        }

        m_Menu.mLeftMenuGrid.repositionNow = true;
    }
Ejemplo n.º 4
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;
    }