// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { customer = animator.gameObject.GetComponent <Customer>(); controller = customer.controller; patience = customer.patience; satisfaction = customer.satisfaction; this.animator = animator; receiver = Player.Instance; SubscribeEvents(); }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { customer = animator.gameObject.GetComponent <Customer>(); playerNode = customer.GetComponentInChildren <PlayerNode>(); patience = customer.patience; satisfaction = customer.satisfaction; renderer = customer.GetComponent <SpriteRenderer>(); this.animator = animator; receiver = customer; SubscribeEvents(); //turn the patience counter back on patience.SetPatienceInteractibility(true); }
public Customer(GameObject g, List <SaladOrder> ol, Image bgImg, Image fillImg, int pos) { posInIsCustomerPresent = pos; isFrustated = false; satisfactionState = CustomerSatisfaction.veryHappy; go = g; orderList = ol; ol = null; for (int i = 0; i < orderList.Count; ++i) { orderList[i].quad.transform.SetParent(go.transform.GetChild(0)); orderList[i].quad.transform.position = go.transform.GetChild(0).position + new Vector3(0.0f, i * 0.6f, i * 0.5f); } if (bgImg != null && fillImg != null) { bgImage = bgImg; fillImage = fillImg; } }
void Awake() { instance = this; }
void React(int row, int col, int p) { ItemsController obj = tiles[row][col].go.GetComponent <ItemsController>(); if (obj != null) { switch (obj.type) { case ItemType.Fruit: if (playerController.players[p].items.Count < 2 && playerController.players[p].salad.Count <= 0) { GameObject go = Instantiate(fruits[(int)obj.fruit]); switch (obj.fruit) { case FruitName.Apple: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; case FruitName.Banana: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; case FruitName.Watermelon: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; case FruitName.Cherry: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; case FruitName.Avocaado: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; case FruitName.Strawberry: playerController.players[p].AddItem(obj.type, obj.fruit, go); break; } go = null; } break; case ItemType.Process: if (playerController.players[p].items.Count > 0) { ProcessFruitController processFruitController = tiles[row][col].go.GetComponent <ProcessFruitController>(); if (processFruitController && !processFruitController.isProcesssing) { processFruitController.StartProcessing(playerController.players[p].items.Peek().go); playerController.players[p].RemoveItem(); } } break; case ItemType.PickOrder: PickOrderController pickOrderController = tiles[row][col].go.GetComponent <PickOrderController>(); if (pickOrderController && pickOrderController.processedFruit.Count > 0 && playerController.players[p].items.Count <= 0) { playerController.players[p].AddSalad(pickOrderController.processedFruit); pickOrderController.Clear(); } break; case ItemType.Trash: Trash(p); break; case ItemType.Serve: ServiceController serviceController = tiles[row][col].go.GetComponent <ServiceController>(); Debug.Log(CustomerController.isCustomerPresent[col - 1]); if (serviceController && CustomerController.isCustomerPresent[col - 1] != -1) { CustomerSatisfaction customerSatisfaction = serviceController.CheckCombination( customerController.customerList[CustomerController.isCustomerPresent[col - 1]], playerController.players[p].salad, p); switch (customerSatisfaction) { case CustomerSatisfaction.angry: playerController.players[p].score += 5; Destroy(customerController.customerList[CustomerController.isCustomerPresent[col - 1]].go); customerController.RemoveCustomer(CustomerController.isCustomerPresent[col - 1], col - 1); Trash(p); break; case CustomerSatisfaction.veryAngry: playerController.players[p].score -= 10; break; case CustomerSatisfaction.happy: playerController.players[p].score += 20; playerController.players[p].GiveBonusTime(2.0f, playerController.timerMaxVal); Destroy(customerController.customerList[CustomerController.isCustomerPresent[col - 1]].go); customerController.RemoveCustomer(CustomerController.isCustomerPresent[col - 1], col - 1); Trash(p); break; case CustomerSatisfaction.veryHappy: playerController.players[p].score += 25; playerController.players[p].GiveBonusTime(3.0f, playerController.timerMaxVal); Destroy(customerController.customerList[CustomerController.isCustomerPresent[col - 1]].go); customerController.RemoveCustomer(CustomerController.isCustomerPresent[col - 1], col - 1); Trash(p); break; } UpdateScores(p, playerController.players[p].score); } break; } } }