Пример #1
0
    private void UpdateScoresAndNameText()
    {
        playerScoreText.text = player1.finalScore.ToString();
        playerNameText.text  = player1.name;

        string cpu1Score = GameUtil.cpuList.Count > 0 ? GameUtil.cpuList[0].finalScore.ToString() : "-";
        string cpu2Score = GameUtil.cpuList.Count > 1 ? GameUtil.cpuList[1].finalScore.ToString() : "-";
        string cpu3Score = GameUtil.cpuList.Count > 2 ? GameUtil.cpuList[2].finalScore.ToString() : "-";

        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two)
        {
            cpu1ScoreText.text = player2.finalScore.ToString();
            cpu1NameText.text  = player2.name;
            cpu2ScoreText.text = cpu1Score;
            cpu2NameText.text  = GameUtil.cpuList.Count > 0 ? GameUtil.cpuList[0].name : "";
            cpu3ScoreText.text = cpu2Score;
            cpu3NameText.text  = GameUtil.cpuList.Count > 1 ? GameUtil.cpuList[1].name : "";
        }
        else
        {
            cpu1ScoreText.text = cpu1Score;
            cpu1NameText.text  = GameUtil.cpuList.Count > 0 ? GameUtil.cpuList[0].name : "";
            cpu2ScoreText.text = cpu2Score;
            cpu2NameText.text  = GameUtil.cpuList.Count > 1 ? GameUtil.cpuList[1].name : "";
            cpu3ScoreText.text = cpu3Score;
            cpu3NameText.text  = GameUtil.cpuList.Count > 2 ? GameUtil.cpuList[2].name : "";
        }
    }
Пример #2
0
 void Start()
 {
     singlePlayerGroup.SetActive(GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Single);
     twoPlayersGroup.SetActive(GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two);
     statsIndex = 0;
     Pause(false, false);
 }
Пример #3
0
    private Statistics GetPlayerStats()
    {
        bool forPlayer2 = !player1StatsToggle.isOn;

        //Assume first element is player1 and second element is player 2 IF game type is for 2 players.
        return(GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && forPlayer2 ? statsList[1] : statsList[0]);
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Game Begins");

        bananaRewardWindowManager.Hide();

        BuildGameProgressionLogicList();

        //Building card list including secret cards
        allCards = new List <Card>();
        allCards.AddRange(cards_2Entities);
        Array.ForEach(secretCards_2Entities, card =>
        {
            if (GameProgressionUtil.GetCardAvailability(card.cardEnum))
            {
                allCards.Add(card);
            }
        });

        showingGameOverMenu = false;
        cpuCoroutines.Clear();
        timer = GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.GoGo ? GameUtil.timer : 0f;

        player1 = (Player)Player.PLAYER_1.RebuildToPlay();
        player1.Stats.Restart();
        player1.finalScore = 0;
        player1.points     = 0;
        player1.penalties  = 0;
        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Single)
        {
            player1.SetNewName(Player.SINGLE_PLAYER_NAME);
        }

        player2 = (Player)Player.PLAYER_2.RebuildToPlay();
        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two)
        {
            player2.Stats.Restart();
            player2.finalScore = 0;
            player2.points     = 0;
            player2.penalties  = 0;
        }
        GameUtil.cpuList.ForEach(cpu =>
        {
            cpu.Stats.Restart();
            cpu.finalScore = 0;
            cpu.points     = 0;
            cpu.penalties  = 0;
        });
        UpdateScoresAndNameText();
        gameOver    = false;
        cardInDelay = false;
        roundSeperator.SetActive(false);
        StartCoroutine(NewRoundWithDelay());
    }
Пример #5
0
    private void ShowGameOverMenu()
    {
        List <Statistics> statsList = new List <Statistics>();

        statsList.Add(player1.Stats);
        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two)
        {
            statsList.Add(player2.Stats);
        }
        statsList.AddRange(GameUtil.cpuList.Select(cpu => cpu.Stats));
        pauseMenu.GameOver(statsList);
    }
