Beispiel #1
0
        static void Main()
        {
            // Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //try
            //{
                Game game = new Game();
                GameForm gf;
                gf = new GameForm(game);
                Thread t = new Thread(new ParameterizedThreadStart(game.Start));
                t.Name = "GameLoop";
                t.IsBackground = true;
                t.TrySetApartmentState(ApartmentState.STA);
                t.Start(gf);

                //Thread tt = new Thread(new ThreadStart(gf.Show2));
                //tt.Start();
                gf.Init();
            //}
            //catch (Exception e) { MessageBox.Show(e.Message + e.InnerException + e.Source + e.StackTrace); }

            //if (t.ThreadState == ThreadState.Running)
             //   t.Abort();

            //Application.Run(new GameForm());
        }
Beispiel #2
0
 internal override void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[51], 1f, BitmapInterpolationMode.Linear);
     foreach (var b in Buttons)
         b.Draw(gf);
     for (int i = 0; i < about.Count(); i++)
     {
         gf.d2dRenderTarget.DrawText(about[i], new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 20.0f), new RectangleF(gf.Width * 0.2f, (gf.Height * 0.3f) + (i*22), gf.Width * 0.8f, gf.Height * 0.9f), GameForm.solidColorBrush);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Called when New Game is clicked
 /// </summary>
 public World(GameForm gf,string mapname)
 {
     Player = new Tower_Defense.Player();
     Gameform = gf;
     Map = new Level(mapname);
     UIElements.Add(new Button("Next Wave", gf.Width - 425, 5,150,50));
     UIElements.Add(new Button("Pause Game", gf.Width - 275, 5,150,50));
     UIElements.Add(new Button("Exit", gf.Width - 125, 5, 100, 50));
     UIElements.Add(new Button("Speed", gf.Width - 575, 5, 150, 50));
     BuildMenu = new Tower_Defense.BuildMenu();
     BuildMenu.initMenu((int)(gf.Width / 1.31), 75, gf);
 }
Beispiel #4
0
            /*internal void Draw(SharpDX.Direct2D1.RenderTarget d2dRenderTarget)
            {
                switch (Type)
                {
                    case MapTileType.EmptyTile:
                        //d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        break;
                    case MapTileType.TowerHere:
                        d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        break;
                    default:
                        var rect = new RectangleF(ViewX + 0.2f, ViewY + 0.2f, ViewX + TileSize - 0.2f, ViewY + TileSize - 0.2f);
                        d2dRenderTarget.FillRectangle(rect, new SharpDX.Direct2D1.SolidColorBrush(d2dRenderTarget,Colors.Red));
                        d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        break;

                }
            }*/
            internal void Draw(GameForm gameForm)
            {
                switch (Type)
                {
                    case MapTileType.EmptyTile:
                        //d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        gameForm.d2dRenderTarget.DrawBitmap(gameForm.MapTiles[0],ScreenSprite, 1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
                        break;
                    case MapTileType.TowerHere:
                        //d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        gameForm.d2dRenderTarget.DrawBitmap(gameForm.MapTiles[0], ScreenSprite, 1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
                        break;
                    default:
                        gameForm.d2dRenderTarget.DrawBitmap(gameForm.MapTiles[1], ScreenSprite, 1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
                        //var rect = new RectangleF(ViewX + 0.2f, ViewY + 0.2f, ViewX + TileSize - 0.2f, ViewY + TileSize - 0.2f);
                        //d2dRenderTarget.FillRectangle(rect, new SharpDX.Direct2D1.SolidColorBrush(d2dRenderTarget, Colors.Red));
                        //d2dRenderTarget.DrawRectangle(ScreenSprite, GameForm.EmptyTileBrush);
                        break;

                }
            }
Beispiel #5
0
 public void Draw(GameForm gf)
 {
     foreach (var x in Map.Map)
     {
         if (Helper.Contains(GameForm.ViewPort, x.ScreenSprite))
             x.Draw(gf);
     }
     foreach (var o in DrawableObjects.ToArray()) // FIX ME should be safer
     {
         if (Helper.Contains(GameForm.ViewPort, o.ScreenSprite))
         o.Draw(gf);
     }
     ParticleMan.Draw(gf.d2dRenderTarget);
     foreach (var o in UIElements)
     {
             o.Draw(gf);
     }
     //
     BuildMenu.Draw(gf);
     if (ShowUpgradeMenu)
         UpgradeMenu.Draw(gf);
     gf.d2dRenderTarget.DrawText("Score: " + Player.Score + " Gold: " + Player.Gold + " Lives Left: " + Player.Lives + " Wave #" + Wave + "MobsLeft: " + MobsRemaining, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 15.0f), new RectangleF(gf.Width / 2 - 100, 0, gf.Width, 225), GameForm.solidColorBrush);
 }
