Exemplo n.º 1
0
        public override void Initialize()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            lines = new List <string>();

            boxLine        = new PrimitiveLine(Game.GraphicsDevice, 1);
            boxLine.Colour = Color.Black;
            boxVectors     = new Vector2[4];

            base.Initialize();
        }
Exemplo n.º 2
0
        public override void Initialize()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);

            lines = new List<string>();

            boxLine = new PrimitiveLine(Game.GraphicsDevice, 1);
            boxLine.Colour = Color.Black;
            boxVectors = new Vector2[4];

            base.Initialize();
        }
Exemplo n.º 3
0
 public static void InitializeSelectBoxLine(GraphicsDevice graphicsDevice, Color color)
 {
     selectBoxLine        = new PrimitiveLine(graphicsDevice, 1);
     selectBoxLine.Colour = color;
 }
Exemplo n.º 4
0
        public Rts(EventHandler callback, Lidgren.Network.NetPeer netpeer, short myTeam)
            : base(callback)
        {
            netPeer   = netpeer;
            iAmServer = netPeer is NetServer;

            Game1.Game.DebugMonitor.Position = Direction.NorthEast;
            //Game1.Game.Graphics.SynchronizeWithVerticalRetrace = false;
            //Game1.Game.IsFixedTimeStep = false;
            //Game1.Game.Graphics.ApplyChanges();
            //GameTimer.Restart();

            //map = new Map(@"Content/map1.muh");
            map        = new Map("C:\\rts maps\\map2.muh");
            pathFinder = new PathFinder(map);
            map.InstantiateMapResources();
            //Player.Me.Team = myTeam;
            Player.Me = Player.Players[myTeam];

            actualMapWidth  = map.Width * map.TileSize;
            actualMapHeight = map.Height * map.TileSize;

            Unit.UnitCollisionSweeper.Thread.Suspend();
            Unit.UnitCollisionSweeper.Thread.Resume();
            Rts.pathFinder.ResumeThread();

            uiViewport      = GraphicsDevice.Viewport;
            worldViewport   = GraphicsDevice.Viewport;
            minimapViewport = new Viewport(minimapBorderSize, uiViewport.Height - minimapSize - minimapBorderSize, minimapSize, minimapSize);
            //minimapViewport = new Viewport(0, 0, minimapSize, minimapSize);
            worldViewport.Height   -= (minimapSize + minimapBorderSize * 2);
            GraphicsDevice.Viewport = worldViewport;

            camera     = new Camera();
            camera.Pos = new Vector2(worldViewport.Width / 2, worldViewport.Height / 2);

            button1 = new BaseObject(new Rectangle(10, 25, 25, 25));
            button2 = new BaseObject(new Rectangle(10, 52, 25, 25));
            button3 = new BaseObject(new Rectangle(10, 79, 25, 25));
            button4 = new BaseObject(new Rectangle(10, 106, 25, 25));
            button5 = new BaseObject(new Rectangle(10, 133, 25, 25));

            if (!contentLoaded)
            {
                pauseFont             = Content.Load <SpriteFont>("spritefonts/pausefont");
                fpsFont               = Content.Load <SpriteFont>("spritefonts/fpsfont");
                unitInfoUnitNameFont  = Content.Load <SpriteFont>("spritefonts/UnitInfoUnitNameFont");
                unitInfoHpFont        = Content.Load <SpriteFont>("spritefonts/UnitInfoHpFont");
                unitInfoKillCountFont = Content.Load <SpriteFont>("spritefonts/UnitInfoKillCountFont");
                resourceCountFont     = Content.Load <SpriteFont>("spritefonts/ResourceCountFont");
                bigFont               = Content.Load <SpriteFont>("spritefonts/BigMessage");
                //brownGuyTexture = Content.Load<Texture2D>("unit textures/browncircleguy");
                //brownGuySelectingTexture = Content.Load<Texture2D>("unit textures/browncircleguyselected2");
                //brownGuySelectedTexture = Content.Load<Texture2D>("unit textures/browncircleguyselecting2");
                greenTeamIndicatorTexture        = Content.Load <Texture2D>("unit textures/green team indicator");
                redTeamIndicatorTexture          = Content.Load <Texture2D>("unit textures/red team indicator");
                buttonTexture                    = Content.Load <Texture2D>("titlebutton1");
                moveCommandShrinkerTexture       = Content.Load <Texture2D>("greencircle2");
                attackMoveCommandShrinkerTexture = Content.Load <Texture2D>("redcircle2");
                //normalCursorTexture = Content.Load<Texture2D>("greencursor2");
                //attackCommandCursorTexture = Content.Load<Texture2D>("crosshair");
                normalCursor            = Util.LoadCustomCursor(@"Content/cursors/SC2-cursor.cur");
                attackCursor            = Util.LoadCustomCursor(@"Content/cursors/SC2-target-none.cur");
                boulder1Texture         = Content.Load <Texture2D>("boulder1");
                tree1Texture            = Content.Load <Texture2D>("tree2");
                rallyFlagTexture        = Content.Load <Texture2D>("redflag");
                redCircleTexture        = Content.Load <Texture2D>("redcircle");
                transparentTexture      = Content.Load <Texture2D>("transparent");
                transparentGrayTexture  = Content.Load <Texture2D>("transparentgray");
                transparentBlackTexture = Content.Load <Texture2D>("transparentblack");
                whiteBoxTexture         = Content.Load <Texture2D>("whitebox");
                cogWheelTexture         = Content.Load <Texture2D>("cogwheel");
                rtsMusic         = Content.Load <Song>("music/58 - Weapons Factory");
                errorSoundEffect = Content.Load <SoundEffect>("sounds/Error");
                //Unit.BulletTexture = Content.Load<Texture2D>("bullet");
                Unit.Explosion1Textures      = Util.SplitTexture(Content.Load <Texture2D>("explosionsheet1"), 45, 45);
                Structure.Explosion1Textures = Util.SplitTexture(Content.Load <Texture2D>("explosionsheet1"), 45, 45);
                contentLoaded = true;
            }

            winForm = (Form)Form.FromHandle(Game1.Game.Window.Handle);
            //Cursor.Clip = new System.Drawing.Rectangle(winForm.Location, winForm.Size);
            winForm.Cursor = normalCursor;

            initializeMapTexture();
            initializeCommandCardArea();
            initializeSelectionInfoArea();
            line.Alpha = .75f;

            VisionUpdater = new VisionUpdater(map, Rts.pathFinder, Player.Me.Team);

            SelectBox.InitializeSelectBoxLine(GraphicsDevice, Color.Green);
            Initializeline(GraphicsDevice, Color.Yellow);

            minimapScreenIndicatorBoxLine        = new PrimitiveLine(GraphicsDevice, 1);
            minimapScreenIndicatorBoxLine.Colour = Color.White;

            for (int i = 0; i < HotkeyGroups.Length; i++)
            {
                HotkeyGroups[i] = new List <RtsObject>();
            }

            MediaPlayer.Play(rtsMusic);
            MediaPlayer.Volume      = MusicVolume;
            MediaPlayer.IsRepeating = true;

            /*new TownHall(map.StartingPoints[myTeam], myTeam);
             * camera.Pos = new Vector2(map.StartingPoints[myTeam].X * map.TileSize, map.StartingPoints[myTeam].Y * map.TileSize);
             * Player.Me.MaxSupply += StructureType.TownHall.Supply;*/
            initializeStartingPoints();

            //new Barracks(new Point(10, 14), 2);
            //new Roks(new Point(3, 3));
            //new Roks(new Point(3, 30));

            Player.Me.Roks = 25;

            clampCameraToMap();

            initialHandShake();
        }