Пример #6
0
 private void CheckForGameOver()
 {
     if (GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.Coco)
     {
         if (player1.finalScore >= GameUtil.pointsToReach ||
             (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && player2.finalScore >= GameUtil.pointsToReach) ||
             GameUtil.cpuList.Any(cpu => cpu.finalScore >= GameUtil.pointsToReach))
         {
             gameOver = true;
         }
     }
     else if (GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.GoGo && timer <= 0)
     {
         gameOver = true;
     }
 }
Пример #7
0
    public void PlayGame()
    {
        GameUtil.pointsToReach = pointsToReach;
        GameUtil.timer         = timer;

        GameUtil.cpuList.Clear();
        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Single && cpuIndexes[0] > 0)
        {
            GameUtil.cpuList.Add((Cpu)allCpus[cpuIndexes[0]].RebuildToPlay());
        }
        if (cpuIndexes[1] > 0)
        {
            GameUtil.cpuList.Add((Cpu)allCpus[cpuIndexes[1]].RebuildToPlay());
        }
        if (cpuIndexes[2] > 0)
        {
            GameUtil.cpuList.Add((Cpu)allCpus[cpuIndexes[2]].RebuildToPlay());
        }

        menuAudioManager.PlayMainButtonClick();

        SceneManager.LoadScene("Load Screen");
    }
Пример #8
0
    void Start()
    {
        allCpus = new List <Cpu>()
        {
            null, Cpu.KELSEY, Cpu.ANDREW, Cpu.MONKEY, Cpu.PENGUIN
        };
        allCpus.Add(Cpu.KONGO);
        allCpus.Add(Cpu.PURPLE_MONKEY);
        allCpus.Add(Cpu.MUFFIN);
        allCpus.Add(Cpu.CHOMP);
        allCpus.Add(Cpu.COCO);

        List <int> cpusInPlay = GameSettingsUtil.GetCpusInPlayList();

        SetCpu(0, cpusInPlay[0]);
        SetCpu(1, cpusInPlay[1]);
        SetCpu(2, cpusInPlay[2]);

        cpuPicker.Close(true, false);

        twoPlayersToggle.isOn       = GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two;
        gogoGameModeToggle.isOn     = GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.GoGo;
        allowGameOptionChangedSound = false;
    }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        if (!cardInDelay && !gameOver)
        {
            if (GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.Coco)
            {
                timer += Time.deltaTime;
            }
            else if (GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.GoGo)
            {
                timer -= Time.deltaTime;
            }
        }

        timerText.text = TransformTime(timer);
        CheckForGameOver();
        if (!gameOver)
        {
            timerText.color = new Color32(255, 255, 255, 255);
        }
        else
        {
            timerText.color = new Color32(0, 255, 0, 255);
        }
        if (gameOver && !showingGameOverMenu)
        {
            if (cardGameObject != null)
            {
                DestroyImmediate(cardGameObject.gameObject);
                cardGameObject = null;
            }
            GameProgressionUtil.UpdateGameProgression(rep => rep.totalTimeSpentPlaying += GameSettingsUtil.GetGameMode() == GameSettingsUtil.GameModeEnum.GoGo ? GameUtil.timer : timer);
            if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Single)
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalSinglePlayerGamesPlayed++);
            }
            if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two)
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalTwoPlayerGamesPlayed++);
            }
            if (GameUtil.cpuList.All(cpu => cpu.finalScore < player1.finalScore) || (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && GameUtil.cpuList.All(cpu => cpu.finalScore < player2.finalScore)))
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalCpusDefeated += GameUtil.cpuList.Count);
            }
            if (GameUtil.cpuList.Contains(Cpu.ANDREW) && GameUtil.cpuList.Contains(Cpu.KELSEY))
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalGamesWithAndrewAndKelsey++);
            }
            if (GameUtil.cpuList.Contains(Cpu.COCO) && GameUtil.cpuList.Contains(Cpu.MUFFIN))
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalGamesWithCocoAndMuffin++);
            }
            if (GameUtil.cpuList.Contains(Cpu.MONKEY) && GameUtil.cpuList.Contains(Cpu.PENGUIN))
            {
                GameProgressionUtil.UpdateGameProgression(rep => rep.totalGamesWithMonkeyAndPenguin++);
            }
            GameProgressionUtil.UpdateGameProgression(rep => rep.totalCorrectGuessesStreak += correctStreak);

            showingGameOverMenu = true;
            ShowGameOverMenu();

            gameProgressionLogicContainerList.ForEach(l =>
            {
                RewardAndBarrier[] list = GameProgressionUtil.GetCorrectRewards(l.rewardAndBarriers, l.initialValue, GameProgressionUtil.GetGameProgressionField(l.lambda));
                AttemptRewardUnlock(list, l.reasonString);
            });

            bananaRewardWindowManager.BeginUnlockPhase();
        }
    }
