Exemplo n.º 1
0
        public void PresentPRStatement()
        {
            Debug.Log(statement);
            if (statement == null)
            {
                statement = new PRStatement();

                Sentence sentence = statement.getSentence();

                string prefabPath       = "WordGame/Word";
                string teleprompterPath = "WordGame/Teleprompter";
                string dropdownPath     = "WordGame/Choice";

                GameObject teleprompter = Instantiate(Resources.Load <GameObject>(teleprompterPath), menuCanvas.gameObject.transform);
                Transform  wordParent   = teleprompter.transform.Find("Panel/Viewport/Content/WordPanel");

                // do unity loading stuff for UI here

                List <Word> words = sentence.getWords();
                for (int i = 0; i < words.Count; i++)
                {
                    Word word = words.ElementAt(i);

                    // Display vanilla word
                    if (!word.isOption())
                    {
                        GameObject newVanillaWordObject = Instantiate(Resources.Load <GameObject>(prefabPath), wordParent.transform);
                        WordUI     ui = newVanillaWordObject.GetComponent <WordUI>();

                        ui.setText(word.getVanillaWord());

                        continue;
                    }

                    // Add choice dropdown
                    GameObject newChoiceObject = Instantiate(Resources.Load <GameObject>(dropdownPath), wordParent.transform);
                    ChoiceUI   choiceObject    = newChoiceObject.GetComponent <ChoiceUI>();

                    if (word.isOption())
                    {
                        choiceObject.SetOptions(word.getChoice().options.Keys.ToList(), i);
                    }

                    choiceObject.enabled = true;
                }

                Transform ok       = teleprompter.transform.Find("ButtonPanel").Find("OK");
                Button    okButton = ok.gameObject.GetComponent <Button>();

                okButton.onClick.AddListener(delegate {
                    okButton.onClick.RemoveAllListeners();
                    this.SubmitPrStatements();
                    this.RunRound();
                    Destroy(teleprompter);
                });
            }
        }
Exemplo n.º 2
0
        public void SubmitPrStatements()
        {
            List <FucksBucketMod> fucksBucketMods = statement.getSentence().CalculateFuckBuckets();


            foreach (FucksBucketMod fucksBucketMod in fucksBucketMods)
            {
                if (fuckBuckets.ContainsKey(fucksBucketMod.fucksBucketKey))
                {
                    fuckBuckets[fucksBucketMod.fucksBucketKey] += fucksBucketMod.baseChange * fucksBucketMod.modifier;

                    Debug.Log(fuckBuckets[fucksBucketMod.fucksBucketKey]);
                }
                else
                {
                    Debug.Log($"{nameof(fucksBucketMod)} provided invalid {nameof(fucksBucketMod.fucksBucketKey)}");
                }
            }
        }