/// <summary> /// 是否升级排序点击 /// </summary> public void OnClickForWorker(WorkerEnum worker, WorkerDetilsEnum workerDetils) { AudioHandler.Instance.PlaySound(AudioSoundEnum.ButtonForNormal); this.listCharacterData = this.listCharacterData.OrderByDescending( (data) => { int workNumber = 0; CharacterWorkerBaseBean workerData = data.baseInfo.GetWorkerInfoByType(worker); if (worker == WorkerEnum.Chef || worker == WorkerEnum.Beater || worker == WorkerEnum.Accountant) { if (workerData.isWorking) { workNumber++; } } else if (worker == WorkerEnum.Waiter) { CharacterWorkerForWaiterBean waiterData = workerData as CharacterWorkerForWaiterBean; if (workerDetils == WorkerDetilsEnum.WaiterForCleanBed && waiterData.isWorkingCleanBed) { workNumber++; } if (workerDetils == WorkerDetilsEnum.WaiterForCleanTable && waiterData.isWorkingForCleanTable) { workNumber++; } if (workerDetils == WorkerDetilsEnum.WaiterForSend && waiterData.isWorkingForSend) { workNumber++; } } else if (worker == WorkerEnum.Accost) { CharacterWorkerForAccostBean accostData = workerData as CharacterWorkerForAccostBean; if (workerDetils == WorkerDetilsEnum.AccostForSolicit && accostData.isWorkingForSolicit) { workNumber++; } if (workerDetils == WorkerDetilsEnum.AccostForGuide && accostData.isWorkingForGuide) { workNumber++; } } return(workNumber); }).ToList(); InitData(); }
/// <summary> /// 通过不同的工作类型分配不同的工作 /// </summary> public bool DistributionWorkForType(WorkerDetilsEnum workDetailsType, NpcAIWorkerCpt workNpc) { switch (workDetailsType) { case WorkerDetilsEnum.AccountantForPay: if (!CheckUtil.ListIsNull(innPayHandler.listCounterCpt)) { for (int i = 0; i < innPayHandler.listCounterCpt.Count; i++) { BuildCounterCpt counterCpt = innPayHandler.listCounterCpt[i]; if (!CheckUtil.ListIsNull(counterCpt.payQueue)) { bool isSuccess = innPayHandler.SetPay(counterCpt.payQueue[0], workNpc); if (isSuccess) { counterCpt.payQueue.RemoveAt(0); return(true); } } } } break; case WorkerDetilsEnum.ChefForCook: //排队做菜处理 if (!CheckUtil.ListIsNull(foodQueue)) { bool isSuccess = innCookHandler.SetChefForCook(foodQueue[0], workNpc); if (isSuccess) { foodQueue.RemoveAt(0); return(true); } } break; case WorkerDetilsEnum.WaiterForSend: //排队送菜处理 if (!CheckUtil.ListIsNull(sendQueue)) { OrderForCustomer orderForSend = sendQueue[0]; bool isSuccess = innWaiterHandler.SetSendFood(orderForSend, workNpc); if (isSuccess) { sendQueue.Remove(orderForSend); return(true); } } break; case WorkerDetilsEnum.WaiterForCleanTable: //排队清理处理 if (!CheckUtil.ListIsNull(cleanQueue)) { //搜寻最近的桌子 OrderForCustomer clearItem = null; float distance = float.MaxValue; for (int i = 0; i < cleanQueue.Count; i++) { OrderForCustomer itemOrder = cleanQueue[i]; float tempDistance = Vector3.Distance(itemOrder.table.GetTablePosition(), workNpc.transform.position); if (tempDistance < distance) { distance = tempDistance; clearItem = itemOrder; } } if (clearItem == null) { return(false); } bool isSuccess = innWaiterHandler.SetCleanFood(clearItem, workNpc); if (isSuccess) { cleanQueue.Remove(clearItem); return(true); } } break; case WorkerDetilsEnum.WaiterForCleanBed: //排队床单清理处理 if (!CheckUtil.ListIsNull(bedCleanQueue)) { OrderForHotel orderForHotel = bedCleanQueue[0]; bool isSuccess = innWaiterHandler.SetCleanBed(orderForHotel, workNpc); if (isSuccess) { bedCleanQueue.Remove(orderForHotel); return(true); } } break; case WorkerDetilsEnum.AccostForSolicit: workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.AccostSolicit); return(true); case WorkerDetilsEnum.AccostForGuide: //等待接待 if (!CheckUtil.ListIsNull(hotelQueue)) { OrderForHotel orderForHotel = hotelQueue[0]; workNpc.SetIntent(NpcAIWorkerCpt.WorkerIntentEnum.AccostGuide, orderForHotel); hotelQueue.Remove(orderForHotel); return(true); } break; case WorkerDetilsEnum.BeaterForDrive: //分派打架人选 if (!CheckUtil.ListIsNull(rascalrQueue)) { NpcAIRascalCpt npcAIRascal = innFightHandler.SetFight(rascalrQueue, workNpc); if (npcAIRascal) { //rascalrQueue.Remove(npcAIRascal); return(true); } } break; } return(false); }
/// <summary> /// 通过优先级设置工作 /// </summary> public bool SetWorkByPriority() { //如果该工作者此时空闲 if (workerIntent != WorkerIntentEnum.Idle) { return(false); } for (int i = 0; i < listWorkerDetailsType.Count; i++) { WorkerDetilsEnum workerDetils = listWorkerDetailsType[i]; CharacterWorkerBaseBean characterWorker; switch (workerDetils) { case WorkerDetilsEnum.ChefForCook: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Chef); if (!characterWorker.isWorking) { continue; } break; case WorkerDetilsEnum.WaiterForSend: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Waiter); if (!((CharacterWorkerForWaiterBean)characterWorker).isWorkingForSend) { continue; } break; case WorkerDetilsEnum.WaiterForCleanTable: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Waiter); if (!((CharacterWorkerForWaiterBean)characterWorker).isWorkingForCleanTable) { continue; } break; case WorkerDetilsEnum.WaiterForCleanBed: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Waiter); if (!((CharacterWorkerForWaiterBean)characterWorker).isWorkingCleanBed) { continue; } break; case WorkerDetilsEnum.AccountantForPay: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Accountant); if (!characterWorker.isWorking) { continue; } break; case WorkerDetilsEnum.AccostForSolicit: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Accost); if (!((CharacterWorkerForAccostBean)characterWorker).isWorkingForSolicit) { continue; } break; case WorkerDetilsEnum.AccostForGuide: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Accost); if (!((CharacterWorkerForAccostBean)characterWorker).isWorkingForGuide) { continue; } break; case WorkerDetilsEnum.BeaterForDrive: characterWorker = characterData.baseInfo.GetWorkerInfoByType(WorkerEnum.Beater); if (!characterWorker.isWorking) { continue; } break; } bool isDistributionSuccess = InnHandler.Instance.DistributionWorkForType(workerDetils, this); if (isDistributionSuccess) { return(true); } } return(false); }