Exemplo n.º 5
0
 public static void InitializeSelectBoxLine(GraphicsDevice graphicsDevice, Color color)
 {
     selectBoxLine = new PrimitiveLine(graphicsDevice, 1);
     selectBoxLine.Colour = color;
 }
Exemplo n.º 6
0
 public static void Initializeline(GraphicsDevice graphicsDevice, Color color)
 {
     line = new PrimitiveLine(graphicsDevice, 1);
     line.Colour = color;
 }
Exemplo n.º 7
0
Arquivo: Rts.cs Projeto: nubington/rts
        public Rts(EventHandler callback, Lidgren.Network.NetPeer netpeer, short myTeam)
            : base(callback)
        {
            netPeer = netpeer;
            iAmServer = netPeer is NetServer;

            Game1.Game.DebugMonitor.Position = Direction.NorthEast;
            //Game1.Game.Graphics.SynchronizeWithVerticalRetrace = false;
            //Game1.Game.IsFixedTimeStep = false;
            //Game1.Game.Graphics.ApplyChanges();
            //GameTimer.Restart();

            //map = new Map(@"Content/map1.muh");
            map = new Map("C:\\rts maps\\map2.muh");
            pathFinder = new PathFinder(map);
            map.InstantiateMapResources();
            //Player.Me.Team = myTeam;
            Player.Me = Player.Players[myTeam];

            actualMapWidth = map.Width * map.TileSize;
            actualMapHeight = map.Height * map.TileSize;

            Unit.UnitCollisionSweeper.Thread.Suspend();
            Unit.UnitCollisionSweeper.Thread.Resume();
            Rts.pathFinder.ResumeThread();

            uiViewport = GraphicsDevice.Viewport;
            worldViewport = GraphicsDevice.Viewport;
            minimapViewport = new Viewport(minimapBorderSize, uiViewport.Height - minimapSize - minimapBorderSize, minimapSize, minimapSize);
            //minimapViewport = new Viewport(0, 0, minimapSize, minimapSize);
            worldViewport.Height -= (minimapSize + minimapBorderSize * 2);
            GraphicsDevice.Viewport = worldViewport;

            camera = new Camera();
            camera.Pos = new Vector2(worldViewport.Width / 2, worldViewport.Height / 2);

            button1 = new BaseObject(new Rectangle(10, 25, 25, 25));
            button2 = new BaseObject(new Rectangle(10, 52, 25, 25));
            button3 = new BaseObject(new Rectangle(10, 79, 25, 25));
            button4 = new BaseObject(new Rectangle(10, 106, 25, 25));
            button5 = new BaseObject(new Rectangle(10, 133, 25, 25));

            if (!contentLoaded)
            {
                pauseFont = Content.Load<SpriteFont>("spritefonts/pausefont");
                fpsFont = Content.Load<SpriteFont>("spritefonts/fpsfont");
                unitInfoUnitNameFont = Content.Load<SpriteFont>("spritefonts/UnitInfoUnitNameFont");
                unitInfoHpFont = Content.Load<SpriteFont>("spritefonts/UnitInfoHpFont");
                unitInfoKillCountFont = Content.Load<SpriteFont>("spritefonts/UnitInfoKillCountFont");
                resourceCountFont = Content.Load<SpriteFont>("spritefonts/ResourceCountFont");
                bigFont = Content.Load<SpriteFont>("spritefonts/BigMessage");
                //brownGuyTexture = Content.Load<Texture2D>("unit textures/browncircleguy");
                //brownGuySelectingTexture = Content.Load<Texture2D>("unit textures/browncircleguyselected2");
                //brownGuySelectedTexture = Content.Load<Texture2D>("unit textures/browncircleguyselecting2");
                greenTeamIndicatorTexture = Content.Load<Texture2D>("unit textures/green team indicator");
                redTeamIndicatorTexture = Content.Load<Texture2D>("unit textures/red team indicator");
                buttonTexture = Content.Load<Texture2D>("titlebutton1");
                moveCommandShrinkerTexture = Content.Load<Texture2D>("greencircle2");
                attackMoveCommandShrinkerTexture = Content.Load<Texture2D>("redcircle2");
                //normalCursorTexture = Content.Load<Texture2D>("greencursor2");
                //attackCommandCursorTexture = Content.Load<Texture2D>("crosshair");
                normalCursor = Util.LoadCustomCursor(@"Content/cursors/SC2-cursor.cur");
                attackCursor = Util.LoadCustomCursor(@"Content/cursors/SC2-target-none.cur");
                boulder1Texture = Content.Load<Texture2D>("boulder1");
                tree1Texture = Content.Load<Texture2D>("tree2");
                rallyFlagTexture = Content.Load<Texture2D>("redflag");
                redCircleTexture = Content.Load<Texture2D>("redcircle");
                transparentTexture = Content.Load<Texture2D>("transparent");
                transparentGrayTexture = Content.Load<Texture2D>("transparentgray");
                transparentBlackTexture = Content.Load<Texture2D>("transparentblack");
                whiteBoxTexture = Content.Load<Texture2D>("whitebox");
                cogWheelTexture = Content.Load<Texture2D>("cogwheel");
                rtsMusic = Content.Load<Song>("music/58 - Weapons Factory");
                errorSoundEffect = Content.Load<SoundEffect>("sounds/Error");
                //Unit.BulletTexture = Content.Load<Texture2D>("bullet");
                Unit.Explosion1Textures = Util.SplitTexture(Content.Load<Texture2D>("explosionsheet1"), 45, 45);
                Structure.Explosion1Textures = Util.SplitTexture(Content.Load<Texture2D>("explosionsheet1"), 45, 45);
                contentLoaded = true;
            }

            winForm = (Form)Form.FromHandle(Game1.Game.Window.Handle);
            //Cursor.Clip = new System.Drawing.Rectangle(winForm.Location, winForm.Size);
            winForm.Cursor = normalCursor;

            initializeMapTexture();
            initializeCommandCardArea();
            initializeSelectionInfoArea();
            line.Alpha = .75f;

            VisionUpdater = new VisionUpdater(map, Rts.pathFinder, Player.Me.Team);

            SelectBox.InitializeSelectBoxLine(GraphicsDevice, Color.Green);
            Initializeline(GraphicsDevice, Color.Yellow);

            minimapScreenIndicatorBoxLine = new PrimitiveLine(GraphicsDevice, 1);
            minimapScreenIndicatorBoxLine.Colour = Color.White;

            for (int i = 0; i < HotkeyGroups.Length; i++)
                HotkeyGroups[i] = new List<RtsObject>();

            MediaPlayer.Play(rtsMusic);
            MediaPlayer.Volume = MusicVolume;
            MediaPlayer.IsRepeating = true;

            /*new TownHall(map.StartingPoints[myTeam], myTeam);
            camera.Pos = new Vector2(map.StartingPoints[myTeam].X * map.TileSize, map.StartingPoints[myTeam].Y * map.TileSize);
            Player.Me.MaxSupply += StructureType.TownHall.Supply;*/
            initializeStartingPoints();

            //new Barracks(new Point(10, 14), 2);
            //new Roks(new Point(3, 3));
            //new Roks(new Point(3, 30));

            Player.Me.Roks = 25;

            clampCameraToMap();

            initialHandShake();
        }
