private void OnTriggerEnter(Collider other) { if (other.transform.CompareTag("Ladron")) { Debug.Log("He pillado al ladron"); catco = other.transform.GetComponentInParent <Catco>(); estadoActual = EstadosFSM.ECHAR_LADRON; } }
void Start() { puestoMaitre = mundo.puestoMaitre; transform.position = puestoMaitre; clienteSentado = false; estadoActual = EstadosFSM.ESPERAR; timer = waitingTime; lookAt = mundo.mesaMaitre.transform.position; wait(); }
// Start is called before the first frame update void Start() { posMesaPedidos = mundo.mesaPedidos.transform.GetChild(1).position; puestoCocinar = mundo.posCocina; posCocinero = mundo.posCocinero.transform.position; transform.position = posCocinero; this.min = mundo.minCocinero; this.max = mundo.maxCocinero; this.estadoActual = EstadosFSM.ESPERAR; this.estadoCocinar = CocinarFSM.PENSAR; }
void OnTriggerEnter(Collider other) { if (other.transform.CompareTag("Catmarero")) { catmarero = other.transform.GetComponentInParent <Catmarero>(); if (catmarero.isDistraido()) { estadoActual = EstadosFSM.IR_CAMARERO; walkTo(catmarero.transform.position - transform.forward); } } }
// Start is called before the first frame update void Start() { GameObject path = mundo.pathEncargado; pathNodes = new Transform[path.transform.childCount]; for (int i = 0; i < path.transform.childCount; i++) { pathNodes[i] = path.transform.GetChild(i); } nodeNumber = 0; estadoActual = EstadosFSM.SIGUIENTE_PUNTO; }
public void FSM() { switch (estadoActual) { case EstadosFSM.SIGUIENTE_PUNTO: currentNode = pathNodes[nodeNumber]; nodeNumber = (nodeNumber + 1) % pathNodes.Length; walkTo(currentNode.position); estadoActual = EstadosFSM.PATRULLAR; break; case EstadosFSM.PATRULLAR: if (isInPosition()) { estadoActual = EstadosFSM.SIGUIENTE_PUNTO; } ///if (collider de camarero && estaDistraido) ///{ ///walkTo(camarero); ///estadoActual = EstadosFSM.IR_CAMARERO; ///} break; case EstadosFSM.IR_CAMARERO: walkTo(catmarero.transform.position - transform.forward); catmarero.lookAtEncargado(gameObject); estadoActual = EstadosFSM.BRONCA; break; case EstadosFSM.BRONCA: rotateTowards(catmarero.transform.position); if (isInPosition() && isLookingTowards(catmarero.transform.position)) { angry(); timer = 1.6f; estadoActual = EstadosFSM.BRONCA_EN_CURSO; } break; case EstadosFSM.BRONCA_EN_CURSO: timer -= Time.deltaTime; if (timer <= 0) { catmarero.volverAlTrabajo(); estadoActual = EstadosFSM.SIGUIENTE_PUNTO; } break; } }
// Start is called before the first frame update void Start() { //Posición de spawn min = mundo.minSpawnCliente; max = mundo.maxSpawnCliente; transform.position = new Vector3(Random.Range(min.x, max.x), Random.Range(min.y, max.y), Random.Range(min.z, max.z)); //Segundos this.timer = Random.Range(5f, 10f); this.estadoActual = EstadosFSM.VAGAR; this.estadoVagar = VagarFSM.PENSAR; this.inPosCola = false; this.avisoMaitre = false; this.avisoSentarse = false; this.decidido = false; this.servido = false; this.atendido = false; maitre = FindObjectOfType <Maitre>(); }
void FSM() { switch (estadoActual) { case EstadosFSM.ESPERAR: timer -= Time.deltaTime; rotateTowards(puestoCaco); if (mundo.hayPlato() && timer <= 0) { walkTo(puertaTrasera); cocineroEnElCamino = false; estadoActual = EstadosFSM.ENTRAR; } break; case EstadosFSM.ENTRAR: if (isInPosition()) { Plato plato = mundo.pollPlato(); walkTo(posPlato); estadoActual = EstadosFSM.IR_PLATO; } break; case EstadosFSM.IR_PLATO: if (pillado || !mundo.hayPlato() || cocineroEnElCamino) { Debug.Log("Salgo por patas"); runTo(puestoCaco); estadoActual = EstadosFSM.VOLVER; } else if (isInPosition()) { Plato plato = mundo.pollPlato(); estadoActual = EstadosFSM.COGER_PLATO; } break; case EstadosFSM.COGER_PLATO: comida = mundo.getPlato(); pick(comida.plato); runTo(puestoCaco); estadoActual = EstadosFSM.VOLVER; break; case EstadosFSM.VOLVER: if (isInPosition()) { if (comida != null) { timer = 10; platoComiendo = Instantiate(mundo.plato, transform.position + transform.forward * 0.5f, mundo.plato.transform.rotation); eat(); estadoActual = EstadosFSM.COMER; } else { timer = 5; idle(); estadoActual = EstadosFSM.ESPERAR; } pillado = false; } break; case EstadosFSM.COMER: timer -= Time.deltaTime; if (timer <= 0) { Destroy(platoComiendo); comida = null; idle(); estadoActual = EstadosFSM.ESPERAR; } break; } }
void FSM() { switch (estadoActual) { case EstadosFSM.VAGAR: if (timer <= 0) { if (!mundo.colaIsFull()) { estadoActual = EstadosFSM.EN_COLA; } else { timer = Random.Range(5, 10); } } else { timer -= Time.deltaTime; FSM_Vagar(); } break; case EstadosFSM.EN_COLA: posColaMaitre = mundo.getNextCola(); walkTo(posColaMaitre); if (mundo.colaIsFull()) { estadoActual = EstadosFSM.VAGAR; } else if (isInPosition() && distance(posColaMaitre)) { wait(); mundo.pushClienteCola(this); estadoActual = EstadosFSM.ESPERAR_MAITRE; } break; case EstadosFSM.ESPERAR_MAITRE: if (avisoMaitre) { estadoActual = EstadosFSM.SEGUIR_MAITRE; } else if (inPosCola) { walkTo(transform.position - new Vector3(0, 0, mundo.distanciaCola)); inPosCola = false; estadoActual = EstadosFSM.AVANZA; } break; case EstadosFSM.AVANZA: if (isInPosition()) { wait(); estadoActual = EstadosFSM.ESPERAR_MAITRE; } break; case EstadosFSM.SEGUIR_MAITRE: walkTo(maitre.transform.position); if (avisoSentarse) { timer = 1.2f; Vector3 position = mundo.mesas[mesaActual].transform.position; walkTo(position); if (isInPosition()) { estadoActual = EstadosFSM.SENTARSE; } } break; case EstadosFSM.SENTARSE: Transform rotation = mundo.mesas[mesaActual].transform.parent; rotateTowards(rotation.transform.position); if (isLookingTowards(rotation.transform.position)) { sitDown(); mundo.pushCliente(mesaActual, this); maitre.Sentado(); estadoActual = EstadosFSM.SENTADO; } break; case EstadosFSM.SENTADO: timer -= Time.deltaTime; if (timer <= 0) { wait(); timer = Random.Range(5, 10); estadoActual = EstadosFSM.DECIDIR_MENU; } break; case EstadosFSM.DECIDIR_MENU: avisoMaitre = false; if (timer > 0) { timer -= Time.deltaTime; } else if (timer <= 0) { decidido = true; timer -= Time.deltaTime; } if (atendido) { timer = Random.Range(5f, 20f); estadoActual = EstadosFSM.ESPERAR_PEDIDO; } break; case EstadosFSM.ESPERAR_PEDIDO: if (servido) { eat(); estadoActual = EstadosFSM.COMER; } break; case EstadosFSM.COMER: timer -= Time.deltaTime; if (timer <= 0) { Destroy(pedido); walkTo(mundo.posDestroy); mundo.clienteLeaves(mesaActual); estadoActual = EstadosFSM.SALIR; } break; case EstadosFSM.SALIR: if (isInPosition()) { Destroy(gameObject); gameManager.borrarCliente(); } break; } }
void FSM() { switch (estadoActual) { case EstadosFSM.ESPERAR: rotateTowards(lookAt); if (!mundo.colaIsEmpty() && !mundo.mesasIsFull()) { //Espera 1 segundos antes de llevar al cliente a la mesa timer -= Time.deltaTime; if (timer <= 0 && isLookingTowards(lookAt)) { mesaActual = mundo.nextMesa(); clienteActual = mundo.popClienteCola(); clienteActual.concedeMesa(mesaActual); //Camina hasta la siguiente mesa Vector3 position = mundo.mesas[mesaActual].transform.parent.GetChild(1).position; walkTo(position); estadoActual = EstadosFSM.LLEVAR_CLIENTE; } } break; case EstadosFSM.LLEVAR_CLIENTE: if (isInPosition()) { wait(); timer = waitingTime; estadoActual = EstadosFSM.SENTAR; } break; case EstadosFSM.SENTAR: clienteActual.sentar(); if (clienteSentado) { //Espera un poco antes de volver timer -= Time.deltaTime; if (timer <= 0) { clienteSentado = false; walkTo(puestoMaitre); estadoActual = EstadosFSM.VOLVER; } } break; case EstadosFSM.VOLVER: if (isInPosition()) { timer = waitingTime; idle(); estadoActual = EstadosFSM.ESPERAR; } break; } }
public void FSM() { switch (estadoActual) { case EstadosFSM.ESPERAR: if (isInPosition()) { wait(); if (mundo.hayComandas()) { platoActual = mundo.takeComanda(); walkTo(puestoCocinar.transform.position); estadoActual = EstadosFSM.IR_PUESTO; estadoCocinar = CocinarFSM.PENSAR; } } break; case EstadosFSM.IR_PUESTO: rotateTowards(puestoCocinar.transform.parent.position); if (isInPosition() && isLookingTowards(puestoCocinar.transform.parent.position)) { timer = Random.Range(10f, 15f); mundo.setPlato(platoActual.comida, platoActual.mesa, mundo.plato, platoActual.cliente); estadoActual = EstadosFSM.COCINAR; } break; case EstadosFSM.COCINAR: //Si acaba de cocinar timer -= Time.deltaTime; if (timer <= 0) { Debug.Log("Termina de cocinar"); Plato comida = mundo.getPlato(); pick(comida.plato); walkTo(posMesaPedidos); estadoActual = EstadosFSM.LLEVAR_COMIDA; } //Si han robado el plato lo vuelve a empezar else if (!mundo.hayPlato()) { walkTo(puestoCocinar.transform.position); estadoActual = EstadosFSM.IR_PUESTO; } else { FSM_Cocinar(); } break; case EstadosFSM.ECHAR_LADRON: rotateTowards(catco.transform.position); if (isLookingTowards(catco.transform.position)) { angry(); catco.Pillado(); estadoActual = EstadosFSM.COCINAR; } break; case EstadosFSM.LLEVAR_COMIDA: if (isInPosition()) { if (mundo.pushPlato(platoActual)) { platoActual = null; walkTo(posCocinero); estadoActual = EstadosFSM.ESPERAR; } else { wait(); } } break; } }