Example #1
0
    void Start()
    {
        _manager = this;
        database = _database;
#if !UNITY_EDITOR
        toucControl = true;
#endif
        if (!toucControl)
        {
            CrossPlatformInputManager.useHardwareInput();
        }
        else
        {
            CrossPlatformInputManager.useTouchInput();
        }

        UIHandler = _UIHandler;
        path      = Application.persistentDataPath;
        Debug.Log("Game started at " + path);
        mainThread = Thread.CurrentThread;
        Timer.start("Loading Materials");
        for (int i = 0; i <= Enum.GetValues(typeof(MyMaterial)).Length - 1; i++)
        {
            ((MyMaterial)i).loadMaterial();
        }
        Timer.endAndPrint("Loading Materials");
        halfMaxChunkCount       = (maxChunkCount / 2);
        chunkPrefab             = _chunkPrefab;
        chunks                  = new Chunk[maxChunkCount, 50, maxChunkCount];
        currentTerrainGenerator = new TerrainGenerator();


        //INITIATIONS
        ItemMeshCreator.init();
        IconRenderer.init();
        if (startGame)
        {
            //LOAD SAVE FILE
            save = SaveLoader.load(saveFileName);
            currentTerrainGenerator.initiateMap();
            //INITIALIZE PLAYER
            if (save.player == null)
            {
                save.player = new Player(spawnPoint);
            }
            save.player.init(playerPrefab);
            //INITIALIZE UI
            _UIHandler.init();
        }


        //START BACKGOUND THREAD
        if (startGame)
        {
            Thread thread = new Thread(Timer.doAsycTick);
            thread.IsBackground = true;
            thread.Start();
        }
    }