Exemplo n.º 8
0
Arquivo: Rts.cs Projeto: nubington/rts
        public override void Draw(SpriteBatch spriteBatch)
        {
            Game1.Game.DebugMonitor.AddLine("camera position: " + camera.Pos);
            Game1.Game.DebugMonitor.AddLine("camera zoom: " + camera.Zoom);
            Game1.Game.DebugMonitor.AddLine("camera rotation: " + camera.Rotation);
            Game1.Game.DebugMonitor.AddLine("pathfinding usage: " + pathFindingPercentage.ToString("F1") + "%");
            Game1.Game.DebugMonitor.AddLine("pathfinding queue: " + pathFindQueueSize);
            Game1.Game.DebugMonitor.AddLine("time: " + GameTimer.Elapsed.Minutes + ":" + GameTimer.Elapsed.Seconds.ToString("D2"));

            GraphicsDevice.Clear(Color.Black);

            GraphicsDevice.Viewport = worldViewport;
            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.get_transformation(worldViewport));

            drawMap(spriteBatch);

            // units
            foreach (Unit unit in SelectingUnits)
                //drawSelectionRing(unit, spriteBatch, Color.Green);
                drawSelectingRing(unit, spriteBatch);
            foreach (Unit unit in SelectedUnits)
                //drawSelectionRing(unit, spriteBatch, Color.Khaki);
                drawSelectedRing(unit, spriteBatch);

            foreach (Unit unit in Unit.Units)
            {
                if (!SelectingUnits.Contains(unit) && !SelectedUnits.Contains(unit))
                    spriteBatch.Draw(unit.Texture, new Rectangle((int)unit.CenterPoint.X, (int)unit.CenterPoint.Y, unit.Width, unit.Height), null, Color.White, unit.Rotation, unit.TextureCenterOrigin, SpriteEffects.None, 0f);

                /*int teamIndicatorSize = (int)(unit.Diameter / 4);
                // Rectangle teamIndicator = new Rectangle((int)(unit.CenterPoint.X - teamIndicatorSize / 2), (int)(unit.CenterPoint.Y - teamIndicatorSize / 2), teamIndicatorSize, teamIndicatorSize);
                Rectangle teamIndicator = new Rectangle((int)unit.CenterPoint.X, (int)unit.CenterPoint.Y, teamIndicatorSize, teamIndicatorSize);

                if (unit.Team == myTeam)
                    spriteBatch.Draw(ColorTexture.Green, teamIndicator, null, Color.White, unit.Rotation, ColorTexture.CenterVector, SpriteEffects.None, 0f);
                else
                    spriteBatch.Draw(ColorTexture.Red, teamIndicator, null, Color.White, unit.Rotation, ColorTexture.CenterVector, SpriteEffects.None, 0f);*/

                if (unit.Team == myTeam)
                    spriteBatch.Draw(greenTeamIndicatorTexture, new Rectangle((int)unit.CenterPoint.X, (int)unit.CenterPoint.Y, unit.Width, unit.Height), null, Color.White, unit.Rotation, new Vector2(greenTeamIndicatorTexture.Width / 2, greenTeamIndicatorTexture.Height / 2), SpriteEffects.None, 0f);
                else
                    spriteBatch.Draw(redTeamIndicatorTexture, new Rectangle((int)unit.CenterPoint.X, (int)unit.CenterPoint.Y, unit.Width, unit.Height), null, Color.White, unit.Rotation, new Vector2(redTeamIndicatorTexture.Width / 2, redTeamIndicatorTexture.Height / 2), SpriteEffects.None, 0f);
            }

            // unit animations
            foreach (UnitAnimation a in UnitAnimation.UnitAnimations)
                spriteBatch.Draw(a, new Rectangle(a.Rectangle.Center.X, a.Rectangle.Center.Y, a.Rectangle.Width, a.Rectangle.Height), null, Color.White, a.Rotation, new Vector2(((Texture2D)a).Width / 2, ((Texture2D)a).Height / 2), SpriteEffects.None, 0f);

            foreach (Unit unit in SelectedUnits)
            {
                if (unit.IsMoving)
                {
                    selectionRingLine.ClearVectors();
                    selectionRingLine.AddVector(unit.CenterPoint);
                    //foreach (Vector2 v in unit.WayPoints)
                    //    selectionRingLine.AddVector(v);
                    foreach (MoveCommand command in unit.Commands)
                    {
                        if (command is AttackCommand)
                            selectionRingLine.Colour = Color.Red;
                        else
                            selectionRingLine.Colour = Color.Green;

                        foreach (Vector2 v in command.WayPoints)
                            selectionRingLine.AddVector(v);

                        selectionRingLine.Render(spriteBatch);
                        selectionRingLine.ClearVectors();
                        selectionRingLine.AddVector(command.Destination);
                    }
                }
            }

            PrimitiveLine line = new PrimitiveLine(GraphicsDevice, 1);
            line.Colour = Color.Black;

            if (SelectedUnits.Count == 1 && SelectedUnits[0] is Unit)
            {
                Unit unit = SelectedUnits[0] as Unit;

                //PrimitiveLine line = new PrimitiveLine(GraphicsDevice, 1);
                //line.Colour = Color.Black;
                lock (SelectedUnits[0].PotentialCollisions)
                {
                    foreach (Unit u in SelectedUnits[0].PotentialCollisions)
                    {
                        line.ClearVectors();
                        line.AddVector(SelectedUnits[0].CenterPoint);
                        line.AddVector(u.CenterPoint);
                        line.Render(spriteBatch);
                    }
                }
                line.Colour = Color.Red;
                line.ClearVectors();
                line.AddVector(new Vector2(unit.CurrentPathNode.Tile.X, unit.CurrentPathNode.Tile.Y));
                line.AddVector(new Vector2(unit.CurrentPathNode.Tile.X + unit.CurrentPathNode.Tile.Width, unit.CurrentPathNode.Tile.Y));
                line.AddVector(new Vector2(unit.CurrentPathNode.Tile.X + unit.CurrentPathNode.Tile.Width, unit.CurrentPathNode.Tile.Y + unit.CurrentPathNode.Tile.Height));
                line.AddVector(new Vector2(unit.CurrentPathNode.Tile.X, unit.CurrentPathNode.Tile.Y + unit.CurrentPathNode.Tile.Height));
                line.AddVector(new Vector2(unit.CurrentPathNode.Tile.X, unit.CurrentPathNode.Tile.Y));
                line.Render(spriteBatch);
                line.Colour = Color.Black;
                foreach (MapTile tile in unit.CurrentPathNode.Tile.Neighbors)
                {
                    line.ClearVectors();
                    line.AddVector(new Vector2(tile.X, tile.Y));
                    line.AddVector(new Vector2(tile.X + tile.Width, tile.Y));
                    line.AddVector(new Vector2(tile.X + tile.Width, tile.Y + tile.Height));
                    line.AddVector(new Vector2(tile.X, tile.Y + tile.Height));
                    line.AddVector(new Vector2(tile.X, tile.Y));
                    line.Render(spriteBatch);
                }
            }

            /*foreach (Unit unit in SelectedUnits)
            {
                lock (unit.PotentialCollisions)
                {
                    foreach (Unit u in unit.PotentialCollisions)
                    {
                        line.ClearVectors();
                        line.AddVector(unit.CenterPoint);
                        line.AddVector(u.CenterPoint);
                        line.Render(spriteBatch);
                    }
                }
            }*/

            // bullets
            foreach (RtsBullet b in RtsBullet.RtsBullets)
                //spriteBatch.Draw(b.Texture, b, Color.White);
                spriteBatch.Draw(b.Texture, new Rectangle((int)b.CenterPoint.X, (int)b.CenterPoint.Y, b.Width, b.Height), null, Color.White, b.Rotation, b.TextureCenterOrigin, SpriteEffects.None, 0f);

            // move command shrinker things
            foreach (Shrinker shrinker in Shrinker.Shrinkers)
                spriteBatch.Draw(shrinker.Texture, shrinker, Color.White);
            //spriteBatch.Draw(shrinker.Texture, new Rectangle((int)shrinker.CenterPoint.X, (int)shrinker.CenterPoint.Y, shrinker.Width, shrinker.Height), null, Color.White, shrinker.Rotation, shrinker.TextureCenterOrigin, SpriteEffects.None, 0f);

            spriteBatch.End();
            spriteBatch.Begin();

            GraphicsDevice.Viewport = uiViewport;

            SelectBox.Draw(spriteBatch, camera);

            drawMinimap(spriteBatch);
            drawSelectionInfoArea(spriteBatch);
            drawCommandCardArea(spriteBatch);
            drawCommandCardBorder(spriteBatch);

            //pause and fps count
            Vector2 pauseStringSize = pauseFont.MeasureString("PAUSED");
            if (paused)
                spriteBatch.DrawString(pauseFont, "PAUSED", new Vector2(uiViewport.Width / 2 - pauseStringSize.X / 2, uiViewport.Height / 2 - pauseStringSize.Y / 2), Color.White);
            else
                frameCounter++;

            // fps message
            spriteBatch.DrawString(fpsFont, fpsMessage, new Vector2(8, 5), Color.Black);

            spriteBatch.Draw(buttonTexture, button1, Color.White);
            Vector2 button1TextSize = fpsFont.MeasureString("1");
            spriteBatch.DrawString(fpsFont, "1", new Vector2((int)(button1.X + button1.Width / 2 - button1TextSize.X / 2), (int)(button1.Y + button1.Height / 2 - button1TextSize.Y / 2)), Color.White);
            spriteBatch.Draw(buttonTexture, button2, Color.White);
            Vector2 button2TextSize = fpsFont.MeasureString("10");
            spriteBatch.DrawString(fpsFont, "10", new Vector2((int)(button2.X + button2.Width / 2 - button2TextSize.X / 2), (int)(button2.Y + button2.Height / 2 - button2TextSize.Y / 2)), Color.White);
            spriteBatch.Draw(buttonTexture, button3, Color.White);
            Vector2 button3TextSize = fpsFont.MeasureString("FS");
            spriteBatch.DrawString(fpsFont, "FS", new Vector2((int)(button3.X + button3.Width / 2 - button3TextSize.X / 2), (int)(button3.Y + button3.Height / 2 - button3TextSize.Y / 2)), Color.White);
            spriteBatch.Draw(buttonTexture, button4, Color.White);
            Vector2 button4TextSize = fpsFont.MeasureString("M");
            spriteBatch.DrawString(fpsFont, "M", new Vector2((int)(button4.X + button4.Width / 2 - button4TextSize.X / 2), (int)(button4.Y + button4.Height / 2 - button4TextSize.Y / 2)), Color.White);
            spriteBatch.Draw(buttonTexture, button5, Color.White);
            Vector2 button5TextSize = fpsFont.MeasureString("X");
            spriteBatch.DrawString(fpsFont, "X", new Vector2((int)(button5.X + button5.Width / 2 - button5TextSize.X / 2), (int)(button5.Y + button5.Height / 2 - button5TextSize.Y / 2)), Color.White);

            // cursor
            /*if (usingAttackCommand)
                spriteBatch.Draw(attackCommandCursorTexture, new Rectangle(mouseState.X - attackCommandCursorSize / 2, mouseState.Y - attackCommandCursorSize / 2, attackCommandCursorSize, attackCommandCursorSize), Color.White);
            else
                spriteBatch.Draw(normalCursorTexture, new Rectangle(mouseState.X, mouseState.Y, attackCommandCursorSize, attackCommandCursorSize), Color.White);*/

            spriteBatch.End();

            // tell pathfinder to stop calculating
            Unit.PathFinder.Go = false;
        }
