// TODO: // World class will also be responsible for drawing and maintaining the tiles (tilemap tiles) // This should not be updated every step, but only when needed #region INTERFACE // Awake is always called first private void Awake() { InitGameFramerate(); Level test = new Level02(); // Todo, later have a menu too choose a level LoadLevel(test); treeList = new GameObject("Trees"); treeList.transform.SetParent(this.transform); stoneList = new GameObject("Stones"); stoneList.transform.SetParent(this.transform); peepList = new GameObject("Peeps"); peepList.transform.SetParent(this.transform); }
// This is updating the game public void Update(float deltaTime) { this.deltaTime = deltaTime; if (level.IsActive()) { level.Update(deltaTime); } else { // Loading the new level when the last one finished switch (level.LoadLevel()) { case "01": level01 = new Level01(); level = level01; level.Active(); level.Init(); break; case "win": winLevel = new WinLevel(); level = winLevel; level.Active(); level.Init(); break; case "lose": loseLevel = new LoseLevel(); level = loseLevel; level.Active(); level.Init(); break; case "start": startLevel = new StartLevel(); level = startLevel; level.Active(); level.Init(); break; case "02": level02 = new Level02(); level = level02; level.Active(); level.Init(); break; case "load": loadLevel = new LoadImagesLevel(); level = loadLevel; level.Active(); level.Init(); break; } } timer += deltaTime; if (timer >= 1) { fps = frames; frames = 0; timer -= 1; } frames++; }