/// <summary>
        /// Changes the environmental health metric by the given value. Note that the min
        /// value of the metric is 0 and the max is 100.
        /// </summary>
        /// <param name="value">The value by which to modify environmental health</param>
        public void UpdateEnvHealth(int value)
        {
            this.EnvHealth    += value;
            this.PopHappiness += (int)Math.Round(value * campaignWeightings.EnvHealth);

            if (this.EnvHealth > MAX_VALUE)
            {
                this.EnvHealth = MAX_VALUE;
            }

            if (this.EnvHealth < MIN_VALUE)
            {
                this.EnvHealth = MIN_VALUE;

                SimpleDialogue endGameDialogue = new SimpleDialogue(new string[2]
                {
                    "Your decisions have led to a lot of damage to the environment." +
                    "Natural disasters have ravaged the city.",
                    " Take better care of your environment next time"
                }, "Advisory Board");


                CardManager.Instance.QueueGameLost(endGameDialogue);
            }
            else
            {
                //notify weather controller of new metric
                weatherController = WeatherController.Instance;
                weatherController.UpdateWeatherProbabilities((float)this.EnvHealth);
            }
        }
        /// <summary>
        /// Queues the dialogue to be played to the user when the current card
        /// dissappears
        /// </summary>
        /// <param name="endGameDialogue">The dialogue to be played to the user</param>
        public void QueueGameLost(SimpleDialogue endGameDialogue)
        {
            GameLost = true;
            waitingForEventsDuration = 0f;

            this.endGameDialogue = endGameDialogue;
        }
 public OptionDialogue(string question, string[] options, SimpleDialogue dialogue, string cardType)
 {
     this.precedingDialogue = dialogue;
     this.question          = question;
     this.options           = options;
     this.cardType          = cardType;
 }
Exemple #4
0
 public SliderOptionDialogue(string question, int maxValue, int minValue, SimpleDialogue dialogue, string cardType)
 {
     this.maxValue          = maxValue;
     this.minValue          = minValue;
     this.precedingDialogue = dialogue;
     this.question          = question;
     this.cardType          = cardType;
 }
        /// <summary>
        /// Displays purely explanatory dialogue. This means the only interactivity available is
        /// pressing the "Continue" button. i.e. no decisions to be made.
        /// </summary>
        /// <param name="dialogue"></param>
        /// <param name="onClosed"></param>
        public void StartExplanatoryDialogue(SimpleDialogue dialogue, Action onClosed)
        {
            Action onEndOfStatement = () =>
            {
                simpleDialogueViewAnimator.SetBool("InstantTransition", false);
                simpleDialogueViewAnimator.SetBool("IsVisible", false);
                onClosed();
            };

            StartSimpleDialogue(dialogue, onEndOfStatement);
        }
Exemple #6
0
        /// <summary>
        /// Starts the beginning dialogue displayed to the user
        /// </summary>
        public void TriggerDialogue()
        {
            Action handleDialogueClosed = () => this.TriggerDialogue();

            if (this.expositionDialogues.Count == 1)
            {
                handleDialogueClosed = () => CardManager.Instance.StartDisplayingCards();
            }

            this.currentExpositionDialogue = this.expositionDialogues[0];
            this.expositionDialogues.RemoveAt(0);

            DialogueManager.Instance.StartExplanatoryDialogue(this.currentExpositionDialogue, handleDialogueClosed);
        }