Exemplo n.º 9
0
Arquivo: Rts.cs Projeto: nubington/rts
        public Rts(EventHandler callback)
            : base(callback)
        {
            Game1.Game.DebugMonitor.Position = Direction.NorthEast;
            Game1.Game.IsMouseVisible = true;
            //Game1.Game.Graphics.SynchronizeWithVerticalRetrace = false;
            //Game1.Game.IsFixedTimeStep = false;
            //Game1.Game.Graphics.ApplyChanges();
            GameTimer.Restart();

            map = new Map(@"Content/map1.txt");
            Unit.Map = map;
            actualMapWidth = map.Width * map.TileSize;
            actualMapHeight = map.Height * map.TileSize;

            Unit.UnitCollisionSweeper.Thread.Suspend();
            Unit.UnitCollisionSweeper.Thread.Resume();
            Unit.PathFinder.ResumeThread();

            uiViewport = GraphicsDevice.Viewport;
            worldViewport = GraphicsDevice.Viewport;
            worldViewport.Height -= (minimapSize + minimapBorderSize * 2);
            GraphicsDevice.Viewport = worldViewport;

            camera = new Camera();
            camera.Pos = new Vector2(worldViewport.Width / 2, worldViewport.Height / 2);

            button1 = new BaseObject(new Rectangle(10, 25, 25, 25));
            button2 = new BaseObject(new Rectangle(10, 52, 25, 25));
            button3 = new BaseObject(new Rectangle(10, 79, 25, 25));
            button4 = new BaseObject(new Rectangle(10, 106, 25, 25));
            button5 = new BaseObject(new Rectangle(10, 133, 25, 25));

            if (!contentLoaded)
            {
                pauseFont = Content.Load<SpriteFont>("spritefonts/pausefont");
                fpsFont = Content.Load<SpriteFont>("spritefonts/fpsfont");
                unitInfoUnitNameFont = Content.Load<SpriteFont>("spritefonts/UnitInfoUnitNameFont");
                unitInfoHpFont = Content.Load<SpriteFont>("spritefonts/UnitInfoHpFont");
                unitInfoKillCountFont = Content.Load<SpriteFont>("spritefonts/UnitInfoKillCountFont");
                //brownGuyTexture = Content.Load<Texture2D>("unit textures/browncircleguy");
                //brownGuySelectingTexture = Content.Load<Texture2D>("unit textures/browncircleguyselected2");
                //brownGuySelectedTexture = Content.Load<Texture2D>("unit textures/browncircleguyselecting2");
                greenTeamIndicatorTexture = Content.Load<Texture2D>("unit textures/green team indicator");
                redTeamIndicatorTexture = Content.Load<Texture2D>("unit textures/red team indicator");
                buttonTexture = Content.Load<Texture2D>("titlebutton1");
                moveCommandTexture = Content.Load<Texture2D>("greencircle2");
                //normalCursorTexture = Content.Load<Texture2D>("greencursor2");
                //attackCommandCursorTexture = Content.Load<Texture2D>("crosshair");
                normalCursor = Util.LoadCustomCursor(@"Content/cursors/SC2-cursor.cur");
                attackCursor = Util.LoadCustomCursor(@"Content/cursors/SC2-target-none.cur");
                boulder1Texture = Content.Load<Texture2D>("boulder1");
                tree1Texture = Content.Load<Texture2D>("tree2");
                redCircleTexture = Content.Load<Texture2D>("redcircle");
                transparentTexture = Content.Load<Texture2D>("transparent");
                transparentGrayTexture = Content.Load<Texture2D>("transparentgray");
                transparentBlackTexture = Content.Load<Texture2D>("transparentblack");
                whiteBoxTexture = Content.Load<Texture2D>("whitebox");
                rtsMusic = Content.Load<Song>("sounds/crossingthosehills");
                //Unit.BulletTexture = Content.Load<Texture2D>("bullet");
                Unit.Explosion1Textures = Util.SplitTexture(Content.Load<Texture2D>("explosionsheet1"), 45, 45);
                contentLoaded = true;
            }

            winForm = (Form)Form.FromHandle(Game1.Game.Window.Handle);
            winForm.Cursor = normalCursor;

            VisionUpdater = new VisionUpdater(map, Unit.PathFinder, myTeam);

            initializeMapTexture();
            initializeCommandCardArea();
            initializeSelectionInfoArea();

            SelectBox.InitializeSelectBoxLine(GraphicsDevice, Color.Green);
            InitializeSelectionRingLine(GraphicsDevice, Color.Yellow);

            minimapScreenIndicatorBoxLine = new PrimitiveLine(GraphicsDevice, 1);
            minimapScreenIndicatorBoxLine.Colour = Color.White;

            for (int i = 0; i < HotkeyGroups.Length; i++)
                HotkeyGroups[i] = new List<RtsObject>();

            MediaPlayer.Play(rtsMusic);
            MediaPlayer.Volume = .25f;
            MediaPlayer.IsRepeating = true;
        }