Esempio n. 1
0
        // Inspired by https://unity3d.com/learn/tutorials/projects/stealth/screen-fader

        /// <summary>
        /// Fades the screen to black, performs the given action, and then fades the scene back in.
        /// </summary>
        /// <param name="fadeSpeed">The lerp rate when fading.</param>
        /// <param name="onBlack">An action to perform when the screen is black, or <c>null</c> to
        /// perform no action.</param>
        public static void PerformScreenFadeInOut(float fadeSpeed, Action onBlack)
        {
            GameObject screenFader = new GameObject("ScreenFader");

            GUITexture guiTexture = screenFader.AddComponent <GUITexture>();

            guiTexture.color      = Color.clear;
            guiTexture.texture    = Texture2D.whiteTexture;
            guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);

            ScreenFaderScript script = screenFader.AddComponent <ScreenFaderScript>();

            Action onScriptClear = delegate() {
                GameObject.Destroy(screenFader);
            };

            Action onScriptBlack = delegate() {
                if (onBlack != null)
                {
                    onBlack();
                }

                script.FadeToClear(fadeSpeed, onScriptClear);
            };

            script.FadeToBlack(fadeSpeed, onScriptBlack);
        }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        //instantiate weather effects and music
        deathTollText      = GameObject.Find("DeathTollText").GetComponent <Text> ();
        deathTollText.text = "0 have died";
        winterWeather      = GameObject.Find("WinterWeather");
        winterWeather.SetActive(false);
        springWeather = GameObject.Find("SpringWeather");
        springWeather.SetActive(false);
        summerWeather = GameObject.Find("SummerWeather");
        summerWeather.SetActive(false);
        fallWeather = GameObject.Find("FallWeather");
        fallWeather.SetActive(false);
        fallMusicBoxObject   = GameObject.Find("FallMusicBox");
        springMusicBoxObject = GameObject.Find("SpringMusicBox");
        summerMusicBoxObject = GameObject.Find("SummerMusicBox");
        winterMusicBoxObject = GameObject.Find("WinterMusicBox");
        nightMusicBoxObject  = GameObject.Find("NightMusicBox");
        springMusicBoxScript = springMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        summerMusicBoxScript = summerMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        fallMusicBoxScript   = fallMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        winterMusicBoxScript = winterMusicBoxObject.GetComponent <SpringMusicBoxScript> ();
        nightMusicBoxScript  = nightMusicBoxObject.GetComponent <SpringMusicBoxScript> ();

        //find advisors
        guardScript = GameObject.Find("Guard").GetComponent <GuardScript>();
        witchScript = GameObject.Find("Witch").GetComponent <WitchScript>();

        //find notification text
        notificationText      = GameObject.Find("NotificationText").GetComponent <Text> ();
        notificationText.text = "";

        //Load in txt files to word lists
        loadWordLists();

        //find the screen fader
        screenFader       = GameObject.Find("ScreenFader");
        screenFaderScript = screenFader.gameObject.GetComponent <ScreenFaderScript> ();

        //write season text
        seasonText      = GameObject.Find("SeasonText").GetComponent <Text> ();
        seasonText.text = "spring";

        //set us to night
        isDay = false;

        //create list fo opponents
        opponentList = new List <GameObject>();

        //find the day counter in UI
        dayNumberText = GameObject.Find("DayNumberText").GetComponent <Text>();

        //create the world with opponents, player, and decorations (cursor too)
        CreateWorld();

        //establish reference to well
        well       = GameObject.FindGameObjectWithTag("Well");
        wellScript = well.GetComponent <WellScript> ();

        //establish reference to player village
        myPlayerVillage       = GameObject.FindGameObjectWithTag("PlayerVillage");
        myPlayerVillageScript = myPlayerVillage.gameObject.GetComponent <PlayerVillageScript> ();

        //Camera background
        camera.clearFlags = CameraClearFlags.SolidColor;
        destroyWordLists();
        nightMusicBoxScript.FadeInMusic();

        //color trees
        for (int i = 0; i < trees.Length; i++)
        {
            trees [i].GetComponent <Renderer>().material.color = springSummerTreeColor;
        }

        //set day number
        dayNumberText.text = "night " + dayNumber;
        origOpponents      = opponents;
    }