private void BuildStates() { menu = new GameState("Menu"); stateManager.RequestStatePush(menu); Clickable button = new Clickable(uiTextures.GetAsset("Button"), new Vector2(200), MouseButtons.LMB); menu.CreateNewEntity(button); button.OnClickEvent += ActivateLevel; button = new Clickable(uiTextures.GetAsset("Button"), new Vector2(400), MouseButtons.LMB); menu.CreateNewEntity(button); button.OnClickEvent += ActivateLevel; level = new GameState("Level", StateActivityLevel.Inactive); stateManager.RequestStatePush(level); DrawLayer terrainLayer = level.CreateNewDrawLayer("IsoTerrain", false, new Vector2(64, 32)); //DrawLayer cartTerrainLayer = menu.CreateNewDrawLayer("CartTerrain", false, new Vector2(32), new Vector2(400, 0)); DrawLayer structureLayer = level.CreateNewDrawLayer("Structures", false, new Vector2(64, 32)); BatchedGrid <ProtoEntity> isoTerrain = BatchedGrid <ProtoEntity> .CreateIsometricGrid(new Vector2(0, 0), false, textures.GetAsset("GridTile"), textures.GetAsset("GrassTile")); level.CreateNewEntity("IsoTerrain", isoTerrain); //Terrain cartTerrain = Terrain.CreateSquareTerrain(new Vector2(4, 0), new Vector2(10), textures.GetAsset("GridTile"), textures.GetAsset("GrassTopDown")); //menu.CreateNewEntity("CartTerrain", cartTerrain); var rand = new Random(); for (var i = 0; i < 500; i++) { var pos = new Vector2(rand.Next(100), rand.Next(100)); var gridObject = GridObject.CreateIsometricGridObject(textures.GetAsset("Obelisk"), structureLayer, pos, new Vector2(2)); level.CreateNewEntity("Structures", gridObject); pos = new Vector2(rand.Next(100), rand.Next(100)); gridObject = GridObject.CreateIsometricGridObject(textures.GetAsset("House"), structureLayer, pos, new Vector2(1)); level.CreateNewEntity("Structures", gridObject); } var cameraController = new CameraController(menu.Camera); level.CreateNewEntity(cameraController); options = new GameState("Options", StateActivityLevel.Inactive); stateManager.RequestStatePush(options); Clickable exitButton = new Clickable(uiTextures.GetAsset("Button"), new Vector2(0)); exitButton.OnClickEvent += Quit; options.CreateNewEntity(exitButton); }
private void BuildStates() { const int width = 17; const int height = 17; const float mineDensity = 0.2f; var tileSize = new Point(32); var spriteDraw = new SpriteDrawSystem(); var spriteGridSys = new MineScreenSystem(); var mineSystem = new MineFieldSystem(); var cameraSystem = new MineCameraSystem(); level = new GameState("Level", StateActivityLevel.Active, cameraSystem, spriteDraw, mineSystem, spriteGridSys); var camera = level.CreateNewEntity(); cameraSystem.AddNewComponentToEntity( new Camera(CameraConstraints.WrapAround, new Rectangle(0, 0, tileSize.X * width, tileSize.Y * height)), camera, level); level.SetRenderCamera(camera); // level.CreateNewEntityWithComponent(Sprite.CreateIsometricSprite(textures.GetAsset("Cell"), new Vector2(16, 16), new Vector2(16, 16))); stateManager.RequestStatePush(level); var mineFieldTile = Sprite.CreateTileSprite(textures.GetAsset("Cell32"), 13); mineFieldTile.FrameX = 12; //ArrayGrid grid = new ArrayGrid(Perspective.Standard, mineSystem.CreateMinefield(width, height, mineDensity, minefieldTile), new Vector2(16, 16), true, true); var mineField = level.CreateNewEntityWithComponent(new MineField(Vector2.Zero, tileSize, width, height, true, mineDensity)); var spriteGrid = WrappingScreenGridSystem.CreateScreenFillingGrid(textures.GetAsset("Cell32"), graphics.GraphicsDevice.Viewport.Bounds.Size, tileSize.ToVector2(), Perspective.Standard); spriteGrid.SetWrappedDimensions(width, height); var screenGrid = level.CreateNewEntityWithComponent(spriteGrid); //level.CreateComponentForEntity(mineFie), mineField); //int sprite = level.CreateNewEntityWithComponent(minefieldTile); }
private void InitialiseContentDependents() { Log.SetMessageFont(fonts.GetAsset("CourierNew")); GameState.SetDefaultCamera(new Camera(graphics)); }
private void InitialiseContentDependents() { Log.SetMessageFont(fonts.GetAsset("CourierNew")); }