Exemple #7
0
        /// <summary>
        /// Opens the campaign panel if the game is in the correct state to do so. Additionally, provides a
        /// small explanatory dialogue of the campaign mechanic. Also, oves the game into a paused state.
        /// </summary>
        public void StartCampaignDialogue()
        {
            CardManager.Instance.SetState(CardManager.GameState.GamePaused);
            Action onClosed = () =>
            {
                campaignPanel.gameObject.SetActive(true);
            };
            SimpleDialogue dialogue = new SimpleDialogue(new string[2] {
                "Hello Mrs. Gatberg, to keep your position as mayor we must launch a new campaign. We need your guidance in designing the new campaign poster.",
                "Be careful what you choose, as it will shape the public's opinion on your future decisions."
            },
                                                         "Advisory Board");

            DialogueManager.Instance.StartExplanatoryDialogue(dialogue, onClosed);
            Debug.Log("Successfully opened campaign");
        }
        private void StartSimpleDialogue(SimpleDialogue dialogue, Action onEndOfStatement)
        {
            simpleDialogueView.SetContent(dialogue);
            this.onEndOfStatements = onEndOfStatement;
            simpleDialogueViewAnimator.SetBool("InstantTransition", false);
            simpleDialogueViewAnimator.SetBool("IsVisible", true);
            statements.Clear();

            simpleDialogueView.npcNameText.text = dialogue.Name;
            foreach (string statement in dialogue.Statements)
            {
                statements.Enqueue(statement);
            }

            DisplayNextStatement();
        }
        /// <summary>
        /// Changes the population happiness metric by the given value. Note that the min
        /// value of the metric is 0 and the max is 100.
        /// </summary>
        /// <param name="value">The value by which to modify population happiness</param>
        public void UpdatePopHappiness(int value)
        {
            this.PopHappiness += value;
            this.PopHappiness += (int)Math.Round(value * campaignWeightings.Happiness);
            if (this.PopHappiness > MAX_VALUE)
            {
                this.PopHappiness = MAX_VALUE;
            }

            if (this.PopHappiness < MIN_VALUE)
            {
                this.PopHappiness = MIN_VALUE;
                SimpleDialogue endGameDialogue = new SimpleDialogue(new string[2]
                {
                    "Oh no, the people in our town became " +
                    "very upset with your decisions. They have voted you out of power.",
                    " Try keeping them happier next time. "
                }, "Advisory Board");
                CardManager.Instance.QueueGameLost(endGameDialogue);
            }
        }
Exemple #10
0
        /// <summary>
        /// Ends the game by displaying dialogue and switching scenes
        /// </summary>
        private void EndGame()
        {
            var endGameImage = GameObject.Find("EndGameImage").GetComponent <Image>();

            GameObject.Find("MetricPanel").SetActive(false);
            GameObject.Find("LevelProgressPanel").SetActive(false);
            GameObject.Find("PauseButton").SetActive(false);
            if (GameWon)
            {
                townAudioClipSwitch.PlayWinScreenMusic();
                SimpleDialogue endGameDialogue = LastCardDialogue.CreateFinalDialogue(PastTokens);
                Sprite         sprite;
                if (MetricManager.Instance.ScoreLow())
                {
                    sprite = Resources.Load <Sprite>("Sprites/BadWinCutscene");
                }
                else
                {
                    //TODO: change to new image when finished art
                    sprite = Resources.Load <Sprite>("Sprites/GoodWinCutscene");
                }
                endGameImage.sprite  = sprite;
                this.endGameDialogue = endGameDialogue;
                StartCoroutine(FadeInCutScene(endGameImage));
                dialogueManager.StartCutsceneDialogue(
                    this.endGameDialogue.Statements,
                    () => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1));
            }
            else if (GameLost)
            {
                townAudioClipSwitch.PlayLoseScreenMusic();
                Sprite sprite = Resources.Load <Sprite>("Sprites/LoseCutscene");
                endGameImage.sprite = sprite;
                StartCoroutine(FadeInCutScene(endGameImage));
                dialogueManager.StartCutsceneDialogue(
                    this.endGameDialogue.Statements,
                    () => SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1));
            }
        }
Exemple #11
0
        private List <SimpleDialogue> ParseExpositionJson(string json)
        {
            List <SimpleDialogue> result = new List <SimpleDialogue>();

            JSONArray expositionArray = SimpleJSON.JSON.Parse(json).AsArray;

            foreach (JSONNode exposition in expositionArray)
            {
                List <string> dialogueList = new List <string>();

                foreach (JSONNode dialogue in exposition["dialogue"])
                {
                    dialogueList.Add(dialogue);
                }

                SimpleDialogue sd = new SimpleDialogue(dialogueList.ToArray(), exposition["name"]);
                result.Add(sd);
            }


            return(result);
        }
