public void checkGreet() { CafeNPC tNPC = pInstance.closestCustomer(); if (tNPC != null && tNPC.state == ProcessState.WaitingForGreet) { ; } { npc = (CafeNPC)GameManager.instance.firstCustomer(ProcessState.WaitingForGreet); npc.npcObj.transform.LookAt(player.transform); } }
void AddCustomer() { if (custCount < custLimit) { //Chooses NPC customer obj at random and Places NPC game object into the scene at current place. GameObject newNPCobj = Instantiate(customers[Random.Range(0, customers.Length)], new Vector3(-5.5f, 0, custCount), transform.rotation * Quaternion.Euler(0f, 180f, 0f)); //Creates new CafeNPC object and enqueues it to activeNPC. CafeNPC newNPC = new CafeNPC(newNPCobj, orders[Random.Range(0, orders.Length)]); activeNPC.Enqueue(newNPC); custCount++; } else { Debug.Log("Customer limit hit!"); } }
//Returns closest NPC if an NPC is near player. public CafeNPC closestCustomer() { CafeNPC closest = null; float tempDist = radarDistance; foreach (CafeNPC npc in GameManager.instance.activeNPC) { Vector3 diff = (npc.npcObj.transform.position - GetComponent <Transform>().position); float curDistance = diff.sqrMagnitude; if (curDistance < tempDist) { closest = npc; tempDist = curDistance; } } return(closest); }
void endGreet() { npc = null; npc.state = ProcessState.LookingAtMenu; }