示例#1
0
        public void InitializeSfml()
        {
            var tilesets = new EditorTilesets();

            model     = new HexModel(40);
            resources = new ResourceManager();
            resources.Add(tilesets);

            CreateBrushes(tilesets);
            toolBar.SelectPlayer(PlayerColour.Red);

            world = new Map(model, resources);
            world.Create(new Vector2i(10, 10));

            window     = drawingSurface.InitializeSfml();
            editorView = new EditorView(window, world);

            window.OnKeyPress(Keyboard.Key.Space, () => editorView.Return());
            window.OnKeyHold(Keyboard.Key.Left, () => editorView.Scroll(Direction.Left));
            window.OnKeyHold(Keyboard.Key.Right, () => editorView.Scroll(Direction.Right));
            window.OnKeyHold(Keyboard.Key.Up, () => editorView.Scroll(Direction.Up));
            window.OnKeyHold(Keyboard.Key.Down, () => editorView.Scroll(Direction.Down));
            window.OnKeyHold(Keyboard.Key.Add, editorView.IncrementScrollSpeed);
            window.OnKeyHold(Keyboard.Key.Subtract, editorView.DecrementScrollSpeed);
        }
示例#2
0
        private void CreateBrushes(EditorTilesets tilesets)
        {
            ImageList.ImageCollection images;

            images         = terrainPaletteImages.Images;
            terrainBrushes = new List <ImageBrushPair>();

            terrainBrushes.AddTerrainBrush(images["none"], TerrainMetadata.Empty);
            terrainBrushes.AddTerrainBrush(images["grass"], TerrainDefinitions.Grass, tilesets.Terrain.Grass);
            terrainBrushes.AddTerrainBrush(images["desert"], TerrainDefinitions.Desert, tilesets.Terrain.Desert);
            terrainBrushes.AddTerrainBrush(images["water"], TerrainDefinitions.Water, tilesets.Terrain.Water);
            terrainBrushes.AddTerrainBrush(images["forest"], TerrainDefinitions.Forest, tilesets.Terrain.Forest);
            terrainBrushes.AddTerrainBrush(images["hill"], TerrainDefinitions.Hill, tilesets.Terrain.Hill);
            terrainBrushes.AddTerrainBrush(images["mountain"], TerrainDefinitions.Mountain, tilesets.Terrain.Mountain);

            images          = depositsPaletteImages.Images;
            depositsBrushes = new List <ImageBrushPair>();

            depositsBrushes.AddDepositBrush(images["none"], DepositMetadata.Empty);
            depositsBrushes.AddDepositBrush(images["iron"], DepositsDefinitions.Iron, tilesets.Deposits.Iron);
            depositsBrushes.AddDepositBrush(images["gems"], DepositsDefinitions.Gems, tilesets.Deposits.Gems);
            depositsBrushes.AddDepositBrush(images["pearls"], DepositsDefinitions.Pearls, tilesets.Deposits.Pearls);

            images       = unitsPalleteImages.Images;
            unitsBrushes = new List <ImageBrushPair>();

            unitsBrushes.AddUnitBrush(images["none"], UnitMetadata.Empty);
            unitsBrushes.AddUnitBrush(toolBar, images["worker"], UnitsDefinitions.Worker, tilesets.Units.Worker);
            unitsBrushes.AddUnitBrush(toolBar, images["archer"], UnitsDefinitions.Archer, tilesets.Units.Archer);
            unitsBrushes.AddUnitBrush(toolBar, images["swordsman"], UnitsDefinitions.Swordsman, tilesets.Units.Swordsman);
            unitsBrushes.AddUnitBrush(toolBar, images["horseman"], UnitsDefinitions.Horseman, tilesets.Units.Horseman);
            unitsBrushes.AddUnitBrush(toolBar, images["boat"], UnitsDefinitions.Boat, tilesets.Units.Boat);
            unitsBrushes.AddUnitBrush(toolBar, images["dragon"], UnitsDefinitions.Dragon, tilesets.Units.Dragon);

            images             = improvementsPalleteImages.Images;
            improvementBrushes = new List <ImageBrushPair>();

            improvementBrushes.AddImprovementBrush(images["none"], ImprovementMetadata.Empty);
            improvementBrushes.AddImprovementBrush(toolBar, images["farm"], ImprovementDefinitions.Farm, tilesets.Improvements.Farm);
            improvementBrushes.AddImprovementBrush(toolBar, images["lumberjacks"], ImprovementDefinitions.LumberjacksHut, tilesets.Improvements.LumberjacksHut);
            improvementBrushes.AddImprovementBrush(toolBar, images["mine"], ImprovementDefinitions.Mine, tilesets.Improvements.IronMine);
            improvementBrushes.AddImprovementBrush(toolBar, images["barracks"], ImprovementDefinitions.Barracks, tilesets.Improvements.Barracks);
            improvementBrushes.AddImprovementBrush(toolBar, images["stable"], ImprovementDefinitions.Stable, tilesets.Improvements.Stable);
            improvementBrushes.AddImprovementBrush(toolBar, images["shipyard"], ImprovementDefinitions.Shipyard, tilesets.Improvements.Shipyard);
            improvementBrushes.AddImprovementBrush(toolBar, images["dragonlair"], ImprovementDefinitions.DragonLair, tilesets.Improvements.DragonLair);
        }