Beispiel #6
0
 public override void Draw(GameForm gf)
 {
     if (_hits > 1) // HPRect Size will be wrong it HP = 0.
     {
         GameForm.solidColorBrush.Color = SharpDX.Colors.Black;
         gf.d2dRenderTarget.DrawRectangle(HPoutline, GameForm.solidColorBrush);
         GameForm.solidColorBrush.Color = SharpDX.Colors.Green;
         gf.d2dRenderTarget.FillRectangle(HPRect, GameForm.solidColorBrush);
     }
     gf.MonsterModels[TextureIndex].SetVisibleFrame(framenum);
     gf.d2dRenderTarget.DrawBitmap(gf.MonsterModels[TextureIndex].Texture, this.ScreenSprite, 1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear, gf.MonsterModels[TextureIndex].DrawRegion);
     //base.Draw(gf);
 }
Beispiel #7
0
 internal static void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[50], Location, 1f, BitmapInterpolationMode.Linear);
     foreach (var b in Buttons)
         b.Draw(gf);
     gf.d2dRenderTarget.DrawText("Level" + Tower.Level, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(Location.Left + 15, Location.Top + 25, Location.Left + 100, Location.Top + 70), GameForm.solidColorBrush);
     gf.d2dRenderTarget.DrawText("LvlUpCost" + UpgradeMenu.Tower.UpgradeCost, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(Location.Left + 15, Location.Top + 40, Location.Left + 100, Location.Top + 70), GameForm.solidColorBrush);
     gf.d2dRenderTarget.DrawText("Dmg:" + Tower._damage + "Rng" + Tower._range, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(Location.Left + 15, Location.Top + 55, Location.Left + 100, Location.Top + 70), GameForm.solidColorBrush);
 }
Beispiel #8
0
        /// <summary>
        /// Called By a new Thread
        /// </summary>
        internal void Start(object gf)
        {
            Gameform = (GameForm)gf;
            GameState = Tower_Defense.GameState.MainMenu;
            Gameform.MouseClick += Gameform_MouseClick;
            Gameform.KeyUp += Gameform_KeyUp;
            Gameform.KeyDown += Gameform_KeyDown;

            //Menu = new MainMenu();
            Update();
        }
Beispiel #9
0
 internal override void Draw(GameForm gf)
 {
     foreach (var b in Buttons)
         b.Draw(gf);
 }
Beispiel #10
0
 internal abstract void Draw(GameForm gf);
Beispiel #11
0
 internal override void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[51], new RectangleF(0, 0, gf.Width, gf.Height), 1f, BitmapInterpolationMode.Linear);
     foreach (var b in Buttons)
         b.Draw(gf);
 }
Beispiel #12
0
 internal override void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[51], 1f, BitmapInterpolationMode.Linear);
     foreach (var b in Buttons)
         b.Draw(gf);
 }
