예제 #1
0
    public void DoLeave(bool satisfied)
    {
        canAcceptFood = false;
        renderedCustomer.SetActive(false);
        var controller = FindObjectOfType <MainSceneController>();

        //is order fulfilled correctly?
        if (satisfied)
        {
            //get player who made customer happy
            switch (submittingPlayer.playerNumber)
            {
            //add score based on complexity of order
            case 1:
                controller.player1Score += GameConstants.ScorePerIngredient * order.GetIngredientCount();
                break;

            case 2:
                controller.player2Score += GameConstants.ScorePerIngredient * order.GetIngredientCount();
                break;
            }
            //conditions are correct for spawning powerup, so do so
            //50% of time is TimeUp, 25% of time is PointsUp, 25% of time is SpeedUp
            if (attachedBar.percentComplete <= 0.3F)
            {
                if (RandomUtil.GenerateFloat() > 0.5F)
                {
                    //Do spawn time up
                    DoSpawnPowerUp(PowerUpType.TimeUp);
                }
                else
                {
                    if (RandomUtil.GenerateFloat() > 0.5F)
                    {
                        //Do spawn score up
                        DoSpawnPowerUp(PowerUpType.PointsUp);
                    }
                    else
                    {
                        //Do spawn speed up
                        DoSpawnPowerUp(PowerUpType.SpeedUp);
                    }
                }
            }
        }
        else
        {
            //customer is angry. Find out which player(s) customer is angry at and deduct score accordingly
            if (player1Mad && player2Mad)
            {
                controller.player1Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount() * 2;
                controller.player2Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount() * 2;
            }
            else if (player1Mad)
            {
                controller.player1Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount() * 2;
            }
            else if (player2Mad)
            {
                controller.player2Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount() * 2;
            }
            //customer's order was not fulfilled, deduct points from both players accordingly
            else
            {
                controller.player1Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount();
                controller.player2Score -= GameConstants.ScorePerIngredient * order.GetIngredientCount();
            }
        }
        order      = null;
        isActive   = false;
        player1Mad = false;
        player2Mad = false;
        attachedBar.ResetProgressBar();
    }
예제 #2
0
    public void StartCustomer()
    {
        canAcceptFood = true;
        renderedCustomer.SetActive(true);
        order = new Salad();
        var ingredients = RandomUtil.CreateRandomCombination();

        foreach (var ingredient in ingredients)
        {
            order.AddIngredient(ingredient);
        }
        if (attachedBar != null)
        {
            attachedBar.StartProgressBar(GameConstants.WaitTime * GameConstants.RecipeComplexityScale * order.GetIngredientCount());
        }
    }