Beispiel #1
0
    private void SetCpuDisplay(Cpu cpu)
    {
        bool available = cpu != null?GameProgressionUtil.GetCpuAvailability(cpu) : false;

        portrait.sprite = cpu != null ? cpu.sprite : null;
        Color tempColor = portrait.color;

        tempColor.a          = portrait.sprite == null ? 0 : 1;
        tempColor.r          = available ? 255 : 0;
        tempColor.g          = available ? 255 : 0;
        tempColor.b          = available ? 255 : 0;
        portrait.color       = tempColor;
        descriptionText.text = cpu != null ? (available ? cpu.description :cpu.unlockDescription) : "";
        nameText.text        = cpu != null ? (available ? cpu.name : "???") : Cpu.NO_CPU;
        bool interactable = cpu == null || available;

        acceptBtn.interactable = interactable;
        Color tempButtonColor = acceptBtn.image.color;

        tempButtonColor.a     = interactable ? 1 : 0.5f;
        acceptBtn.image.color = tempButtonColor;

        Text  acceptBtnText       = acceptBtn.GetComponentInChildren <Text>();
        Color tempButtonTextColor = acceptBtnText.color;

        tempButtonTextColor.a = interactable ? 1 : 0.5f;
        acceptBtnText.color   = tempButtonTextColor;
        if (cpu != null && available)
        {
            menuAudioManager.PlayAVoice(cpu.voiceGreeting);
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        //Check if card already bought
        EnableCard(!GameProgressionUtil.GetCardAvailability(buyableCardEnum));

        UpdatePrice(GameProgressionUtil.CARD_COST_MAP[buyableCardEnum]);
    }
Beispiel #3
0
 private void AttemptRewardUnlock(RewardAndBarrier[] list, string reasonString)
 {
     Array.ForEach(list, rb =>
     {
         GameProgressionUtil.ChangeBananaCountBy(rb.Reward);
         bananaRewardWindowManager.AddRewardToUnlock(rb, reasonString);
     });
 }
Beispiel #4
0
 private void BuildGameProgressionLogicList(Func <GameProgressionRepresentation, float> getRepField, RewardAndBarrier[] rb, string reasonString)
 {
     gameProgressionLogicContainerList.Add(new GameProgressionLogicContainer(
                                               GameProgressionUtil.GetGameProgressionField(getRepField)
                                               , getRepField
                                               , rb
                                               , reasonString));
 }
Beispiel #5
0
    private void SetUpProgressBar(ProgressBar progressBar, Func <GameProgressionRepresentation, float> getRepField, RewardAndBarrier[] rewardAndBarriers, Func <float, float> valueConverter = null)
    {
        float            progressionField = GameProgressionUtil.GetGameProgressionField(getRepField);
        RewardAndBarrier nextRB           = GameProgressionUtil.GetNextRewardBarrier(rewardAndBarriers, progressionField);

        progressBar.SetValue(valueConverter != null ? valueConverter(progressionField) : progressionField, valueConverter != null ? valueConverter(nextRB.Barrier) : nextRB.Barrier);
        progressBar.SetNextReward(nextRB.Reward);
        progressBar.SetLabelValue(nextRB.Secret);
    }
Beispiel #6
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());
    }
    // Use this for initialization
    void Start()
    {
        Cpu cpu = GameProgressionUtil.CPU_MAP[buyableCpuEnum];

        portrait.sprite  = cpu.sprite;
        description.text = cpu.name;

        //Check if cpu already bought
        EnableCpu(!GameProgressionUtil.GetCpuAvailability(cpu));

        UpdatePrice(GameProgressionUtil.CPU_COST_MAP[buyableCpuEnum]);
    }
Beispiel #8
0
    public void SetCpu(int cpuPortraitIndex, int cpuIndex)
    {
        Cpu cpu = allCpus[cpuIndex];

        //Check if cpu is actually available
        if (cpu != null && cpuIndex != 0 && !GameProgressionUtil.GetCpuAvailability(cpu))
        {
            SetCpu(cpuPortraitIndex, 0);
        }

        cpuIndexes[cpuPortraitIndex] = cpuIndex;


        if (cpu != null && !GameProgressionUtil.GetCpuAvailability(cpu))
        {
            return;
        }

        string name   = cpu != null ? cpu.name : Cpu.NO_CPU;
        Sprite sprite = cpu != null ? cpu.sprite : null;

        switch (cpuPortraitIndex)
        {
        case 0:
            cpu1Portrait.SetCpuDisplay(name, sprite);
            break;

        case 1:
            cpu2Portrait.SetCpuDisplay(name, sprite);
            break;

        case 2:
            cpu3Portrait.SetCpuDisplay(name, sprite);
            break;
        }

        GameSettingsUtil.SetCpuInPlay(cpuPortraitIndex, cpuIndex);
    }
Beispiel #9
0
 protected override GameProgressionUtil.BuyStatus BuyItem()
 {
     return(GameProgressionUtil.BuyCard(buyableCardEnum));
 }
Beispiel #10
0
 public void UpdateBananaCount()
 {
     bananaCount.text = "x" + GameProgressionUtil.GetBananas().ToString();
 }
Beispiel #11
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();
        }
    }
Beispiel #12
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());
            }
        }
    }
Beispiel #13
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)));
        });
    }
Beispiel #14
0
 public void IncreaseBananaCount(int value)
 {
     Debug.Log("Banana count increase from IAP: " + value);
     GameProgressionUtil.ChangeBananaCountBy(value);
     progressStorePage.UpdateBananaCount();
 }