Ejemplo n.º 1
0
 void SetDoctorIcon(CSPersonnel p)
 {
     if (uiObj != null)
     {
         uiObj.ExamineDoc = p;
     }
 }
Ejemplo n.º 2
0
 void _decreaseOccupationNum(CSPersonnel person, int occupation)
 {
     if (occupation == CSConst.potWorker)
     {
         m_Workers.Remove(person);
         m_WorkerNum = Mathf.Max(0, m_WorkerNum - 1);
     }
     else if (occupation == CSConst.potSoldier)
     {
         m_Soldiers.Remove(person);
         m_SoldierNum = Mathf.Max(0, m_SoldierNum - 1);
     }
     else if (occupation == CSConst.potFarmer)
     {
         m_Farmers.Remove(person);
         m_FarmerNum = Mathf.Max(0, m_FarmerNum - 1);
     }
     else if (occupation == CSConst.potProcessor)
     {
         m_Processors.Remove(person);
         m_ProcessorNum = Mathf.Max(0, m_ProcessorNum - 1);
     }
     else if (occupation == CSConst.potTrainer)
     {
         m_Trainers.Remove(person);
         m_TrainerNum = Mathf.Max(0, m_TrainerNum - 1);
     }
 }
Ejemplo n.º 3
0
    public static List <CSPersonnel> GetTraineeList()
    {
        CSMgCreator creator = null;

        creator = s_MgCreator;
        List <CSPersonnel> result = new List <CSPersonnel>();

        if (s_MgCreator.Assembly == null)
        {
            return(null);
        }
        CSTraining cst = s_MgCreator.Assembly.TrainingCenter;

        if (cst == null)
        {
            return(null);
        }
        foreach (int id in cst.TraineeList)
        {
            CSPersonnel csp = creator.GetNpc(id);
            if (csp != null)
            {
                result.Add(csp);
            }
        }
        return(result);
    }
Ejemplo n.º 4
0
 protected void ExecuteEventPersonnel(int event_type, CSPersonnel p)
 {
     if (m_EventListenserPer != null)
     {
         m_EventListenserPer(event_type, p);
     }
 }
Ejemplo n.º 5
0
    public void AddNpc(CSPersonnel npc)
    {
        //--to do:
        if (npcList.Contains(npc))
        {
            return;
        }
        //not in processing
        if (cs == null)
        {
            npcList.Add(npc);
            npc.IsProcessing = false;
        }
        //in processing
        else
        {
//            float currentParam = GetFullWorkerParam(npcList);
//            float newParam = GetFullWorkerParam(GenNewNpcList(npcList, npc, true));
//            float changeParam = newParam / currentParam;
//
//
//            cs.Init(cs.CurCounter * changeParam, cs.FinalCounter * changeParam);
            npcList.Add(npc);
            float curPercent = cs.CurCounter / cs.FinalCounter;
            float finalNew   = CountTime();
            float curNew     = finalNew * curPercent;
            cs.Init(curNew, finalNew);
            npc.IsProcessing = true;
        }
    }
Ejemplo n.º 6
0
    public virtual bool AddWorker(CSPersonnel npc)
    {
        if (m_Workers == null)
        {
            Debug.LogWarning("There are not workers in this common entity.");
            return(false);
        }
        foreach (CSPersonnel pl in m_Workers)
        {
            if (pl != null && pl == npc)
            {
                return(true);
            }
        }
        for (int i = 0; i < m_Workers.Length; i++)
        {
            if (m_Workers[i] == null)
            {
                m_Workers[i] = npc;

                return(true);
            }
        }

        return(false);
    }
Ejemplo n.º 7
0
 public void RemoveNpc(CSPersonnel npc)
 {
     if (!npcList.Contains(npc))
     {
         return;
     }
     //not in processing
     if (cs == null)
     {
         npcList.Remove(npc);
     }
     //in processing
     else
     {
         npcList.Remove(npc);
         if (npcList.Count == 0)
         {
             StopCounter();
         }
         else
         {
             float curPercent = cs.CurCounter / cs.FinalCounter;
             float finalNew   = CountTime();
             float curNew     = finalNew * curPercent;
             cs.Init(curNew, finalNew);
         }
     }
     npc.IsProcessing = false;
 }
