Exemplo n.º 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();
        }
    }
Exemplo n.º 2
0
 public static void init()
 {
     foreach (MyMaterial m in Enum.GetValues(typeof(MyMaterial)))
     {
         MaterialSetting ms = m.getSetting();
         if (ms != null && ms.itemRenderStyle == ItemRenderStyle.ITEM)
         {
             if (ms.texture != null)
             {
                 ItemMeshCreator imc = new ItemMeshCreator(ms.texture);
                 ms.itemPrefab = imc.getGameObject();
             }
             else
             {
                 throw new Exception(m + " does not have a texture attached!");
             }
         }
         else if (ms != null && ms.isPlaceable)
         {
             ms.itemPrefab = CubeMeshCreator.getGameObject(m);
         }
     }
 }