Exemple #1
0
 public virtual void TextInputOk(TextInputDialogBox Box)
 {
     //Console.WriteLine(Box.TextEntry);
 }
 public override void TextInputOk(TextInputDialogBox Box)
 {
     if (Box == MapNameDialog)
     {
         map.MapName = Box.TextEntry;
         MapNameLabel.Caption = "Map Name : " + Box.TextEntry;
         Box.TextEntry = "";
     }
 }
        public EditorWindow(Surface Screen)
            : base("Map Editor", 640, 800, Screen)
        {
            AppsDirectory = Directory.GetCurrentDirectory();

            TexIndex = TextureIndex.LoadTextureIndex("../../../../assets/Textures/MapTiles.xml");

            Textures = TexIndex.LoadTextures();

            map = new Map();
            ButtonBg = new BackgroundItem(Color.LightGray);
            ButtonBg.Width = Width;
            ButtonBg.Height = 100;
            ButtonBg.X = 0;
            ButtonBg.Y = 0;

            Background = new BackgroundItem(Color.WhiteSmoke);
            Background.Width = Width;
            Background.Height = Height;

            //WinBar = new WindowBar("Map Editor", Width);
            //WinBar.CloseButton = true;

            LoadMapButton = new ButtonItem("LoadMap", 120, 22, "Load Map");
            LoadMapButton.X = 20;
            LoadMapButton.Y = 30;

            SaveMap = new ButtonItem("SaveMap", 120, 22, "Save Map");
            SaveMap.X = 146;
            SaveMap.Y = 30;

            NewMap = new ButtonItem("NewMap", 120, 22, "New Map");
            NewMap.X = 272;
            NewMap.Y = 30;

            ChangeMapName = new ButtonItem("ChangeMapName", 140, 22, "Change Map Name");
            ChangeMapName.X = 398;
            ChangeMapName.Y = 30;

            SetDefaultTexture = new ButtonItem("SetDefaultTexture", 140, 22, "Set Default Texture");
            SetDefaultTexture.X = 20;
            SetDefaultTexture.Y = 4;

            QuitButton = new ButtonItem("Quit", 100, 22, "Quit");
            QuitButton.X = 166;
            QuitButton.Y = 4;

            mapRenderer = new MapEditRenderer(map,Textures);
            mapRenderer.X = 20;
            mapRenderer.Y = 120;

            MapGrid = new Grid(40, 40);
            MapGrid.Width = 40 * map.Columns;
            MapGrid.Height = 40 * map.Rows;
            MapGrid.X = 20;
            MapGrid.Y = 120;

            MapNameLabel = new LabelItem("Map Name : " + map.MapName);
            MapNameLabel.X = 16;
            MapNameLabel.Y = 65;

            RowLabel = new LabelItem("Row : -");
            RowLabel.X = 20;
            RowLabel.Y = 610;
            ColumnLabel = new LabelItem("Column : -");
            ColumnLabel.X = 20;
            ColumnLabel.Y = 630;

            MapNameDialog = new TextInputDialogBox("Map Name", "Map Name");
            MapNameDialog.X = (Width - MapNameDialog.Width) / 2;
            MapNameDialog.Y = (Height - MapNameDialog.Height) / 2;

            MessageBox = new DialogBox("Message", "Not set");
            MessageBox.X = (Width - MessageBox.Width) / 2;
            MessageBox.Y = (Height - MessageBox.Height) / 2;

            openFile = new OpenFileDialog();
            openFile.InitialDirectory = @"..\..\..\..\Assets\Maps\";
            openFile.Multiselect = false;
            openFile.Title = "Load a Map";
            openFile.Filter = "XML T.D. Map (*.xml) | *.xml";

            Container.Add(Background);
            Container.Add(ButtonBg);

            //Container.Add(WinBar);

            Container.Add(LoadMapButton);
            Container.Add(SaveMap);
            Container.Add(NewMap);
            Container.Add(ChangeMapName);
            Container.Add(SetDefaultTexture);
            Container.Add(QuitButton);

            Container.Add(MapNameLabel);
            Container.Add(RowLabel);
            Container.Add(ColumnLabel);

            Container.Add(mapRenderer);
            Container.Add(MapGrid);

            //Container.Add(MapNameDialog);

            MapNameDialog.SetEvents();
        }
        public void Init()
        {
            TextureIndex Textures = TextureIndex.LoadTextureIndex("../../../../assets/Textures/MapTiles.xml");
            CreepTextures = CreepTextureIndex.LoadIndex("../../../../assets/GameData/CreepSpriteIndex.xml");
            MapTiles = Textures.LoadTextures();

            GameStartP = new Point(200, 100);

            CritSprites = new TextSpriteList();

            MapRender = new MapRenderer(GameObj.map, MapTiles);
            CreepRender = new CreepRenderer(CreepTextures.GetEntry(GameObj.CurrentWave.GfxName));

            GameRectangle = new Rectangle(GameStartP,new Size(GameObj.map.Columns*Tile.TILE_WIDTH,GameObj.map.Rows*Tile.TILE_HEIGHT));
            SelectedTile = new MapCoord();

            MageSprites = new MageAttackSprites();

            TopLevelContainer = new List<GuiItem>();

            MapBackground = MapRender.Render();

            Background = new BackgroundItem(Color.WhiteSmoke);
            Background.X = 0;
            Background.Y = 0;
            Background.Width = Width;
            Background.Height = Height;

            ButtonPanel = new BackgroundItem(Color.LightGray);
            ButtonPanel.X = 0;
            ButtonPanel.Y = 0;
            ButtonPanel.Width = Width;
            ButtonPanel.Height = 80;

            HudPanel = new BackgroundItem(Color.SteelBlue);
            HudPanel.X = 0;
            HudPanel.Y = 640;
            HudPanel.Width = Width;
            HudPanel.Height = 120;

            CloseButton = new ButtonItem("Close",120,22,"Quit");
            CloseButton.X = 10;
            CloseButton.Y = 20;

            PauseButton = new ButtonItem("Pause", 120, 22, "Pause");
            PauseButton.X = 140;
            PauseButton.Y = 20;

            StartWaveButton = new ButtonItem("StartWave", 120, 22, "Start Wave");
            StartWaveButton.X = 270;
            StartWaveButton.Y = 20;

            CombatLogButton = new ButtonItem("CombatLog", 120, 22, "View Combat Log");
            CombatLogButton.X = 10;
            CombatLogButton.Y = 50;

            BuyUnitButton = new ButtonItem("BuyUnit", 120, 22, "Buy a Unit");
            BuyUnitButton.X = 140;
            BuyUnitButton.Y = 50;

            ResetButton = new ButtonItem("Reset", 120, 22, "Restart");
            ResetButton.X = 270;
            ResetButton.Y = 50;

            LabelScore = new LabelItem("Score : 0");
            LabelScore.X = 10;
            LabelScore.Y = 650;
            LabelScore.Foreground = Color.White;

            LabelWave = new LabelItem("Wave : " + GameObj.Wave);
            LabelWave.X = 350;
            LabelWave.Y = 650;
            LabelWave.Foreground = Color.White;

            LabelCrystal = new LabelItem("Crystal Left : " + GameObj.Crystal);
            LabelCrystal.X = 10;
            LabelCrystal.Y = 680;
            LabelCrystal.Foreground = Color.White;

            LabelGold = new LabelItem("Gold : " + GameObj.Gold);
            LabelGold.X = 350;
            LabelGold.Y = 680;
            LabelGold.Foreground = Color.White;

            LabelFps = new LabelItem("Fps : 30");
            LabelFps.X = Width - 70;
            LabelFps.Y = 4;

            LogBox = new CombatLogBox(GameObj.LastCombatLog, Garbage);

            UnitInfoBox = new PlayerUnitInfoBox(new Point(GameStartP.X + GameRectangle.Width + 10,GameStartP.Y));

            CreepBox = new CreepInfoBox();
            CreepBox.FromPoint(new Point(GameStartP.X + GameRectangle.Width + 10, GameStartP.Y + UnitInfoBox.Height + 10));

            UnitClassesChooserBox = new UnitClassesChooser(Garbage);
            UnitClassesChooserBox.X = GameStartP.X + ((GameRectangle.Width - UnitClassesChooserBox.Width) / 2); ;
            UnitClassesChooserBox.Y = GameStartP.Y + ((GameRectangle.Height - UnitClassesChooserBox.Height) / 2); ;

            WaveBox = new WaveInfoBox(GameObj.GetNextWaveInfo(),Garbage);
            WaveBox.X = GameStartP.X + ((GameRectangle.Width - WaveBox.Width) / 2);
            WaveBox.Y = GameStartP.Y + ((GameRectangle.Height - WaveBox.Height) / 2);

            NextWaveBox = new CreepNextWaveBox(GameObj.CreepWaves);
            NextWaveBox.X = 10;
            NextWaveBox.Y = GameStartP.Y;

            PlayerNameDialog = new TextInputDialogBox("Highscore Entry", "Player Name : ");
            PlayerNameDialog.X = (Width - PlayerNameDialog.Width) / 2;
            PlayerNameDialog.Y = (Height - PlayerNameDialog.Height) / 2;
            PlayerNameDialog.TextEntry = PlayerName;

            Container.Add(Background);
            Container.Add(ButtonPanel);
            Container.Add(HudPanel);

            Container.Add(CloseButton);
            Container.Add(PauseButton);
            Container.Add(StartWaveButton);
            Container.Add(CombatLogButton);
            Container.Add(BuyUnitButton);
            Container.Add(ResetButton);

            Container.Add(LabelScore);
            Container.Add(LabelCrystal);
            Container.Add(LabelWave);
            Container.Add(LabelGold);

            Container.Add(LabelFps);

            Container.Add(NextWaveBox);
            Container.Add(UnitInfoBox);
            Container.Add(CreepBox);
        }