Пример #1
0
    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;
            }
        }
    }