Ejemplo n.º 8
0
    public void SetNpcIsTraining(bool flag)
    {
        CSPersonnel instructorNpc = m_MgCreator.GetNpc(InstructorNpcId);
        CSPersonnel traineeNpc    = m_MgCreator.GetNpc(TraineeNpcId);

        if (instructorNpc != null)
        {
            instructorNpc.IsTraining   = flag;
            instructorNpc.trainingType = trainingType;
            if (!flag)
            {
                InstructorNpcId = -1;
            }
        }
        else
        {
            InstructorNpcId = -1;
        }
        if (traineeNpc != null)
        {
            traineeNpc.IsTraining   = flag;
            traineeNpc.trainingType = trainingType;
            if (!flag)
            {
                TraineeNpcId = -1;
            }
        }
        else
        {
            TraineeNpcId = -1;
        }
    }
Ejemplo n.º 9
0
    public bool CheckNpc()
    {
        if (InstructorNpcId <= 0 || TraineeNpcId <= 0)
        {
            return(false);
        }
        CSPersonnel instructorP = m_MgCreator.GetNpc(InstructorNpcId);

        if (instructorP == null)
        {
            return(false);
        }
        if (instructorP.Occupation != CSConst.potTrainer)
        {
            InstructorList.Remove(instructorP.ID);
            instructorP.trainerType = ETrainerType.none;
            InstructorNpcId         = -1;
            return(false);
        }
        CSPersonnel traineeP = m_MgCreator.GetNpc(TraineeNpcId);

        if (traineeP == null)
        {
            return(false);
        }
        if (traineeP.Occupation != CSConst.potTrainer)
        {
            TraineeList.Remove(traineeP.ID);
            traineeP.trainerType = ETrainerType.none;
            TraineeNpcId         = -1;
            return(false);
        }
        return(true);
    }
Ejemplo n.º 10
0
    public bool AddInstructor(CSPersonnel p)
    {
        if (InstructorList.Contains(p.ID))
        {
            return(true);
        }
        if (InstructorList.Count >= MAX_INSTRUCTOR_NUM)
        {
            return(false);
        }
        if (TraineeNpcId == p.ID)
        {
            if (m_Counter != null)
            {
                StopCounter();
            }
            TraineeNpcId = -1;
        }
        TraineeList.Remove(p.ID);
        InstructorList.Add(p.ID);
        p.trainerType = ETrainerType.Instructor;

        UpdateUI();
        return(true);
    }
Ejemplo n.º 11
0
    public bool AddTrainee(CSPersonnel p)
    {
        if (TraineeList.Contains(p.ID))
        {
            return(true);
        }
        if (TraineeList.Count >= MAX_TRAINEE_NUM)
        {
            return(false);
        }
        if (InstructorNpcId == p.ID)
        {
            if (m_Counter != null)
            {
                StopCounter();
            }
            InstructorNpcId = -1;
        }
        InstructorList.Remove(p.ID);
        TraineeList.Add(p.ID);
        p.trainerType = ETrainerType.Trainee;

        UpdateUI();
        return(true);
    }
Ejemplo n.º 12
0
 void UpdataGridTime(CSPersonnel p, float timeLeft)
 {
     if (uiObj != null)
     {
         uiObj.UpdateNpcGridTime(p, timeLeft);
     }
 }
Ejemplo n.º 13
0
 void SetNurseIcon(CSPersonnel p)
 {
     if (uiObj != null)
     {
         uiObj.Nurse = p;
     }
 }
Ejemplo n.º 14
0
 void SetPatientIcon(CSPersonnel p)
 {
     if (uiObj != null)
     {
         uiObj.ExaminedPatient = p;
     }
 }