Exemple #12
0
        /// <summary>
        /// Submits the campaign form to be processed and applied to the MetricManager, should be triggered by a button
        /// when the user finishes creating the campaign.
        /// </summary>
        public void OnSubmit()
        {
            MetricManager.Instance.RenderMetrics();
            campaignPanel.gameObject.SetActive(false);
            // Reset the weightings on every campaign
            popHappinessScore  = 0;
            goldScore          = 0;
            environmentalScore = 0;

            CalculateDropdownScores();
            CalculateImageScore();
            UpdateMetricManagerWeightings();
            SimpleDialogue dialgoue = GenerateExplanatoryDialgoue();

            Action onDialogueClose = () =>
            {
                CardManager.Instance.SetState(CardManager.GameState.WaitingForEvents);
            };

            DialogueManager.Instance.StartExplanatoryDialogue(dialgoue, onDialogueClose);

            Debug.Log("Scores from campaign: money: " + goldScore + " pop happiness: " + popHappinessScore + " env: " + environmentalScore);
        }
        /// <summary>
        /// Changes the gold metric by the given value. Note that the min
        /// value of the metric is 0 and the max is 100.
        /// </summary>
        /// <param name="value">The value by which to modify gold</param>
        public void UpdateGold(int value)
        {
            this.Gold         += value;
            this.PopHappiness += (int)Math.Round(value * campaignWeightings.Gold);

            if (this.Gold > MAX_VALUE)
            {
                this.Gold = MAX_VALUE;
            }

            if (this.Gold < MIN_VALUE)
            {
                this.Gold = MIN_VALUE;

                SimpleDialogue endGameDialogue = new SimpleDialogue(
                    new string[2]
                {
                    "You have lost all your town's money. Now you cannot build the town.",
                    "Be careful when making decisions that involve spending money next time."
                }, "Advisory Board");
                CardManager.Instance.QueueGameLost(endGameDialogue);
            }
        }
 /// <summary>
 /// Sets the contents to be displayed
 /// </summary>
 /// <param name="dialogue">to be displayed</param>
 public void SetContent(SimpleDialogue dialogue)
 {
     npcImage        = GameObject.Find("SimpleNPCImage").GetComponent <Image>();
     npcImage.sprite = NPCSpriteManager.Instance.GetSprite(dialogue.Name);
 }
        /// <summary>
        /// Creates a SimpleDialogue object based on the the provided PastTokens.
        /// </summary>
        /// <param name="PastTokens">PastTokens representing the users story decisions.</param>
        /// <returns>A SimpleDialogue representing the dialogue played to the user reflecting their decisions</returns>
        public static SimpleDialogue CreateFinalDialogue(Dictionary <string, string> PastTokens)
        {
            List <string> finalDialogue = new List <string>();
            List <string> goodDeeds     = new List <string>();
            List <string> badDeeds      = new List <string>();

            finalDialogue.Add("Mrs. Gatburg, it's your last day as Mayor!");
            string accomplishments = "You've done plenty in your time, and we're honoured to have helped you along the way. ";

            goodDeeds.Add("You've made plenty of swell decisions that did wonders for the townspeople. ");
            badDeeds.Add("You've made some not so swell decisions that on hindsight could've been done better. ");

            foreach (KeyValuePair <string, string> entry in PastTokens)
            {
                if (entry.Key.Equals("investment"))
                {
                    goodDeeds.Add("You invested in " + entry.Value + " early that has helped the town's long term growth. ");
                }
                if (entry.Key.Equals("arvio2"))
                {
                    switch (entry.Value)
                    {
                    case "yes":
                        badDeeds.Add("You permitted Arvio to set up a coal mine in the city that did damage to the city's landscape'. ");
                        break;

                    case "no":
                        goodDeeds.Add("You prevented Arvio from setting up a coal mine in the city that could damage the city's landscape. ");
                        break;
                    }
                }
                if (entry.Key.Equals("farming"))
                {
                    switch (entry.Value)
                    {
                    case "dairy":
                        badDeeds.Add("You encouraged dairy farming which is much less environmentally friendly than vegetable farming. ");
                        break;

                    case "no":
                        goodDeeds.Add("You promoted farming fruits and vegetables which is much more environmentally friendly. ");
                        break;
                    }
                }
                if (entry.Key.Equals("transport"))
                {
                    switch (entry.Value)
                    {
                    case "gas":
                        badDeeds.Add("You did not do much to solve transport which did a lot of damage to the environment. ");
                        break;

                    case "ev":
                        goodDeeds.Add("You promoted electric vehicles which has much lower emissions compared to traditional cars. ");
                        break;

                    case "public":
                        goodDeeds.Add("You build up the city's public transport which has much lower emissions compared to personal cars. ");
                        break;
                    }
                }
                if (entry.Key.Equals("refugees"))
                {
                    switch (entry.Value)
                    {
                    case "yes":
                        goodDeeds.Add("You even went out of your way to lend a helping hand to the neighbouring city in their moment of need. ");
                        break;
                    }
                }
            }

            if (goodDeeds.Count > 1)
            {
                finalDialogue.AddRange(goodDeeds);
            }

            if (badDeeds.Count > 1)
            {
                finalDialogue.AddRange(badDeeds);
            }
            finalDialogue.Add("It was a lot of fun working with you, and we hoped you learn't a lot through your time as mayor!");
            SimpleDialogue output = new SimpleDialogue(finalDialogue.ToArray(), "Advisory Board");

            return(output);
        }