Пример #10
0
    public void Guess(CardUtil.EntityEnum entity, Participant _participant = null)
    {
        if (gameOver || cardInDelay)
        {
            return;
        }

        Participant participant = _participant == null ? player1 : _participant;

        if (participant.guessed)
        {
            return;
        }

        participant.guessed = true;
        float timeToGuess = participant.Stats.AddGuess(Time.time, correctEntity.Value, entity);

        if (entity == correctEntity)
        {
            participant.points++;

            //Clear coroutine so other cpus will stop guessing
            cpuCoroutines.ForEach(co => StopCoroutine(co));
            cpuCoroutines.Clear();

            if (participant != player1 && !player1.guessed)
            {
                player1.Stats.AddMissed(correctEntity.Value);
            }
            if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && participant != player2 && !player2.guessed)
            {
                player2.Stats.AddMissed(correctEntity.Value);
            }
            GameUtil.cpuList.ForEach(cpu =>
            {
                if (participant != cpu && !cpu.guessed)
                {
                    cpu.Stats.AddMissed(correctEntity.Value);
                }
            });

            if (participant == player1 || (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && participant == player2))
            {
                correctStreak++;
                if (useCorrectColor)
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalCorrectCorrectlyColoredGuesses++);
                }
                else
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalCorrectIncorrectlyColoredGuesses++);
                }
                if (correctEntity == CardUtil.EntityEnum.Coco)
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalTimesCocoWasPicked++);
                }
                if (correctEntity == CardUtil.EntityEnum.Chomp)
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalTimesChompWasPicked++);
                }
                if (timeToGuess < 1f)
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalCorrectGuessesUnderOneSecond++);
                }
                if (timeToGuess < .5f)
                {
                    GameProgressionUtil.UpdateGameProgression(rep => rep.totalCorrectGuessesUnderHalfASecond++);
                }
                gameAudioManager.PlayCorrectGuess();
            }
            else
            {
                Cpu cpu = (Cpu)participant;
                gameAudioManager.PlayAVoice(cpu.voiceCorrect);
            }
        }
        else
        {
            if (SettingsUtil.IsPenaltiesAllowed())
            {
                participant.penalties++;
                if (participant.points - participant.penalties < 0 && !SettingsUtil.IsNegativeScoresAllowed())
                {
                    participant.penalties--;
                }
            }

            if (participant == player1 || (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && participant == player2))
            {
                correctStreak = 0;
                gameAudioManager.PlayIncorrectGuess();
            }
            else
            {
                Cpu cpu = (Cpu)participant;
                gameAudioManager.PlayAVoice(cpu.voiceIncorrect);
            }
        }


        if (participant == player1)
        {
            SetButtonsEnabled(player1Buttons, entity == correctEntity);
        }
        if (participant == player2)
        {
            SetButtonsEnabled(player2Buttons, entity == correctEntity);
        }

        participant.finalScore = participant.points - participant.penalties;
        UpdateScoresAndNameText();

        CheckForGameOver();
        bool player2Guessed = GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two && player2.guessed;

        if (entity == correctEntity || ((GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Single || player2Guessed) && player1.guessed && GameUtil.cpuList.All(cpu => cpu.guessed)))
        {
            if (cardGameObject != null)
            {
                DestroyImmediate(cardGameObject.gameObject);
                cardGameObject = null;
            }

            if (!gameOver)
            {
                StartCoroutine(NewRoundWithDelay());
            }
        }
    }
