Beispiel #1
0
 // Use this for initialization
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
Beispiel #2
0
    public void PointerClick()
    {
        int increment = 0;

        switch (ShiftDirection)
        {
        case YearShiftAmount.IncrementYear:
            increment = 1;
            break;

        case YearShiftAmount.DecrementYear:
            increment = -1;
            break;

        default:
            increment = 0;
            break;
        }

        YearSelectMain.GetInstance().IncrementYear(increment);
    }
Beispiel #3
0
    /*
     * Handles teleportation to a new year. Calls CreateYear and Destroys previous year
     *
     * TeleportToYear: Handles teleportation to a new year. Calls CreateYear and Destroys previous year
     * Parameters: int newYear - the year to travel to so as to create the year
     *             bool useAnimation - default is true. Won't use animation if going from a project back to a year
     */

    public IEnumerator TeleportToYear(int newYear, bool useAnimation = true)
    {
        CurrentlyTraveling = true;
        ImageLoader.GetInstance().CancelLoading();
        PlanetController.DeselectPlanet();

        //Check if there have been planets created before
        if (atYear != -1)
        {
            //Destroy planets in the previous year
            DestroyPlanets(atYear);
        }

        bool[] reenablePanels = new bool[panels.Length];

        //Start teleportation system traveling there by calling from Hyperspeed script
        if (useAnimation)
        {
            for (int index = 0; index < panels.Length; index++)
            {
                reenablePanels[index] = panels[index].enabled;
                panels[index].enabled = false;
            }
            yield return(StartCoroutine(HyperSpeedController.GetComponentInChildren <Hyperspeed>().Travel(true)));
        }

        PlanetDisplay disp = PlanetDisplay.GetInstance();

        if (disp != null)
        {
            disp.SetVisible(false);
            disp.SetViewTarget(null);
        }

        //Create the new year with planets
        CreateYear(newYear);

        //Change the color of the skybox by hashing the year
        Material skybox = RenderSettings.skybox;

        skybox.SetInt("_Rotation", 20 * newYear);
        int   currYearName       = int.Parse(list_years[newYear].yr_name);
        int   colorValueToChange = newYear % 3;
        Color newSkyboxColor;
        float newColorValue = (((float)currYearName * 42) % 255) / 255; //42 is arbitrary, but also... well, you've heard the joke by now

        if (colorValueToChange == 0)                                    // change red value
        {
            newSkyboxColor = new Color(newColorValue, origSkyboxColor.g, origSkyboxColor.b);
            skybox.SetColor("_Tint", newSkyboxColor);
        }
        else if (colorValueToChange == 1)           // change green value
        {
            newSkyboxColor = new Color(origSkyboxColor.r, newColorValue, origSkyboxColor.b);
            skybox.SetColor("_Tint", newSkyboxColor);
        }
        else if (colorValueToChange == 2)           //change blue value
        {
            newSkyboxColor = new Color(origSkyboxColor.r, origSkyboxColor.g, newColorValue);
            skybox.SetColor("_Tint", newSkyboxColor);
        }
        else
        {
            Debug.LogWarning("Invalid Skybox Year Index");
        }
        RenderSettings.skybox = skybox;

        atYear = newYear;
        YearSelectMain.GetInstance().SetPrimaryYear(Int32.Parse(list_years[atYear].yr_name));

        //Start teleportation system ending by Hyperspeed script call
        if (useAnimation)
        {
            for (int index = 0; index < panels.Length; index++)
            {
                panels[index].enabled = reenablePanels[index];
            }
            yield return(StartCoroutine(HyperSpeedController.GetComponentInChildren <Hyperspeed>().Travel(false)));
        }
        CurrentlyTraveling = false;
    }