public void NoAnswer()
        {
            if (!blnEnd)
            {
                objGC.LastState = false;
                if (qtnTmpQuestion.NextNegativeQuestion != null)
                {
                    qtnLastAnimal  = qtnTmpQuestion;
                    lblQuestion    = string.Format(strMessageCharacteristic, qtnTmpQuestion.NextNegativeQuestion.Characteristic);
                    qtnTmpQuestion = qtnTmpQuestion.NextNegativeQuestion;
                }
                else
                {
                    if (!qtnTmpQuestion.Root)
                    {
                        lblQuestion = string.Format(strMessageCharacteristic, qtnLastAnimal.AnimalName);
                        blnEnd      = true;
                    }
                    else
                    {
                        intListIndex++;
                        qtnTmpQuestion = objGC.GetQuestionByIndex(intListIndex);
                        blnEnd         = false;
                        lblQuestion    = string.Format(strMessageCharacteristic, qtnTmpQuestion.Characteristic);

                        if (qtnTmpQuestion.AnimalName == "Monkey")
                        {
                            lblQuestion = string.Format(strMessageAnimal, qtnTmpQuestion.AnimalName);
                            blnEnd      = true;
                        }
                    }
                }
            }
            else
            {
                LooseWindowViewModel newLoose = new LooseWindowViewModel(objGC, qtnTmpQuestion);
                var wnLoose = new LooseWindow(newLoose);
                newLoose.looseWindow = wnLoose;
                wnLoose.Show();
                blnNotOpenMain = true;
                QuestionWindow.Close();
            }
        }
Exemplo n.º 2
0
        private async void Awake()
        {
            Locator.Instance.RegisterIn(this);

            this.gameManager = await Locator.Instance.GetService <GameManager>();

            this.bricksManager = await Locator.Instance.GetService <BricksManager>();

            this.levelWindow = Instantiate(this.LevelWindowPrefab, this.transform).GetComponent <LevelWindow>();
            this.winWindow   = Instantiate(this.WinWindowPrefab, this.transform).GetComponent <WinWindow>();
            this.looseWindow = Instantiate(this.LooseWindowPrefab, this.transform).GetComponent <LooseWindow>();

            this.levelWindow.gameObject.SetActive(true);
            this.winWindow.gameObject.SetActive(false);
            this.looseWindow.gameObject.SetActive(false);

            this.gameManager.OnGameOver += this.ShowLoose;
            this.gameManager.OnGameWin  += this.ShowWin;

            // UniRx observation
            this.bricksManager.MovingTimer
            .Subscribe(value => this.levelWindow.NextBlockStep.text = ((int)value).ToString());

            this.gameManager.Scores
            .Subscribe(value => this.levelWindow.ScoresText.text = value.ToString());

            this.looseWindow.RestartButton
            .OnClickAsObservable()
            .Subscribe(_ => LevelManager.LoadGameScene(LevelManager.GameDifficulty));

            this.looseWindow.MainMenuButton
            .OnClickAsObservable()
            .Subscribe(_ => LevelManager.LoadMainMenuScene());

            this.winWindow.NextGameButton
            .OnClickAsObservable()
            .Subscribe(_ => LevelManager.LoadGameScene(this.gameManager.GetNextGameDifficulty()));

            this.winWindow.MainMenuButton
            .OnClickAsObservable()
            .Subscribe(_ => LevelManager.LoadMainMenuScene());
        }