Пример #11
0
    private void NewRound()
    {
        Card card = generateCard();

        CardUtil.EntityEnum[] allEntities = new CardUtil.EntityEnum[CardUtil.Entities_2Card.Count];
        CardUtil.Entities_2Card.CopyTo(allEntities);

        CardUtil.EntityEnum[] currentEntities = card.cardEntities.Select(e => e.entity).ToArray();
        CardUtil.EntityEnum[] otherEntities   = allEntities.Where(e => !currentEntities.Contains(e)).ToArray();


        useCorrectColor = false;
        HashSet <CardUtil.ColorEnum> colorsUsed = new HashSet <CardUtil.ColorEnum>();
        Dictionary <CardUtil.EntityEnum, CardUtil.ColorEnum> entityToColor = new Dictionary <CardUtil.EntityEnum, CardUtil.ColorEnum>();

        Array.ForEach(card.cardEntities, cardEntity =>
        {
            int index = useCorrectColor ? UnityEngine.Random.Range(0, otherEntities.Length) : UnityEngine.Random.Range(0, otherEntities.Length + 1);
            index--;
            CardUtil.ColorEnum color;
            do
            {
                if (index < otherEntities.Length)
                {
                    index++;
                }
                else
                {
                    index = 0;
                }

                if (index >= otherEntities.Length)
                {
                    useCorrectColor = true;
                }

                color = CardUtil.EntityColorMap[index >= otherEntities.Length ? cardEntity.entity : otherEntities[index]];
            } while (colorsUsed.Contains(color));
            colorsUsed.Add(color);
            entityToColor[cardEntity.entity] = color;
            Debug.Log(cardEntity.entity + ": " + color);

            cardEntity.image.color = CardUtil.ColorColorMap[color];
        });

        if (currentEntities.Contains(CardUtil.EntityEnum.Banana) && entityToColor[CardUtil.EntityEnum.Banana] == CardUtil.ColorEnum.Yellow)
        {
            GameProgressionUtil.UpdateGameProgression(rep => rep.totalTimesYellowBananaWasSeen++);
        }

        correctEntity = null;

        List <CardUtil.EntityEnum> incorrectEntities = new List <CardUtil.EntityEnum>();

        foreach (KeyValuePair <CardUtil.EntityEnum, CardUtil.ColorEnum> entry in entityToColor)
        {
            CardUtil.EntityEnum entity      = entry.Key;
            CardUtil.ColorEnum  color       = entry.Value;
            CardUtil.EntityEnum otherEntity = CardUtil.ColorEntityMap[color];

            if (entity == otherEntity)
            {
                correctEntity = entity;
                break;
            }

            incorrectEntities.Add(entity);
            incorrectEntities.Add(otherEntity);
        }

        if (correctEntity == null)
        {
            correctEntity = allEntities.Except(incorrectEntities).First();
        }

        cardGameObject = Instantiate(card, cardContainer.transform);

        //Enable all buttons

        SetButtonsEnabled(player1Buttons, true);
        SetButtonsEnabled(player2Buttons, true);


        //Set up stats

        float time = Time.time;

        player1.Stats.AddPickedCard(time, card, entityToColor, useCorrectColor);
        player1.guessed = false;
        if (GameSettingsUtil.GetGameType() == GameSettingsUtil.GameTypeEnum.Two)
        {
            player2.Stats.AddPickedCard(time, card, entityToColor, useCorrectColor);
            player2.guessed = false;
        }

        GameUtil.cpuList.ForEach(cpu =>
        {
            cpu.Stats.AddPickedCard(time, card, entityToColor, useCorrectColor);
        });
        GameUtil.cpuList.ForEach(cpu =>
        {
            cpu.guessed = false;
        });

        //Cpu starts guessing
        GameUtil.cpuList.ForEach(cpu =>
        {
            cpuCoroutines.Add(StartCoroutine(CpuGuess(cpu)));
        });
    }
