예제 #1
0
    protected void ShowNewsHeadline()
    {
        // Randomise a news headline.

        /*IdealType[] ideals = Utility.GetEnumValues<IdealType>();
         * IdealLean headlineLean = UnityEngine.Random.value > 0.5f ? IdealLean.Positive : IdealLean.Negative;
         * IdealType headlineIdeal = ideals[UnityEngine.Random.Range(0, ideals.Length)];
         * bool validHeadline = false;
         * while (!validHeadline)
         * {
         *      headlineIdeal = ideals[UnityEngine.Random.Range(0, ideals.Length)];
         *
         *      if (player.Ideals.GetIdealValue(headlineIdeal) != 0f)
         *      {
         *              validHeadline = true;
         *              continue;
         *      }
         * }
         * string headline = "Headline is " + headlineLean.ToString() + " " + headlineIdeal.ToString() + "!";
         *
         * newsHeadline.InitHeadline(headlineIdeal, headlineLean, headline);
         * newsHeadline.Show();*/

        if (!gameRunning)
        {
            return;
        }

        IdealType[]      allIdeals   = Utility.GetEnumValues <IdealType>();
        List <IdealType> validIdeals = new List <IdealType>();

        for (int i = 0; i < allIdeals.Length; i++)
        {
            if (player.Ideals.GetIdealValue(allIdeals[i]) != 0f)
            {
                validIdeals.Add(allIdeals[i]);
            }
        }

        // If for whatever reason there are no valid ideals, just throw 'em all in!
        if (validIdeals.Count == 0)
        {
            validIdeals.AddRange(allIdeals);
        }

        NewsHeadline headline = NewsHeadlineCollection.Instance.GetRandomByIdealType(validIdeals[UnityEngine.Random.Range(0, validIdeals.Count)]);;

        newsHeadline.InitHeadline(headline);
        newsHeadline.Show();

        this.PerformAction(GameSettings.Instance.HeadlineOnScreenTime, () => {
            newsHeadline.Hide();
        });

        fox.DoAnnounce();

        for (int i = 0; i < allSheep.Count; i++)
        {
            allSheep[i].SetState(SheepState.Newspaper);
        }

        // Remove cards display.
        playerControls.Hide();
    }