Example #1
0
 void OnDestroy()
 {
     if (switcher == this)
     {
         switcher = null;
     }
 }
Example #2
0
    /*
     * BeginTravel: Save current year user is in and travel to the planet executable
     * Parameters: None
     */
    public void BeginTravel()
    {
        //Save the current year in an output text file

        //Write the year index to the following path
        string path;

#if UNITY_EDITOR
        if (USystem.GetOculusBool())
        {
            path = Application.dataPath + "/../Website/data/VRClubUniverseData/Oculus/saveData.txt";                              //saveData not exist on my side
        }
        else
        {
            path = Application.dataPath + "/../Website/data/VRClubUniverseData/Vive/saveData.txt";  //saveData not exist on my side
        }
#elif UNITY_STANDALONE
        if (USystem.GetOculusBool())
        {
            path = Application.dataPath + "/../VRClubUniverseData/Oculus/saveData.txt";                              //Change everything under VRClubUniverseData to VR../Vive/
        }
        else
        {
            path = Application.dataPath + "/../VRClubUniverseData/Vive/saveData.txt";      //Change everything under VRClubUniverseData to VR../Vive/
        }
#endif

        string currentYear = UniverseSystem.GetInstance().GetCurrentYear();
        Debug.Log("Writing current year to saveData file, year Index: " + currentYear);
        File.WriteAllText(path, currentYear);

        //Begin loading the executable
        Debug.Log("loading executable: " + executableString);
        ExecutableSwitch.LoadExe(executableString);
    }
Example #3
0
    private void Awake()
    {
        isOculus = USystem.GetOculusBool();
        if (switcher == null)
        {
            switcher = this;
        }
        else
        {
            Destroy(this);
        }
        isLoading = false;

        appDatapath = Application.dataPath;

        Debug.Log("appDatapath: " + appDatapath);
    }
Example #4
0
    // called when user pulls trigger while pointing at this button
    public void PointerClick()
    {
        // switch to detailed entry view
        if (!data.title.Equals(""))
        {
            // get detailed entry canvas, pass it data, enable it
            DetailedEntry infoPanel = DetailedEntry.GetInstance();
            infoPanel.UpdateInfo(data.title, data.creator, data.description, data.year, data.des_tag, data.image);
            infoPanel.GetTravelButton().SetExeString(ExecutableSwitch.GetFullPath(data.executable + ".exe", data.executable, data.year));
            infoPanel.SetVisible(true);

            // disable search results and category panel
            ResultDisplay.GetInstance().SetVisible(false);
            CategoryManager.GetInstance().SetVisible(false);

            detailedEntryCallback = infoPanel.ReceiveSprite; // pass on sprite if a sprite is received
        }
    }
Example #5
0
    public void PointerClick()
    {
        if (selectedPlanet == this)
        {
            LeverScript lever = LeverScript.GetInstance();
            lever.SetThrottle(lever.GetDefaultThrottle());
            PlanetDisplay disp = PlanetDisplay.GetInstance();
            if (disp.GetViewTarget() == transform)
            {
                disp.SetVisible(false);
                disp.SetViewTarget(null);
                disp.GetTravelInteractable().SetExeString("");
            }

            selectedPlanet = null;

            Highlight("none"); // disables highlights
        }
        else
        {
            LeverScript.GetInstance().SetThrottle(0.0f);
            PlanetDisplay disp = PlanetDisplay.GetInstance();
            disp.SetVisible(true);
            disp.SetViewTarget(transform);
            disp.UpdateInfo(data.title, data.creator, data.description, data.year, data.des_tag, data.image);
            disp.GetTravelInteractable().SetExeString(ExecutableSwitch.GetFullPath(data.executable + ".exe", data.executable, data.year));

            if (selectedPlanet != null)
            {
                selectedPlanet.Highlight("none");
            }
            selectedPlanet = this;

            Highlight("selected");
        }
    }
Example #6
0
    // displays the passed planet data
    public void DisplaySearchResults(List <PlanetData> searchResults)
    {
        //saves data for future use
        planetSearchResults = searchResults;
        topEntryIndex       = 0;
        maxTopEntryIndex    = planetSearchResults.Count - entry_list.Length;

        //displays the data
        UpdateDisplayedEntries();

        //starts loading the planet image data
        List <string>     imagePaths = new List <string>();
        List <PassSprite> callbacks  = new List <PassSprite>();

        planetsWaitingForImages.Clear();
        for (int index = 0; index < planetSearchResults.Count; index++)
        {
            PlanetData planet = planetSearchResults[index];
            planetsWaitingForImages.Add(index);
            imagePaths.Add(ExecutableSwitch.GetFullPath(planet.image_name, planet.executable, planet.year));
            callbacks.Add(ReceiveSprite);
        }
        ImageLoader.GetInstance().LoadImages(imagePaths, callbacks);
    }
