public Stage BuildStage() { Level level = new Level(); StageGenerator generator = new StageGenerator(level); float startTime = Time.realtimeSinceStartup; Stage stage = generator.GenerateStage(); dungeon.stage = stage; float endTime = Time.realtimeSinceStartup; //Debug.Log ("End :"+ (endTime-startTime)); return(stage); }
void BuildDungeon() { Level level = new Level(); StageGenerator generator = new StageGenerator(level); float startTime = Time.realtimeSinceStartup; Stage stage = generator.GenerateStage(); dungeon.stage = stage; float endTime = Time.realtimeSinceStartup; Debug.Log("End :" + (endTime - startTime)); int index = 0; float y = 0, x = 0; for (int i = 0; i < dungeon.level.levelSize.y; i++) { for (int j = 0; j < dungeon.level.levelSize.x; j++) { GameObject ob; tilePool.TryGetValue(index, out ob); if (ob == null) { Tile tile = Tile.CreateTile((TileType)stage.tileType[j, i], new Vector2(x, y), spriteProvider, index); tile.gameObject.transform.parent = dungeon.transform; tilePool.Add(tile.id, tile.gameObject); } else { Tile obTile = ob.GetComponent <Tile>(); obTile.SwitchTileState(stage.tileType[j, i], spriteProvider); } x += dungeon.tileSize.x / 100; x = Mathf.Round(x * 100) / 100; index++; } y += dungeon.tileSize.y / 100; y = Mathf.Round(y * 100) / 100; x = 0; } }