Пример #1
0
    public void HandleTrashCansFeatures()
    {
        if (playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.TRASH_CAN_ONE)
        {
            if (playerManager.playerOneDestinationReached)
            {
                playerManager.playerOneDestinationReached = false;
                if (playerManager.playerOneFoodInHand == 0)//if nothing to trash,error message displayed
                {
                    errorMessageNothingToTrashP1.SetActive(true);
                    Invoke("DisableErrorMessageP1", 2.0f);
                    print("trash error");
                }
                else//after trashing,necessary reinitialization
                {
                    print("trashing " + playerManager.playerOneFoodInHand);
                    miscManager.playerOneScore       -= 100;
                    playerManager.playerOneFoodInHand = 0;
                    print("1111111111");
                    playerManager.DisableAllFruitIconsP1();
                    fruitStallManager.ResetPlayerFruitBasketP1();
                }
            }
        }

        if (playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.TRASH_CAN_TWO)//just same as player one
        {
            if (playerManager.playerTwoDestinationReached)
            {
                playerManager.playerTwoDestinationReached = false;
                if (playerManager.playerTwoFoodInHand == 0)
                {
                    errorMessageNothingToTrashP2.SetActive(true);
                    Invoke("DisableErrorMessageP2", 2.0f);
                }
                else
                {
                    miscManager.playerTwoScore       -= 100;
                    playerManager.playerTwoFoodInHand = 0;
                    playerManager.DisableAllFruitIconsP2();
                    fruitStallManager.ResetPlayerFruitBasketP2();
                }
            }
        }
    }
Пример #2
0
 public void HandleCustomerActivities()
 {
     //if player reaches to any of the customer
     if (playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_ONE ||
         playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_TWO ||
         playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_THREE ||
         playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_FOUR ||
         playerManager.playerOneDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_FIVE)
     {
         if (playerManager.playerOneDestinationReached)
         {
             playerManager.playerOneDestinationReached = false;
             bool wrongDelivery        = false;
             int  wrongDeliveryCounter = 0;
             for (int i = 0; i < NO_OF_TOTAL_FOOD; i++)//how many mismatch between fruit collected and requirement are there is calculated
             {
                 print("player fruit collection " + fruitManager.playerOneFruitS[i]);
                 print(" customer fruit requirement " + customerFruitRequirement[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE, i]);
                 if (
                     !(fruitManager.playerOneFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE, 0]
                       ||
                       fruitManager.playerOneFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE, 1]
                       ||
                       fruitManager.playerOneFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE, 2])
                     )
                 {
                     wrongDelivery = true;
                     wrongDeliveryCounter++;
                 }
             }
             if (!choppingBoardManager.choppingDonePlayerOne)//if player doesn't reach chopping table before fruit submission to customer,invalid delivery
             {
                 wrongDelivery = true;
             }
             choppingBoardManager.choppingDonePlayerOne = false;
             if (!plateTableManager.plateCollectedPlayerOne)//if player doesn't collect plates  before fruit submission to customer,invalid delivery
             {
                 wrongDelivery = true;
             }
             plateTableManager.plateCollectedPlayerOne = false;
             if (wrongDelivery)//wrong delivery message shown and score deducted
             {
                 errorMessageWrongDeliveryP1.SetActive(true);
                 Invoke("DisableErrorMessageP1", 2.0f);
                 print("delivery error");
                 miscManager.playerOneScore -= 100 * wrongDeliveryCounter;
             }
             else//on successful delivery,score recalculated and remaining time added to player's timer
             {
                 duccessfulDeliveryP1.SetActive(true);
                 Invoke("SuccessfulDeliveryMessageP1", 2.0f);
                 miscManager.playerOneScore += 500;
                 miscManager.playerOneTime  += (customerWaitTime[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE] - (Time.time - customerWaitTimer[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE]));
                 miscManager.playerOneScore += (int)(100 * (customerWaitTime[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE] - (Time.time - customerWaitTimer[(int)playerManager.playerOneDestinationIdentity - TOTAL_FRUIT_TYPE])));
             }
             playerManager.playerOneFoodInHand = 0;
             print("222222222222222");
             playerManager.DisableAllFruitIconsP1();
             fruitManager.ResetPlayerFruitBasketP1();
         }
     }
     //same for second player
     if (playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_ONE ||
         playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_TWO ||
         playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_THREE ||
         playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_FOUR ||
         playerManager.playerTwoDestinationIdentity == PlayerManager.DestinationType.CUSTOMER_FIVE)
     {
         if (playerManager.playerTwoDestinationReached)
         {
             playerManager.playerTwoDestinationReached = false;
             bool wrongDelivery        = false;
             int  wrongDeliveryCounter = 0;
             //playerManager.playerTwoDestinationIdentity = PlayerManager.DestinationType.CUSTOMER_ONE
             for (int i = 0; i < NO_OF_TOTAL_FOOD; i++)
             {
                 if (
                     !(fruitManager.playerTwoFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE, 0]
                       ||
                       fruitManager.playerTwoFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE, 1]
                       ||
                       fruitManager.playerTwoFruitS[i] == (byte)customerFruitRequirement[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE, 2])
                     )
                 {
                     wrongDelivery = true;
                     wrongDeliveryCounter++;
                 }
             }
             if (!choppingBoardManager.choppingDonePlayerTwo)
             {
                 wrongDelivery = true;
             }
             choppingBoardManager.choppingDonePlayerTwo = false;
             if (!plateTableManager.plateCollectedPlayerTwo)
             {
                 wrongDelivery = true;
             }
             plateTableManager.plateCollectedPlayerTwo = false;
             if (wrongDelivery)
             {
                 errorMessageWrongDeliveryP2.SetActive(true);
                 Invoke("DisableErrorMessageP2", 2.0f);
                 print("delivery error");
                 miscManager.playerTwoScore -= 100 * wrongDeliveryCounter;
             }
             else
             {
                 duccessfulDeliveryP2.SetActive(true);
                 Invoke("SuccessfulDeliveryP2", 2.0f);
                 miscManager.playerTwoScore += 500;
                 miscManager.playerTwoTime  += (customerWaitTime[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE] - (Time.time - customerWaitTimer[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE]));
                 miscManager.playerTwoScore += (int)(100 * (customerWaitTime[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE] - (Time.time - customerWaitTimer[(int)playerManager.playerTwoDestinationIdentity - TOTAL_FRUIT_TYPE])));
             }
             playerManager.playerTwoFoodInHand = 0;
             playerManager.DisableAllFruitIconsP2();
             fruitManager.ResetPlayerFruitBasketP2();
         }
     }
 }