/// <summary>
        /// Checks whether the player's win conditions. Checks them in order
        /// from biggest to smallest and returns if the condition is met.
        /// </summary>
        private void checkResults()
        {
            events.ChangeTime(2);
            if (results[0] == 2)
            {
                if (results[1] == 2 && results[2] == 2)
                {
                    lastWin = 2 * bet;
                    payPlayer();
                    return;
                }
            }

            if (results[0] == 1)
            {
                if (results[1] == 1 && results[2] == 1)
                {
                    lastWin = 3 * bet;
                    payPlayer();
                    return;
                }
            }

            if (results[0] == 0)
            {
                if (results[1] == 0 && results[2] == 0)
                {
                    lastWin = 4 * bet;
                    payPlayer();
                    return;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                if (results[i] == 0)
                {
                    lastWin = bet;
                    payPlayer();
                    return;
                }
            }
            info2.text = "";
        }
Example #2
0
 /// <summary>
 /// Advances story dialogue by accessing the story from the player class.
 /// </summary>
 /// <param name="level">How far into the story</param>
 /// <param name="answerDialogue">Contains player's answer</param>
 /// <param name="answer">What choosing the answer does</param>
 /// <returns></returns>
 public string GetDialogue(int level, out string answerDialogue, out string answer)
 {
     if (level == story.Length - 1)
     {
         StoryEnding(name);
     }
     events.ChangeTime(2);
     answerDialogue = reply[level];
     answer         = this.answer[level];
     return(story[level]);
 }
 /// <summary>
 /// Hides menu buttons, resets game and deals cards.
 /// Dealer's first card image or count is not shown.
 /// </summary>
 private void startNewGame()
 {
     events = player.events;
     events.ChangeTime(3);
     controlButtons(true, false);
     resetGame();
     player.useMoney(-bet);
     playing = true;
     dealCard("Dealer");
     dealCard("Dealer");
     checkCount("Dealer");
     cardDealerPrevious.sprite = cards[13];
     dealCard("Player");
     dealCard("Player");
     checkCount("Player");
 }
        /// <summary>
        /// Checks winning conditions. Randomizes damage, also if
        /// player is very drunk the player has a higher chance of missing.
        /// </summary>
        /// <param name="user">bfPlayer or bfNPC. The list contains the image of the player at [0] and hp bar at [1].</param>
        private void attackResult(List <Image> user)
        {
            int damage = random.Next(0, 3);

            if (user == bfPlayer)
            {
                if (player.drunkLevel > 60 && damage != 0)
                {
                    damage = random.Next(0, 3);
                }
                npcHP += damage;
                StartCoroutine(showInfo("Player deals " + damage + " damage!"));
                if (npcHP >= 5)
                {
                    events.ChangeTime(10);
                    events.addScore(20);
                    StartCoroutine(iManager.PopUp("You showed who's the boss."));
                    player.useMoney(random.Next(0, 30));
                    target.Remove();
                    target.StopInteracting();
                    barfight.SetActive(false);
                }
                else
                {
                    bfNPC[1].sprite = npcHPBar[npcHP];
                }
            }
            else if (user == bfNPC)
            {
                damage    = random.Next(0, 3);
                playerHP += damage;
                StartCoroutine(showInfo("NPC deals " + damage + " damage!"));
                if (playerHP >= 5)
                {
                    target.StopInteracting();
                    StartCoroutine(cutscene.CutsceneBlackout());
                    player.useMoney(-(random.Next(0, 20)));
                    barfight.SetActive(false);
                }
                else
                {
                    bfPlayer[1].sprite = playerHPBar[playerHP];
                }
            }
        }