public bool canFireStaff(serviceTypes employeeType) { /// room types: other(0), reception(1), bedroom(2), kitchen(3), dining(4), exit(5), hallway(6) switch (employeeType) { case serviceTypes.reception: return(0 < busyWaitStaff && busyWaitStaff <= waitStaff); //break; case serviceTypes.bedroom: return(0 < busyCleaningStaff && busyCleaningStaff <= cleaningStaff); //break; case serviceTypes.kitchen: return(0 < busyCookStaff && busyCookStaff <= cookStaff); //break; case serviceTypes.dining: return(0 < busyWaitStaff && busyWaitStaff <= waitStaff); //break; default: Debug.LogError("Invalid staff fire check."); return(false); //break; } }
public void hireStaff(serviceTypes employeeType) { switch (employeeType) { case serviceTypes.reception: busyWaitStaff++; break; case serviceTypes.bedroom: busyCleaningStaff++; break; case serviceTypes.kitchen: busyCookStaff++; break; case serviceTypes.dining: busyWaitStaff++; break; default: Debug.LogError("Invalid staff fire."); break; } updateTotalEmployeeText(); }
/// <summary> /// references need to be changed to getBestCustomerRoom (deprecated) /// </summary> /// <param name="basePoint"></param> /// <param name="roomType"></param> /// <returns></returns> public Transform findClosestFreeRoomNode(Transform basePoint, serviceTypes roomType) { Transform bestRoom = emptyTransform; float shortestDistance = Vector3.Distance(basePoint.position, bestRoom.position); float tempDistance; for (int i = 0; i < nodeGrid.Count; i++) { for (int j = 0; j < nodeGrid[i].Count; j++) { if (nodeGrid[i][j].GetComponent <Node>().roomType == roomType) { if (bestRoom == emptyTransform) { bestRoom = nodeGrid[i][j]; } else { tempDistance = Vector3.Distance(basePoint.position, nodeGrid[i][j].position); if (tempDistance < shortestDistance) { bestRoom = nodeGrid[i][j]; shortestDistance = tempDistance; } } } } } if (bestRoom == GameObject.Find("EmptyTransform").transform) { return(nodeGrid[0][0]); } return(bestRoom); }
public void setRoom(serviceTypes setRoom, facingDirection curFaceDirection) { //print("setRoom roomType: " + roomType); roomType = setRoom; currentFaceDirection = curFaceDirection; GetComponent <ServiceQueue>().initServices(setRoom); //do space check for available paths }
// Start is called before the first frame update void Start() { angerTimer = 0.0f; gridRef = GameObject.Find("PathManager").GetComponent <CreateGrid>(); gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); //find nearest reception and queue up currentServiceState = serviceTypes.reception; }
// Start is called before the first frame update void Awake() { roomType = serviceTypes.hallway; currentFaceDirection = facingDirection.forward; possiblePaths = new Transform[4]; for (int i = 0; i < 4; i++) { possiblePaths[i] = GameObject.Find("EmptyTransform").transform; } }
// Start is called before the first frame update void Start() { angerTimer = 0.0f; gridRef = GameObject.Find("PathManager").GetComponent <CreateGrid>(); gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); //find nearest reception and queue up currentServiceState = serviceTypes.reception; onDestinationCall = findNextDestination(); onDestinationCall.GetComponent <ServiceQueue>().customerTraveling.Add(this.transform); GetComponent <NodeList>().travel(onDestinationCall, startWaitCall); currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>(); //GetComponent<NodeList>().travel(gridRef.nodeGrid[8][8], startWaitCall); }
private void updateWorkingEmployees() { busyWaitStaff = 0; busyCookStaff = 0; busyCleaningStaff = 0; for (int i = 0; i < nodeGrid.Count; i++) { for (int j = 0; j < nodeGrid[i].Count; j++) { ServiceQueue sQ = nodeGrid[i][j].GetComponent <ServiceQueue>(); serviceTypes currentService = sQ.serviceType; if (currentService != serviceTypes.other && currentService != serviceTypes.exit && currentService != serviceTypes.hallway) { //room types: other, reception, bedroom, kitchen, dining, exit, hallway switch (currentService) { case serviceTypes.reception: busyWaitStaff += sQ.curEmployees; break; case serviceTypes.bedroom: busyCleaningStaff += sQ.curEmployees; break; case serviceTypes.kitchen: busyCookStaff += sQ.curEmployees; break; case serviceTypes.dining: busyWaitStaff += sQ.curEmployees; break; default: //do nothing break; } } } } workingEmployees = busyWaitStaff + busyCookStaff + busyCleaningStaff; }
// Update is called once per frame void Update() { if (isBeingServed) { isAngry = false; curTimer -= Time.deltaTime; if (curTimer < 0) { //move to next task if (currentServiceState == serviceTypes.reception) { currentServiceState = serviceTypes.bedroom; //travel to bedroom => wait on clean => sleep } else if (currentServiceState == serviceTypes.bedroom) { currentServiceState = serviceTypes.kitchen; //travel to kitchen => wait => eat } else if (currentServiceState == serviceTypes.kitchen) { currentServiceState = serviceTypes.exit; //travel to exit => destroy self GetComponent <NodeList>().travel(gridRef.nodeGrid[0][0], destroyMe); } else { print("npc is lost on improper service state"); print("exiting npc....."); GetComponent <NodeList>().travel(gridRef.nodeGrid[0][0], destroyMe); } } } else if (isWaiting) { if (curTimer > 0.0f) { curTimer -= Time.deltaTime; } else { isAngry = true; } } if (isAngry) { angerTimer += Time.deltaTime; if (angerTimer >= maxAngerTime) { isAngry = true; gameManager.decrement(20); //unoccupy hotel room GetComponent <NodeList>().travel( gridRef.nodeGrid[0][0], destroyMe ); } } }
// Update is called once per frame void Update() { if (isBeingServed) { isAngry = false; curTimer -= Time.deltaTime; //print("being serviced"); Transform dummyDestination = gridRef.nodeGrid[1][1]; if (curTimer <= 0) { //move to next task if (currentServiceState == serviceTypes.reception) { currentServiceQueue.customerServed(); currentServiceState = serviceTypes.bedroom; onDestinationCall = findNextDestination(); //remove from old service queue //travel to bedroom => wait on clean => sleep //customerServed() call here.... gameManager.charge(100.0f); Camera.main.transform.GetComponent <ObjectPlacer>().PlaySfx(0); currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>(); //print("onDestinationCall: " + onDestinationCall.position); //print("currentServiceQueuePos: " + currentServiceQueue.transform.position); //print("Go to Bedroom serviceQueueType: " + currentServiceQueue.serviceType); onDestinationCall.GetComponent <ServiceQueue>().customerTraveling.Add(this.transform); GetComponent <NodeList>().travel(onDestinationCall, startWaitCall); } else if (currentServiceState == serviceTypes.bedroom) { currentServiceQueue.customerServed(); currentServiceState = serviceTypes.kitchen; onDestinationCall = findNextDestination(); //travel to kitchen => wait => eat currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>(); onDestinationCall.GetComponent <ServiceQueue>().customerTraveling.Add(this.transform); GetComponent <NodeList>().travel(onDestinationCall, startWaitCall); } else if (currentServiceState == serviceTypes.kitchen) { currentServiceQueue.customerServed(); currentServiceState = serviceTypes.exit; onDestinationCall = findNextDestination(); //travel to exit => destroy self //currentServiceQueue = onDestinationCall.GetComponent<ServiceQueue>(); //onDestinationCall.GetComponent<ServiceQueue>().customerTraveling.Add(this.transform); GetComponent <NodeList>().travel(onDestinationCall, destroyMe); } else { currentServiceQueue.customerServed(); currentServiceState = serviceTypes.exit; onDestinationCall = findNextDestination(); print("npc is lost on improper service state"); print("exiting npc....."); currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>(); GetComponent <NodeList>().travel(onDestinationCall, destroyMe); } isBeingServed = false; } } else if (isWaiting) { ; if (curTimer > 0.0f) { curTimer -= Time.deltaTime; } else { isAngry = true; } } if (isAngry) { angerTimer += Time.deltaTime; if (angerTimer >= maxAngerTime) { print("A customer got angry and left..."); currentServiceQueue.removeCustomer(this.transform); gameManager.charge(-20); //unoccupy hotel room currentServiceState = serviceTypes.exit; GetComponent <NodeList>().travel(onDestinationCall, destroyMe); isAngry = false; } } }
public Transform getBestCustomerRoom(Transform npcPosition, serviceTypes roomType) { Transform bestRoom = emptyTransform; float shortestDistance = Vector3.Distance(npcPosition.position, bestRoom.position); float tempDistance; Transform fullBestRoom = emptyTransform; float fullShortestDistance = Vector3.Distance(npcPosition.position, bestRoom.position); float fullTempDistance; //first pass for rooms that have non-waiting spots for the customer for (int i = 0; i < roomList[(int)roomType].Count; i++) { ServiceQueue sQ = roomList[(int)roomType][i].GetComponent <ServiceQueue>(); //print("customer serving + traveling < current employees"); //print(sQ.customerServing.Count + " + " + sQ.customerTraveling.Count + " < " + sQ.curEmployees); if (sQ.customerServing.Count + sQ.customerTraveling.Count < sQ.curEmployees) { //print("succeeded in integrating traveling employees?"); if (bestRoom == emptyTransform) { bestRoom = roomList[(int)roomType][i]; } else { tempDistance = Vector3.Distance(npcPosition.position, roomList[(int)roomType][i].position); if (tempDistance < shortestDistance) { bestRoom = roomList[(int)roomType][i]; shortestDistance = tempDistance; } } } else //if the room has all busy staff members { if (fullBestRoom == emptyTransform) { fullBestRoom = roomList[(int)roomType][i]; fullTempDistance = Vector3.Distance(npcPosition.position, roomList[(int)roomType][i].position); } else { fullTempDistance = Vector3.Distance(npcPosition.position, roomList[(int)roomType][i].position); if (fullTempDistance < fullShortestDistance) { fullBestRoom = roomList[(int)roomType][i]; fullShortestDistance = fullTempDistance; } } } } if (bestRoom != emptyTransform) { return(bestRoom); } else if (fullBestRoom != emptyTransform) { return(fullBestRoom); } else { //print("no available rooms for customer to go to!!!"); //print("write code for customer waiting queue until room available and manned"); Debug.LogWarning("no available rooms for customer to go to!!!\n" + "write code for customer waiting queue until room available and manned\n" + "sending customer to emptyTransform..."); return(nodeGrid[0][0]); } }
public void initServices(serviceTypes newServiceType) { serviceType = newServiceType; fillService(); }