Ejemplo n.º 15
0
    //private Dictionary<int, FarmPlantLogic> m_WorkingPlants;
    //private Dictionary<int, int>  m_WorkingPlantsHelp;
    //private Dictionary<int, Vector3> m_WorkingPlantPos;

    //private Dictionary<int, ClodChunk> m_WorkingChunks;


    public CSFarm()
    {
        m_Type = CSConst.etFarm;

        // Init Workers
        m_Workers = new CSPersonnel[MAX_WORKER_COUNT];

        m_WorkSpaces    = new PersonnelSpace[1];
        m_WorkSpaces[0] = new PersonnelSpace(this);

        m_Plants = new Dictionary <int, FarmPlantLogic>();
        //m_WateringIDs = new Queue<int>();
        //m_CleaningIDs = new Queue<int>();
        //m_DeadIDs	  = new Queue<int>();
        //m_RipedIDs    = new Queue<int>();
        //m_WorkingPlants = new Dictionary<int, FarmPlantLogic>();
        //m_WorkingPlantsHelp = new Dictionary<int, int>();
        //m_WorkingPlantPos = new Dictionary<int, Vector3>();

        m_WateringIds = new List <int>();
        m_CleaningIds = new List <int>();
        m_RipedIds    = new List <int>();
        m_DeadIds     = new List <int>();

        //m_WorkingChunks = new Dictionary<int, ClodChunk>();

        m_Grade = CSConst.egtLow;
    }
Ejemplo n.º 16
0
    public bool CheckNpcPosition()
    {
        if (InstructorNpcId <= 0 || TraineeNpcId <= 0)
        {
            return(false);
        }
        CSPersonnel instructorP = m_MgCreator.GetNpc(InstructorNpcId);

        if (instructorP == null)
        {
            return(false);
        }
        if ((instructorP.m_Pos - Position).magnitude > 4)
        {
            return(false);
        }
        CSPersonnel traineeP = m_MgCreator.GetNpc(TraineeNpcId);

        if (traineeP == null)
        {
            return(false);
        }
        if ((traineeP.m_Pos - Position).magnitude > 4)
        {
            return(false);
        }
        //Debug.Log(""+(instructorP.m_Pos -Position).magnitude+","+(instructorP.m_Pos -Position).magnitude);
        return(true);
    }
Ejemplo n.º 17
0
    public virtual void RemoveWorker(CSPersonnel npc)
    {
        if (m_Workers == null)
        {
            Debug.LogWarning("There are not workers in this common entity.");
            return;
        }

        for (int i = 0; i < m_Workers.Length; i++)
        {
            if (m_Workers[i] == npc)
            {
                for (int j = 0; j < m_WorkSpaces.Length; j++)
                {
                    if (m_WorkSpaces[j].m_Person == m_Workers[i])
                    {
                        m_WorkSpaces[j].m_Person = null;
                        break;
                    }
                }

                m_Workers[i] = null;
                break;
            }
        }
    }
Ejemplo n.º 18
0
    public override void RemoveWorker(CSPersonnel npc)
    {
        base.RemoveWorker(npc);
        if (InstructorNpcId == npc.ID)
        {
            if (m_Counter != null)
            {
                StopCounter();
            }
            TraineeNpcId = -1;
        }

        if (TraineeNpcId == npc.ID)
        {
            if (m_Counter != null)
            {
                StopCounter();
            }
            TraineeNpcId = -1;
        }
        InstructorList.Remove(npc.ID);
        TraineeList.Remove(npc.ID);

        UpdateUI();
    }
Ejemplo n.º 19
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;
        }
    }
Ejemplo n.º 20
0
 void SetDoctorIcon(CSPersonnel npc)
 {
     if (uiObj != null)
     {
         uiObj.TreatDoc = npc;
     }
 }
Ejemplo n.º 21
0
    public override bool AddWorker(CSPersonnel npc)
    {
        bool flag = base.AddWorker(npc);

        RecountCounter();
        return(flag);
    }
Ejemplo n.º 22
0
 void SetPatientIcon(CSPersonnel npc)
 {
     if (uiObj != null)
     {
         uiObj.TreatmentPatient = npc;
     }
 }