Example #7
0
    /*
     * CreateYear: Creates the year gameobject and instantiates the planets
     * Parameters: int yearIndex - Passes in the index of the selected year to grab from List<Year>
     */
    public void CreateYear(int yearIndex)
    {
        //Checks if the year the user is traveling to is the Home Year. No JSON file for the home year
        if (yearIndex != -1)
        {
            //Gets the name of the year in the list of years
            string yearName = list_years[yearIndex].yr_name;

            //Get the year object from the List via Index
            Year year = list_years[yearIndex];

            //Open the JSON file with the name yr_name parameter passed in
            //string jsonString = File.ReadAllText("VRClubUniverseData/" + yearName + ".json");
            string jsonString;

#if UNITY_EDITOR
            if (isOculus)
            {
                jsonString = File.ReadAllText(Application.dataPath + "/../Website/data/VRClubUniverseData/Oculus/" + yearName + ".json");
            }
            else
            {
                jsonString = File.ReadAllText(Application.dataPath + "/../Website/data/VRClubUniverseData/Vive/" + yearName + ".json");
            }
#elif UNITY_STANDALONE
            if (isOculus)
            {
                jsonString = File.ReadAllText(Application.dataPath + "/../VRClubUniverseData/Oculus/" + yearName + ".json");
            }
            else
            {
                jsonString = File.ReadAllText(Application.dataPath + "/../VRClubUniverseData/Vive/" + yearName + ".json");
            }
#endif

            //TESTING
            Debug.Log("Jsonstring is: " + jsonString);

            //Create a JSONPlanet array and read the JSON file
            PlanetJSON[] universe = JsonHelper.FromJson <PlanetJSON>(jsonString);

            //For each object in the JSONPlanet array
            //foreach (PlanetJSON json_planet in universe)
            List <string>     imagePaths = new List <string>();
            List <PassSprite> callbacks  = new List <PassSprite>();
            for (int i = 0; i < universe.Length; i++)
            {
                PlanetJSON json_planet = universe[i];

                //Instantiate a Planet object with a Planet component on it
                GameObject planet = Instantiate(prefab_planet, planetPosition, Quaternion.identity);

                //Set the name of the planet game object in hierarchy
                planet.name = "Planet";

                //Add a Planet component on the new planet game object to declare it a planet object
                PlanetController currPlanet = planet.GetComponent <PlanetController>();

                //Set the parent of the new Planet object to be the Planets gameobject
                planet.transform.parent = year.planets.transform;

                //Set the planet's name
                currPlanet.data.title = json_planet.Name;

                //Set the planet's creator
                currPlanet.data.creator = json_planet.Creator;

                //Set the planet's description
                currPlanet.data.description = json_planet.Description;

                //Set the planet's year
                currPlanet.data.year = json_planet.Year.ToString();

                //Set the planet's executable path
                currPlanet.data.executable = json_planet.Executable;

                //Set the planet's tags by creating a string array of the same length
                currPlanet.data.des_tag = new string[json_planet.Tags.Length];

                //For each tag in the json planet
                for (int j = 0; j < json_planet.Tags.Length; j++)
                {
                    // Set the tag of the current planet equal to the json tag
                    currPlanet.data.des_tag[j] = json_planet.Tags[j];
                }

                //Get the planet's image with path
                currPlanet.data.image_name = json_planet.Image;

                //Turn the image from path URL into a Sprite to set
                imagePaths.Add(ExecutableSwitch.GetFullPath(currPlanet.data.image_name, currPlanet.data.executable, currPlanet.data.year));
                callbacks.Add(currPlanet.ReceiveSprite);

                currPlanet.data.image = null;

                //Adds the read planet into the year
                year.list_planets.Add(currPlanet);

                Renderer rend     = currPlanet.GetComponent <Renderer>();
                Material material = Instantiate(rend.material);
                rend.material = material;
                ChangeValue val = GetComponentInChildren <ChangeValue>();
                if (i > universe.Length / 2)
                {
                    val.change(rend, currPlanet.data.title, int.Parse(currPlanet.data.year), false);
                }
                else
                {
                    val.change(rend, currPlanet.data.title, int.Parse(currPlanet.data.year), true);
                }
            }

            ImageLoader.GetInstance().LoadImages(imagePaths, callbacks);

            OrbitManager orbitManager = OrbitManager.GetOrbitManager();
            if (orbitManager != null)
            {
                orbitManager.PopulateOrbit(year.list_planets.ToArray());
            }
            else
            {
                Debug.LogError("Could not find OrbitManager to populate planets. Waiting for OrbitManager...");
                StartCoroutine(WaitForOrbit(year));

                /*
                 * orbitManager = OrbitManager.GetOrbitManager();
                 * if (orbitManager != null)
                 * {
                 *  orbitManager.PopulateOrbit(year.list_planets.ToArray());
                 * } else
                 * {
                 *  Debug.LogError("Still could not find OrbitManager to populate planets.");
                 * }
                 */
            }
        }

        // Handles case if the year traveling to is the new year
        else
        {
            // There shouldn't be any planets in the Home year
        }
    }