Beispiel #13
0
        public virtual void Draw(GameForm gf)
        {
            //GameForm.solidColorBrush.Color = Colors.Blue;
            //gf.d2dRenderTarget.DrawRectangle(button, GameForm.solidColorBrush);
            if (ScreenX == 0)
            {
                ScreenX = (gf.Width / 2) - 150;
                ScreenY = (int)(gf.Height / 1.5) - (ScreenY * 80);
                this.button = new RectangleF(ScreenX, ScreenY, ScreenX + 320, ScreenY + 80);

            }
            gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[50], this.button, 1f, BitmapInterpolationMode.Linear);
            GameForm.solidColorBrush.Color = Colors.Red;
            gf.d2dRenderTarget.DrawText(Text, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", fontsize), textbox, GameForm.solidColorBrush);
        }
Beispiel #14
0
        public void initMenu(int x,int y,GameForm gf)
        {
            var height = (int)((gf.Height - 75) / 5);
            var width = (int)(gf.Width - (gf.Width / 1.3));

            X = x; Y = y;
            Buttons[0] = new TowerBuildButton(typeof(Towers.BasicTower),TowerStats.Basic.Name,TowerStats.Basic.Price,TowerStats.Basic.BaseDamage,TowerStats.Basic.BaseFireRateMS,X, Y,width,height);
            Buttons[1] = new TowerBuildButton(typeof(Towers.CannonTower), TowerStats.Cannon.Name, TowerStats.Cannon.Price, TowerStats.Cannon.BaseDamage, TowerStats.Cannon.BaseFireRateMS, X, Y + height, width, height);
            Buttons[2] = new TowerBuildButton(typeof(Towers.SlowingTower), TowerStats.Slow.Name, TowerStats.Slow.Price, TowerStats.Slow.BaseDamage, TowerStats.Slow.BaseFireRateMS, X, Y + height * 2, width, height);
            Buttons[3] = new TowerBuildButton(typeof(Towers.LightTower), TowerStats.Light.Name, TowerStats.Light.Price, TowerStats.Light.BaseDamage, TowerStats.Light.BaseFireRateMS, X, Y + height * 3, width, height);
        }
Beispiel #15
0
 public override void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[50], this.button, 1f, BitmapInterpolationMode.Linear);
     GameForm.solidColorBrush.Color = Colors.Red;
     gf.d2dRenderTarget.DrawText(name, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 15.0f), new RectangleF(this.button.Left + 15, this.button.Top + 10, this.button.Left + 100, this.button.Top + 20), GameForm.solidColorBrush);
     gf.d2dRenderTarget.DrawText("$" + cost, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(this.button.Left + 15, this.button.Top + 50, this.button.Left + 100, this.button.Top + 70), GameForm.solidColorBrush);
     gf.d2dRenderTarget.DrawText("Damage: " + dmg, new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(this.button.Left + 15 + 75, this.button.Top + 50, this.button.Left + 200, this.button.Top + 70), GameForm.solidColorBrush);
     gf.d2dRenderTarget.DrawText("FireRate: " + firerate + "ms", new SharpDX.DirectWrite.TextFormat(gf.fontFactory, "Arial", 10.0f), new RectangleF(this.button.Left + 15, this.button.Top + 80, this.button.Left + 100, this.button.Top + 100), GameForm.solidColorBrush);
 }
Beispiel #16
0
 public virtual void Draw(GameForm gf)
 {
     gf.d2dRenderTarget.DrawBitmap(gf.MapTiles[TextureIndex], ScreenSprite, 1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
 }
Beispiel #17
0
        internal void Draw(GameForm gameForm)
        {
            switch (GameState)
            {
                case GameState.InGame:
                    if(World != null)
                        World.Draw(gameForm); // Draw static map/UI
                    break;
                /*case GameState.MainMenu:
                    Menu.Draw(gameForm);
                    //MainMenu.Draw(this);
                    break;
                case GameState.About:
                    Menu.Draw(gameForm);
                    break;
                case GameState.LevelSelect:
                    Menu.Draw(gameForm);
                    break;
                case GameState.EndGame:
                    Menu.Draw(gameForm);
                    break;
                case GameState.InGamePause:
                    World.Draw(gameForm); // Draw static map/UI
                    Menu.Draw(gameForm);
                    break;*/

            }
            if (Menu != null)
                Menu.Draw(gameForm);
        }