Ejemplo n.º 23
0
    public bool AddNpcs(CSPersonnel npc)
    {
        if (npc == null)
        {
            return(false);
        }

        for (int i = 0; i < m_NPCS.Length; i++)
        {
            if (m_NPCS[i] == null)
            {
                m_NPCS[i] = npc;

                //if (m_Object != null)
                //{
                //    CSDwellingsObject csdo = m_Object.GetComponent<CSDwellingsObject>();
                //    if (csdo == null)
                //        continue;
                //    npc.RestTrans = csdo.m_BedTrans[i];
                //    npc.RestStandTrans = csdo.m_BedEdgeTrans[i];
                //}
                npc.Bed = m_Beds;


                npc.Dwellings = this;
                return(true);
            }
        }

        return(false);
    }
 void OnTraineeSetBtn()
 {
     if (null != CSUI_TrainMgr.Instance)
     {
         TraineeNpc = CSUI_TrainMgr.Instance.RefNpc;
     }
 }
Ejemplo n.º 25
0
    // Remove a NPC grid which reference the npc
    public void RemovePersonnel(CSPersonnel npc)
    {
        if (npc == null)
        {
            Debug.LogWarning("The giving npc is null");
        }

        List <CSUI_NPCGrid> npc_grids_list = null;

        if (npc.IsRandomNpc)
        {
            npc_grids_list = m_OtherGrids;
        }
        else
        {
            npc_grids_list = m_MainLineGrids;
        }

        int index = npc_grids_list.FindIndex(item0 => item0.m_Npc == npc);

        if (index != -1)
        {
            bool oldIsChecked = npc_grids_list[index].gameObject.GetComponent <UICheckbox>().isChecked;
            DestroyImmediate(npc_grids_list[index].gameObject);
            npc_grids_list.RemoveAt(index);
            //lz-2016.08.29 删除后要刷新当前应该显示的范围,避免后面还有几排会留空的情况
            GridRange();

            //lz-2016.08.29 重写删除一个npc,选中转移方法
            if (oldIsChecked)
            {
                if (npc_grids_list.Count > 0)
                {
                    int startIndex = mGridPageIndex * NPC_GRID_COUNT;
                    int EndIndex   = Mathf.Min(startIndex + NPC_GRID_COUNT - 1, npc_grids_list.Count - 1);
                    //1.删除一个npc,它的index会被后面替代,如果存在并没有超出显示范围就选中替代的,超出的话限制在最大或者最小
                    int newIndex = 0;
                    //lz-2016.10.23 错误 #5077 数组越界
                    if (startIndex >= EndIndex)
                    {
                        newIndex = EndIndex;
                    }
                    else
                    {
                        newIndex = Mathf.Clamp(index, startIndex, EndIndex);
                    }
                    npc_grids_list[newIndex].gameObject.GetComponent <UICheckbox>().isChecked = true;
                }
                else
                {
                    ActiveNpcGrid = null;
                }
            }
        }
        else
        {
            Debug.LogWarning("The giving npc is not a Settler");
        }
    }
Ejemplo n.º 26
0
 public void UpdateNpcGrids()
 {
     for (int i = 0; i < m_NpcGrids.Count; i++)
     {
         CSPersonnel worker = m_Farm.Worker(i);
         m_NpcGrids[i].m_Npc = worker;
     }
 }
Ejemplo n.º 27
0
 public void NpcLineChange(CSPersonnel npc, int oldIndex, int newIndex)
 {
     RemoveNpcFromTask(npc, oldIndex);
     AddNpcToTask(npc, newIndex);
     UpdateLineToUI(oldIndex);
     UpdateLineToUI(newIndex);
     UpdateSelectedTask();
 }
Ejemplo n.º 28
0
 public override void RemoveWorker(CSPersonnel npc)
 {
     base.RemoveWorker(npc);
     if (npc.ProcessingIndex >= 0)
     {
         npc.ProcessingIndex = -1;
     }
 }
Ejemplo n.º 29
0
    void OnOccupationChange(CSPersonnel person, int prvState)
    {
        if (person != m_RefNpc)
        {
            return;
        }

        UpdateModeUI();
    }
Ejemplo n.º 30
0
 public void AddNpcToTask(CSPersonnel npc, int index)
 {
     if (mTaskTable[index] == null)
     {
         mTaskTable[index] = new ProcessingTask();
     }
     mTaskTable[index].AddNpc(npc);
     UpdateLineToUI(index);
 }