Пример #12
0
    private void ShowStatsContainer(bool show)
    {
        statsContainer.SetActive(show);
        inGameUiContainer.SetActive(false);
        pauseUiContainer.SetActive(!show);
        scoreUiContainer.SetActive(!show);
        cardContainer.SetActive(show);


        if (card != null)
        {
            DestroyImmediate(card.gameObject);
            card = null;
        }

        playerStatsToggleContainer.SetActive(GameSettingsUtil.GetGameType() != GameSettingsUtil.GameTypeEnum.Single);


        Statistics playerStats = GetPlayerStats();

        if (show)
        {
            if (statsIndex == 0)
            {
                mainStatsContainer.SetActive(true);
                statsPointContainer.SetActive(false);
                averageTimeElapsedText.text = playerStats.Total == 0 ? "-" : playerStats.AverageTimeElapsed.ToString("0.00") + " s";
                averageTimeElapsedForCorrectOnesText.text = playerStats.TotalCorrect == 0 ? "-" : playerStats.AverageTimeElapsedForCorrectOnes.ToString("0.00") + " s";
                averageTimeElapsedForCorrectOnesWithCorrectlyColoredText.text   = playerStats.TotalCorrectWithCorrectlyColored == 0 ? "-" : playerStats.AverageTimeElapsedForCorrectOnesWithCorrectlyColored.ToString("0.00") + " s";
                averageTimeElapsedForCorrectOnesWithIncorrectlyColoredText.text = playerStats.TotalCorrectWithIncorrectlyColored == 0 ? "-" : playerStats.AverageTimeElapsedForCorrectOnesWithIncorrectlyColored.ToString("0.00") + " s";
                averageTimeElapsedForIncorrectOnesText.text = playerStats.TotalIncorrect == 0 ? "-" : playerStats.AverageTimeElapsedForIncorrectOnes.ToString("0.00") + " s";
                averageTimeElapsedForIncorrectOnesWithCorrectlyColoredText.text   = playerStats.TotalIncorrectWithCorrectlyColored == 0 ? "-" : playerStats.AverageTimeElapsedForIncorrectOnesWithCorrectlyColored.ToString("0.00") + " s";
                averageTimeElapsedForIncorrectOnesWithIncorrectlyColoredText.text = playerStats.TotalIncorrectWithIncorrectlyColored == 0 ? "-" : playerStats.AverageTimeElapsedForIncorrectOnesWithIncorrectlyColored.ToString("0.00") + " s";
                totalText.text        = playerStats.Total.ToString();
                totalCorrectText.text = playerStats.TotalCorrect.ToString();
                totalCorrectWithCorrectlyColoredText.text   = playerStats.TotalCorrectWithCorrectlyColored.ToString();
                totalCorrectWithIncorrectlyColoredText.text = playerStats.TotalCorrectWithIncorrectlyColored.ToString();
                totalIncorrectText.text = playerStats.TotalIncorrect.ToString();
                totalIncorrectWithCorrectlyColoredText.text   = playerStats.TotalIncorrectWithCorrectlyColored.ToString();
                totalIncorrectWithIncorrectlyColoredText.text = playerStats.TotalIncorrectWithIncorrectlyColored.ToString();

                //If just one player, dont display misses
                bool onePlayer = statsList.Count <= 1;
                totalMissedText.text = onePlayer ? "-" : playerStats.TotalMissed.ToString();
                totalMissedWithCorrectlyColoredText.text   = onePlayer ? "-" : playerStats.TotalMissedWithCorrectlyColored.ToString();
                totalMissedWithIncorrectlyColoredText.text = onePlayer ? "-" : playerStats.TotalMissedWithIncorrectlyColored.ToString();
            }
            else
            {
                mainStatsContainer.SetActive(false);
                statsPointContainer.SetActive(true);

                StatisticsPoint statsPoint = playerStats.StatisticsList[statsIndex - 1];
                card = Instantiate(statsPoint.Card, cardContainer.transform);
                card.gameObject.SetActive(true);

                Array.ForEach(card.cardEntities, cardEntity =>
                {
                    CardUtil.ColorEnum color = statsPoint.EntityToColor[cardEntity.entity];
                    cardEntity.image.color   = CardUtil.ColorColorMap[color];
                });


                timeElapsedText.text   = statsPoint.Missed ? "-" : statsPoint.TimeElapsed.ToString("0.00") + " s";
                correctEntityText.text = statsPoint.CorrectEntity.ToString();
                guessedEntityText.text = statsPoint.Missed ? "Missed": statsPoint.GuessedEntity.ToString();
                messageText.text       = "Card " + statsIndex;
            }
        }
    }