// unity start
    void Start()
    {
        // initialize some static stuff
        PG_AlbedoMap.Initialize();
        PG_Craters.Initialize();

        // hide everything
        HideEverything();

        // turn off controller navigation of the UI
        EventSystem.current.sendNavigationEvents = false;

        // get to the player data
        var playerData = DataController.m_instance.m_playerData;

        // show the player in case we had it hidden in the editor
        m_playerShip.Show();

        // reset the buttons to default
        m_buttonController.SetBridgeButtons();

        // switch to the current location
        SwitchLocation(playerData.m_general.m_location);

        // make sure the scene is blacked out
        SceneFadeController.m_instance.BlackOut();

        // reset the save game timer
        m_timer = 0.0f;

        // connect the persistent ui canvas to the main camera
        var persistentUI = GameObject.FindWithTag("Persistent UI");
        var uiCamera     = GameObject.FindWithTag("UI Camera");
        var canvas       = persistentUI.GetComponent <Canvas>();
        var camera       = uiCamera.GetComponent <Camera>();

        canvas.worldCamera   = camera;
        canvas.planeDistance = 15.0f;
    }
Пример #2
0
    // generate maps and show them on the planet game object
    void MakeSomeMagic()
    {
        // show progress bar
        EditorUtility.DisplayProgressBar("Planet Generator", "Initializing...", 0.0f);

        // load the game data
        var textAsset = Resources.Load(m_gameDataFileName) as TextAsset;

        // convert it from the json string to our game data class
        var gameData = JsonUtility.FromJson <GameData>(textAsset.text);

        // initialize the game data
        gameData.Initialize();

        // initialize static components of planet generator
        PG_AlbedoMap.Initialize();
        PG_Craters.Initialize();

        // calculate the texture map scale (and it must be an even number)
        m_textureMapScaleX = Mathf.FloorToInt((float)m_textureMapWidth / (float)PG_Planet.c_width);
        m_textureMapScaleY = Mathf.FloorToInt((float)m_textureMapHeight / (float)(PG_Planet.c_height + m_numPolePaddingRows * 2));

        if (m_textureMapScaleX < 2)
        {
            m_textureMapScaleX = 2;
        }
        else if ((m_textureMapScaleX & 1) == 1)
        {
            m_textureMapScaleX--;
        }

        if (m_textureMapScaleY < 2)
        {
            m_textureMapScaleY = 2;
        }
        else if ((m_textureMapScaleY & 1) == 1)
        {
            m_textureMapScaleY--;
        }

        // do some magic
        PG_Planet pgPlanet;

        for (var id = 0; id < c_numPlanets; id++)
        {
            if (m_debugMode)
            {
                id = m_debugPlanetID;
            }

            pgPlanet = new PG_Planet(gameData, m_planetImagesPath, id);

            if (pgPlanet.m_mapIsValid)
            {
                var filename = Application.dataPath + "/" + m_resourcesPath + "/Planets/" + pgPlanet.m_id + ".bytes";

                if (m_debugMode || !File.Exists(filename))
                {
                    if (!GeneratePlanetTextureMaps(pgPlanet, filename))
                    {
                        break;
                    }
                }
            }

            if (m_debugMode)
            {
                break;
            }
        }

        // show progress bar
        EditorUtility.ClearProgressBar();
    }