Пример #1
0
        /// <summary>
        /// 对于指定辅助厢房,生成候选人列表
        /// </summary>
        /// <param name="bedroomIndex">厢房的建筑 ID</param>
        /// <param name="relatedBuildings">该厢房辅助的建筑信息列表</param>
        /// <returns></returns>
        private List <AuxiliaryBedroomWorker> GetAuxiliaryBedroomWorkers(int bedroomIndex, List <BuildingWorkInfo> relatedBuildings)
        {
            var workers = new List <AuxiliaryBedroomWorker>();

            foreach (var entry in this.workerAttrs)
            {
                int workerId = entry.Key;

                if (this.excludedWorkers.Contains(workerId))
                {
                    continue;
                }

                var attrs = entry.Value;

                workers.Add(new AuxiliaryBedroomWorker
                {
                    actorId             = workerId,
                    integratedAttrValue = HumanResource.GetIntegratedAttrValue(attrs, relatedBuildings),
                    lackedMoodAndFavor  = HumanResource.GetLackedMoodAndFavor(workerId),
                });
            }

            return(workers);
        }
Пример #2
0
        private void AssignBuildingWorkers_PrepareData()
        {
            List <int> workerIds = Original.GetWorkerIds(this.partId, this.placeId);

            workerIds = workerIds.Where(workerId => !this.excludedWorkers.Contains(workerId)).ToList();

            Dictionary <int, List <BuildingWorkInfo> > attrBuildings = this.GetBuildingsNeedWorker();

            //
            this.buildings = new Dictionary <int, BuildingWorkInfo>();
            foreach (var currBuildingWorkInfos in attrBuildings.Values)
            {
                foreach (var info in currBuildingWorkInfos)
                {
                    this.buildings[info.buildingIndex] = info;
                }
            }

            //
            this.workerAttrs    = new Dictionary <int, Dictionary <int, int> >();
            this.attrCandidates = new Dictionary <int, List <int> >();

            foreach (int workerId in workerIds)
            {
                this.workerAttrs[workerId] = new Dictionary <int, int>();
            }

            foreach (int requiredAttrId in attrBuildings.Keys)
            {
                foreach (int workerId in workerIds)
                {
                    // 不需要资质时(厢房),放入好感和心情相对标准状态的差值
                    int attrValue = requiredAttrId != 0 ?
                                    int.Parse(DateFile.instance.GetActorDate(workerId, requiredAttrId)) :
                                    HumanResource.GetLackedMoodAndFavor(workerId);
                    this.workerAttrs[workerId][requiredAttrId] = attrValue;
                }

                List <int> sortedWorkerIds = this.workerAttrs
                                             .OrderByDescending(elem => elem.Value[requiredAttrId])
                                             .Select(elem => elem.Key)
                                             .ToList();
                this.attrCandidates[requiredAttrId] = sortedWorkerIds;
            }
        }