From 723215294bdb39e812d6a5c0160b6cd794007a69 Mon Sep 17 00:00:00 2001 From: Simon Holmberg Date: Tue, 23 Oct 2012 16:40:19 +0200 Subject: [PATCH] Panic works. Variable brightness. Brighter lights. Updated tileset. --- .../DepthsBelow/Component/Flashlight.cs | 4 +-- DepthsBelow/DepthsBelow/Component/Stat.cs | 4 ++- DepthsBelow/DepthsBelow/Core.cs | 8 +++-- .../DepthsBelow/DynamicGroupManager.cs | 28 ++++++++++++++--- DepthsBelow/DepthsBelow/GUIManager.cs | 4 +++ DepthsBelow/DepthsBelow/Interface.cs | 29 +++++++++++++++--- DepthsBelow/DepthsBelow/KeyboardInput.cs | 10 +++--- DepthsBelow/DepthsBelow/Soldier.cs | 8 +++-- .../DepthsBelowContent.contentproj | 14 +++++++++ .../images/lights/spot_wide.png | Bin 0 -> 19275 bytes .../DepthsBelowContent/images/soldier5.png | Bin 0 -> 4396 bytes .../DepthsBelowContent/maps/Aztek.Test.tmx | 9 +++--- .../maps/tilesets/aztek.png | Bin 42860 -> 41447 bytes 13 files changed, 93 insertions(+), 25 deletions(-) create mode 100644 DepthsBelow/DepthsBelowContent/images/lights/spot_wide.png create mode 100644 DepthsBelow/DepthsBelowContent/images/soldier5.png diff --git a/DepthsBelow/DepthsBelow/Component/Flashlight.cs b/DepthsBelow/DepthsBelow/Component/Flashlight.cs index bddad6e..4b51cc8 100755 --- a/DepthsBelow/DepthsBelow/Component/Flashlight.cs +++ b/DepthsBelow/DepthsBelow/Component/Flashlight.cs @@ -23,9 +23,9 @@ namespace DepthsBelow.Component public Flashlight(Entity parent) : base(parent) { - Texture = GameServices.GetService().Load("images/lights/spot"); + Texture = GameServices.GetService().Load("images/lights/spot_wide"); Color = Color.White; - Origin = new Vector2(50, 60); + Origin = new Vector2(50, Texture.Height / 2f); } public override void Update(GameTime gameTime) diff --git a/DepthsBelow/DepthsBelow/Component/Stat.cs b/DepthsBelow/DepthsBelow/Component/Stat.cs index bfdfb83..d8f35c4 100755 --- a/DepthsBelow/DepthsBelow/Component/Stat.cs +++ b/DepthsBelow/DepthsBelow/Component/Stat.cs @@ -24,7 +24,9 @@ namespace DepthsBelow.Component if (HP == 0) HP = value; } - } + } + + public int MaxPanic = 100; protected int hp = 0; protected int defence = 0; diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 06b1839..85d19d2 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -44,7 +44,9 @@ namespace DepthsBelow public static Map Map; - public SmallEnemy TestMonster; + public SmallEnemy TestMonster; + + public int Brightness = 30; public Core() { @@ -167,7 +169,7 @@ namespace DepthsBelow // Draw to the lighting render target GraphicsDevice.SetRenderTarget(lightRenderTarget); - GraphicsDevice.Clear(new Color(10, 10, 10)); + GraphicsDevice.Clear(new Color(Brightness, Brightness, Brightness)); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, null, null, null, Camera.Transform); @@ -203,7 +205,7 @@ namespace DepthsBelow { var lightData = new Color[1]; lightRenderTarget.GetData(0, sourceRect, lightData, 0, 1); - if (lightData[0] != new Color(10, 10, 10)) + if (lightData[0] != new Color(Brightness, Brightness, Brightness)) spriteRenderer.Draw(spriteBatch); } } diff --git a/DepthsBelow/DepthsBelow/DynamicGroupManager.cs b/DepthsBelow/DepthsBelow/DynamicGroupManager.cs index a81dc6c..e015d93 100755 --- a/DepthsBelow/DepthsBelow/DynamicGroupManager.cs +++ b/DepthsBelow/DepthsBelow/DynamicGroupManager.cs @@ -12,6 +12,20 @@ namespace DepthsBelow { public List Entities; public float Panic; + public float MaxPanic + { + get + { + float maxPanic = 0; + foreach (var entity in Entities) + { + var stats = entity.GetComponent(); + if (stats != null) + maxPanic += stats.MaxPanic; + } + return maxPanic; + } + } } private List entities; @@ -37,21 +51,27 @@ namespace DepthsBelow foreach (var newGroup in newGroups) { - foreach (var entity in newGroup.Entities) + for (int index = 0; index < newGroup.Entities.Count; index++) { + var entity = newGroup.Entities[index]; + Group oldGroup = null; // Find the group the entity belonged to before foreach (var group in Groups) { - if (group.Entities.Contains(entity)) + if (@group.Entities.Contains(entity)) { - oldGroup = group; + oldGroup = @group; break; } } if (oldGroup != null) - newGroup.Panic += oldGroup.Panic / oldGroup.Entities.Count; + { + newGroup.Panic += (oldGroup.Panic / oldGroup.MaxPanic) * (float)entity.GetComponent().MaxPanic; + oldGroup.Panic -= (oldGroup.Panic / oldGroup.MaxPanic) * (float)entity.GetComponent().MaxPanic; + oldGroup.Entities.Remove(entity); + } else newGroup.Panic = 10; } diff --git a/DepthsBelow/DepthsBelow/GUIManager.cs b/DepthsBelow/DepthsBelow/GUIManager.cs index c321edb..80a8591 100755 --- a/DepthsBelow/DepthsBelow/GUIManager.cs +++ b/DepthsBelow/DepthsBelow/GUIManager.cs @@ -103,7 +103,11 @@ namespace DepthsBelow public static void Draw(SpriteBatch spriteBatch) { foreach (var frame in Frames.OrderBy(f => f, new FrameSort())) + { frame.Draw(spriteBatch); + + + } } /// diff --git a/DepthsBelow/DepthsBelow/Interface.cs b/DepthsBelow/DepthsBelow/Interface.cs index e89dc84..4ddd919 100755 --- a/DepthsBelow/DepthsBelow/Interface.cs +++ b/DepthsBelow/DepthsBelow/Interface.cs @@ -7,6 +7,7 @@ using Microsoft.Xna.Framework; using System.Diagnostics; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Content; namespace DepthsBelow { @@ -140,9 +141,12 @@ namespace DepthsBelow } }; - var leftEdge = new Frame(UIParent); - leftEdge.Width = 20; - leftEdge.Height = GameServices.GetService().Viewport.Height; + var button = new GUI.Button(UIParent); + button.SetTexture("images/Enter"); + button.X = 100; + button.Y = 100; + button.Width = 55; + button.Height = 40; // Test GUI frames /*var frame = new GUI.Frame() @@ -228,6 +232,13 @@ namespace DepthsBelow frame.Width = 164; frame.Height = 19; + frame.OnClick += delegate(Frame frame1, GUIManager.MouseEventArgs args) + { + DynamicGroupManager.Group group = (DynamicGroupManager.Group)frame1["group"]; + if (group != null) + group.Panic += 5; + }; + var panicBarBg = new GUI.Frame(frame); panicBarBg.SetTexture("images/GUI/health_background"); panicBarBg.Width = 136; @@ -245,6 +256,13 @@ namespace DepthsBelow panicBar.Y = 1; frame["panicBar"] = panicBar; + var text = new GUI.Text(frame); + text.SetFont("fonts/UnitName"); + text.Value = "0%"; + text.X = 4; + text.Y = 1; + frame["text"] = text; + return frame; } @@ -374,9 +392,12 @@ namespace DepthsBelow var group = groups[index]; var pFrame = PanicFrames[index]; + pFrame["group"] = group; var pFrameBarBg = (GUI.Frame)pFrame["panicBarBg"]; var pFrameBar = (GUI.Frame)pFrame["panicBar"]; - pFrameBar.Width = (int)(pFrameBarBg.Width * (group.Panic / 100f)); + 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() + "%)"; pFrame.Visible = true; if (lastFrame != null) diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs index 35de637..78e33f8 100755 --- a/DepthsBelow/DepthsBelow/KeyboardInput.cs +++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs @@ -105,11 +105,11 @@ namespace DepthsBelow { KeyboardState ks = Keyboard.GetState(); - // Lua reload scripts - if (ks.IsKeyUp(Keys.R) && lastKeyboardState.IsKeyDown(Keys.R)) - { - core.Lua.Reload(); - } + // Brightness + if (ks.IsKeyUp(Keys.Up) && lastKeyboardState.IsKeyDown(Keys.Up)) + core.Brightness = (int)MathHelper.Clamp(core.Brightness + 5, 0, 254); + if (ks.IsKeyUp(Keys.Down) && lastKeyboardState.IsKeyDown(Keys.Down)) + core.Brightness = (int)MathHelper.Clamp(core.Brightness - 5, 0, 254); // Debug test: grouping if (ks.IsKeyUp(Keys.K) && lastKeyboardState.IsKeyDown(Keys.K)) diff --git a/DepthsBelow/DepthsBelow/Soldier.cs b/DepthsBelow/DepthsBelow/Soldier.cs index bfe342f..a25230a 100755 --- a/DepthsBelow/DepthsBelow/Soldier.cs +++ b/DepthsBelow/DepthsBelow/Soldier.cs @@ -65,12 +65,16 @@ namespace DepthsBelow var pfc = new PathFinder(this); AddComponent(pfc); - var flashlight = new Flashlight(this); + var flashlight = new Flashlight(this) + { + Intensity = 0.8f + }; AddComponent(flashlight); var stat = new Component.Stat(this) { MaxHP = 100, + MaxPanic = 100, //Life = 10, Defence = 10, Strength = 10, @@ -92,7 +96,7 @@ namespace DepthsBelow public static void LoadContent() { - Texture = GameServices.GetService().Load("images/soldier3"); + Texture = GameServices.GetService().Load("images/soldier5"); } public override void Update(GameTime gameTime) diff --git a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj index ee30040..fb93e08 100755 --- a/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj +++ b/DepthsBelow/DepthsBelowContent/DepthsBelowContent.contentproj @@ -210,6 +210,20 @@ TextureProcessor + + + soldier5 + TextureImporter + TextureProcessor + + + + + spot_wide + TextureImporter + TextureProcessor + +