public TestScene() { _random = new DotNetRandom(); MapBuilder builder = new ForestBuilder(64, 64, 0, _random.Next()); builder.Build(); _map = builder.Map; _fov = new FieldOfView(_map); Race playerRace = Engine.Assets.GetAsset <Race>("player"); _player = new Player(playerRace); _map.Add(_player, 32, 32); for (int i = 0; i < 10; i++) { Creature frog = CreatureGenerator.NewCreature("frog"); _map.Add(frog, _map.RandomEmptyPoint(_random)); } for (int i = 0; i < 10; i++) { Creature rat = CreatureGenerator.NewCreature("rat"); _map.Add(rat, _map.RandomEmptyPoint(_random)); } _turnManager = new TurnManager <Creature>(_map.Creatures); _tileSelection = Engine.Assets.GetAsset <Sprite>("tile_selection"); _soundEffectManager.LoadSoundEffect("rain_looped"); _soundEffectManager.LoadSoundEffect("thunder_01"); _soundEffectManager.Play("rain_looped", 0.4f, loop: true); _camera = new Camera(); _camera.Zoom = 1f; int w = Engine.Width / 8; int h = Engine.Height / 8; _camera.Origin = new Vector2(Engine.Width / 2, Engine.Height / 2); _camera.X = _player.RenderX; _camera.Y = _player.RenderY; _mapRenderer = new MapRenderer(_map, _lightingManager, _camera); _creatureRenderer = new CreatureRenderer(_map.Creatures, _map, _lightingManager, _camera); _effectsRenderer = new EffectsRenderer(_map, _lightingManager, _camera); _interfaceRenderer = new InterfaceRenderer(_map, _camera); }
/// Ensure that all the tiles within AdjacentDistance from the player exist. private void BuildAdjacentTiles() { for (float x = -AdjacentDistance; x < AdjacentDistance; x += Builder.TileSize) { for (float z = -AdjacentDistance; z < AdjacentDistance; z += Builder.TileSize) { Vector3 tilePos = new Vector3( (int)((Controller.position.x + x) / Builder.TileSize) * Builder.TileSize, // round down to closest tile origin 0, (int)((Controller.position.z + z) / Builder.TileSize) * Builder.TileSize); if (!_tiles.Contains(tilePos)) { Builder.Build(tilePos); _tiles.Add(tilePos); Debug.Log(String.Format("Built tile {0} {1}", tilePos.x, tilePos.z)); } } } }