From be5b073f315ec482648881651ff8dc0b0daeeec9 Mon Sep 17 00:00:00 2001 From: Simon Holmberg Date: Wed, 31 Oct 2012 19:22:28 +0100 Subject: [PATCH] AP on UI, and bub is moving! --- .../DepthsBelow/Component/SpriteRenderer.cs | 12 +++---- DepthsBelow/DepthsBelow/Core.cs | 6 ++-- DepthsBelow/DepthsBelow/Interface.cs | 35 +++++++++++++++++-- DepthsBelow/DepthsBelow/Map.cs | 4 +-- DepthsBelow/DepthsBelow/SmallEnemy.cs | 11 +++--- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs b/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs index 7611f31..9562a19 100755 --- a/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs +++ b/DepthsBelow/DepthsBelow/Component/SpriteRenderer.cs @@ -26,6 +26,9 @@ namespace DepthsBelow.Component /// Scale of the texture. /// public float Scale; + + public Vector2 Offset; + public SpriteEffects SpriteEffects; public SpriteRenderer(Entity parent) @@ -39,14 +42,7 @@ namespace DepthsBelow.Component public void Draw(SpriteBatch spriteBatch) { var transform = this.Parent.GetComponent(); - if (AlternativeTexture == null) - { - spriteBatch.Draw(Texture, transform.World.Position + transform.World.Origin, null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0); - } - else - { - spriteBatch.Draw(AlternativeTexture, transform.World.Position + transform.World.Origin - new Vector2(Grid.TileSize, Grid.TileSize), null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0); - } + spriteBatch.Draw(Texture, transform.World.Position + transform.World.Origin + Offset, null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0); } } } diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 64c23f5..0d796de 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -123,7 +123,7 @@ namespace DepthsBelow // TODO: use this.Content to load your game content here Soldier.LoadContent(); - SmallEnemy.LoadContent(); + //SmallEnemy.LoadContent(); //Shot.LoadContent(); MouseInput = new MouseInput(this); @@ -222,14 +222,14 @@ namespace DepthsBelow } } -/*#if DEBUG +#if DEBUG var debugTexture = new Texture2D(GraphicsDevice, 1, 1); debugTexture.SetData(new Color[] { Color.White }); foreach (var collisionComponent in EntityManager.GetComponents()) { spriteBatch.Draw(debugTexture, collisionComponent.Rectangle, Color.Red * 0.5f); } -#endif*/ +#endif // Draw mouse input visuals MouseInput.Draw(spriteBatch); diff --git a/DepthsBelow/DepthsBelow/Interface.cs b/DepthsBelow/DepthsBelow/Interface.cs index db5f064..f857360 100755 --- a/DepthsBelow/DepthsBelow/Interface.cs +++ b/DepthsBelow/DepthsBelow/Interface.cs @@ -406,7 +406,7 @@ namespace DepthsBelow frame.SetTexture("images/GUI/unit_background"); frame.Color = Color.Black; frame.Width = 164; - frame.Height = 35; + frame.Height = 42; var nameText = new GUI.Text(frame); nameText.SetFont("fonts/UnitName"); @@ -432,6 +432,33 @@ namespace DepthsBelow healthBar.Y = 1; frame["healthBar"] = healthBar; + var actionBarBg = new GUI.Frame(frame); + actionBarBg.SetTexture("images/GUI/health_background"); + actionBarBg.Width = 136; + actionBarBg.Height = 8; + actionBarBg.X = 3; + actionBarBg.Y = 31; + frame["actionBarBg"] = actionBarBg; + + var actionBar = new GUI.Frame(actionBarBg); + actionBar.SetTexture("images/GUI/bar_solid"); + actionBar.Color = Color.Orange; + actionBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); + actionBar.Height = 6; + actionBar.X = 1; + actionBar.Y = 1; + frame["actionBar"] = actionBar; + + for (int i = 1; i < 10; i++) + { + var line = new GUI.Frame(actionBar); + line.Texture = Utility.GetSolidTexture(); + line.Color = Color.Black; + line.Height = 6; + line.Width = 1; + line.X = (int)(i * ((float)actionBarBg.Width/10f)) - 1; + } + return frame; } @@ -532,7 +559,7 @@ namespace DepthsBelow var pFrameBar = (GUI.Frame)pFrame["panicBar"]; var pFrameText = (GUI.Text)pFrame["text"]; pFrameBar.Width = (int)(pFrameBarBg.Width * (group.Panic / group.MaxPanic)); - pFrameText.Value = group.Panic.ToString() + " (" + (group.Panic / group.MaxPanic * 100f).ToString() + "%)"; + pFrameText.Value = Math.Round(group.Panic).ToString() + " (" + Math.Round(group.Panic / group.MaxPanic * 100f).ToString() + "%)"; pFrame.Visible = true; if (lastFrame != null) @@ -553,6 +580,10 @@ namespace DepthsBelow var healthBar = (GUI.Frame)frame["healthBar"]; healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().Life / soldier.GetComponent().MaxHP)); + // Update Action Points + var actionBarBg = (GUI.Frame)frame["actionBarBg"]; + var actionBar = (GUI.Frame)frame["actionBar"]; + actionBar.Width = (int)(((float)actionBarBg.Width - 2f) * ((float)soldier.AP / (float)soldier.MaxActionPoints)); lastFrame = frame; } } diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs index 6e844e5..e4e6bbf 100755 --- a/DepthsBelow/DepthsBelow/Map.cs +++ b/DepthsBelow/DepthsBelow/Map.cs @@ -106,14 +106,14 @@ namespace DepthsBelow enemy.X = mapObjectGridPos.X; enemy.Y = mapObjectGridPos.Y; } - /*if (mapObject.Type == "BossSpawn") + if (mapObject.Type == "BossSpawn") { var enemy = new MonsterSpawn("BUB", 12, 0, ref core.Swarm); var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize); var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos); enemy.X = mapObjectGridPos.X; enemy.Y = mapObjectGridPos.Y; - }*/ + } if (mapObject.Type == "Door") { var door = new Door(); diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs index 145ba0b..be78a79 100755 --- a/DepthsBelow/DepthsBelow/SmallEnemy.cs +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -10,7 +10,7 @@ namespace DepthsBelow { public class SmallEnemy : Entity { - public static Texture2D Texture; + public Texture2D Texture; public Color Color; public static Point Origin; private bool _selected; //I guess as in "currently doing something" @@ -81,14 +81,17 @@ namespace DepthsBelow } } - public static void LoadContent() + public void LoadContent() { Texture = GameServices.GetService().Load("images/Monster"); } public void LoadBoss() - { - GetComponent().AlternativeTexture = GameServices.GetService().Load("images/Pineapple"); + { + Texture = GameServices.GetService().Load("images/Pineapple"); + GetComponent().Texture = Texture; + Transform.World.Origin = new Vector2(((float)Texture.Width) / 2f, ((float)Texture.Height) / 2f); + GetComponent().Offset = (new Vector2(Texture.Width / 2f, Texture.Height / 2f) - new Vector2(Grid.TileSize / 2, Grid.TileSize / 2)) * -1; var stat = new Component.Stat(this) { Life = 500,