Пример #1
0
        public static void SaveIndex(CreepTextureIndex Index,String Path)
        {
            XmlSerializer Xs = new XmlSerializer(typeof(CreepTextureIndex));

            TextWriter writer = new StreamWriter(Path);

            Xs.Serialize(writer, Index);

            writer.Close();
        }
Пример #2
0
        public static CreepTextureIndex LoadIndex(String Path)
        {
            CreepTextureIndex Index = new CreepTextureIndex();

            XmlSerializer Xs = new XmlSerializer(typeof(CreepTextureIndex));

            StreamReader reader = new StreamReader(Path);

            Index = (CreepTextureIndex)Xs.Deserialize(reader);

            reader.Close();

            return Index;
        }
Пример #3
0
        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);
        }