From f14623c88221a02aa2a8ebbf855a3b3506bce606 Mon Sep 17 00:00:00 2001 From: Niklas Ulf Anders Cullberg Date: Tue, 30 Oct 2012 22:04:16 +0100 Subject: [PATCH 1/3] HitChance displayed, Stats Rearranged --- DepthsBelow/DepthsBelow/Core.cs | 2 +- DepthsBelow/DepthsBelow/Interface.cs | 1198 +++++++++++++------------ DepthsBelow/DepthsBelow/MouseInput.cs | 2 +- DepthsBelow/DepthsBelow/SmallEnemy.cs | 342 +++---- 4 files changed, 790 insertions(+), 754 deletions(-) diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 6a0420e..a1f6afd 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -33,7 +33,7 @@ namespace DepthsBelow public Camera Camera; public Interface Interface; - public static MouseInput MouseInput; + public/* static*/ MouseInput MouseInput; public static KeyboardInput KeyboardInput; public List Squad; public DynamicGroupManager GroupManager; diff --git a/DepthsBelow/DepthsBelow/Interface.cs b/DepthsBelow/DepthsBelow/Interface.cs index 45a67fc..7f0fd6d 100755 --- a/DepthsBelow/DepthsBelow/Interface.cs +++ b/DepthsBelow/DepthsBelow/Interface.cs @@ -1,581 +1,617 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using DepthsBelow.GUI; -using Microsoft.Xna.Framework; -using System.Diagnostics; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Content; - -namespace DepthsBelow -{ - public class Interface - { - Core core; - - /// - /// The master frame covering the whole game screen. Parent of all frames. - /// This frame handles all mouse interaction with the game world - /// - public Frame UIParent; - - public List PanicFrames = new List(); - public List UnitFrames = new List(); - public Dictionary SoldierToFrame = new Dictionary(); - - Random random = new Random(); - - private bool checkingDirection; - private Vector2 directionStart; - - public Interface(Core core) - { - this.core = core; - - UIParent = new Frame(); - UIParent.Width = GameServices.GetService().Viewport.Width; - UIParent.Height = GameServices.GetService().Viewport.Height; - - // Selection rectangle - var selectionFrame = new Frame(UIParent); - selectionFrame.Texture = Utility.GetSolidTexture(); - selectionFrame.Color = Color.Red * 0.5f; - selectionFrame.Visible = false; - UIParent["selectionFrame"] = selectionFrame; - - // OnPress - UIParent.OnPress += delegate(Frame frame, GUIManager.MouseEventArgs args) - { - //KeyboardState ks = Keyboard.GetState(); - MouseState ms = args.MouseState; - var mousePos = new Point(ms.X, ms.Y); - var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); - var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); - var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); - - // Show the selection frame - if (args.LeftButton == ButtonState.Pressed) - { - var selectFrame = (GUI.Frame)frame["selectionFrame"]; - if (!selectFrame.Visible) - { - selectFrame.X = mousePos.X; - selectFrame.Y = mousePos.Y; - selectFrame.Visible = true; - } - } - - if (args.RightButton == ButtonState.Pressed) - { - // Unit rotation - foreach (var unit in core.Squad) - { - if (unit.Selected && mouseWorldRectangle.Intersects(unit.GetComponent().Rectangle)) - { - checkingDirection = true; - directionStart = unit.Transform.World + unit.Transform.World.Origin; - } - } - } - }; - - // OnRelease - UIParent.OnRelease += delegate(Frame frame, GUIManager.MouseEventArgs args) - { - KeyboardState ks = Keyboard.GetState(); - MouseState ms = args.MouseState; - var mousePos = new Point(ms.X, ms.Y); - - var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); - var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); - var mouseGridPos= Grid.WorldToGrid(mouseWorldPos); - var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); - - if (args.LeftButton == ButtonState.Pressed) - { - // Deselect all units - if (!ks.IsKeyDown(Keys.LeftControl)) - { - foreach (var unit in core.Squad) - unit.Selected = false; - - foreach (var unitFrame in UnitFrames) - unitFrame.Color = Color.Black; - } - - // Select all soldier units inside the selection rectangle - var selectFrame = (GUI.Frame)frame["selectionFrame"]; - if (selectFrame.Visible) - { - Console.WriteLine("Before: " + selectFrame.AbsoluteRectangle.X + ", " + selectFrame.AbsoluteRectangle.Y + ", " + selectFrame.AbsoluteRectangle.Width + ", " + selectFrame.AbsoluteRectangle.Height); - - var intersectionRectangle = core.Camera.ScreenToWorld(selectFrame.AbsoluteRectangle); - - Console.WriteLine("After: " + intersectionRectangle.X + ", " + intersectionRectangle.Y + ", " + intersectionRectangle.Width + ", " + intersectionRectangle.Height); - - - // Select all units in the rectangle - foreach (var soldier in core.Squad) - { - if (intersectionRectangle.Intersects(soldier.GetComponent().Rectangle)) - { - soldier.Selected = true; - foreach (var unitFrame in UnitFrames) - { - if (unitFrame["soldier"] == soldier) - unitFrame.Color = Color.Blue; - } - } - } - - selectFrame.Visible = false; - } - } - - // Send orders with right click - if (args.RightButton == ButtonState.Pressed) - { - if (checkingDirection) - { - checkingDirection = false; - } - else - { - Debug.WriteLine("Right button pressed on UIParent"); - Point mainpath = Point.Zero; - Stack soldierStack = new Stack(); - //core.Squad.Where(a=>a.Selected).ToList().ForEach(a => soldierStack.Push(a)); - /*foreach (var soldier in core.Squad) - { - if (soldier.Selected) - { - soldierStack.Push(soldier); - } - }*/ - - // Don't move into other soldiers - bool blocked = false; - foreach (var soldier in core.Squad) - if (soldier.Position == mouseGridPos) - blocked = true; - - if (!blocked) - { - byte[,] collisionMap = Core.Map.GetCollisionMap(); - - // Try pathfinding - foreach (var unit in core.Squad) - { - if (unit.Selected) - { - if (mainpath == Point.Zero) - { - mainpath = unit.Position; - } - Vector2 fromMain = new Vector2((mainpath.X - unit.Position.X)*Grid.TileSize, - (mainpath.Y - unit.Position.Y)*Grid.TileSize); - var goal = Grid.WorldToGrid(mouseWorldPos - fromMain); - Console.WriteLine("First " + unit.AP); - unit.GetComponent().Goal = goal; - var length = unit.GetComponent().Length - 1; - if (unit.AP >= length) - { - - if (unit.GetComponent().IsMoving == false) - { - // If a path was not found, add the unit to the stack - soldierStack.Push(unit); - } - else - { - unit.AP -= length; - Console.WriteLine("then " + unit.AP); - collisionMap[goal.X, goal.Y] = 0; - } - } - else - { - unit.GetComponent().Stop(); - } - - } - } - - // Loop in a spiral and assign the soldiers in the stack their own unblocked positions - int X = 10; - int Y = 10; - int x, y, dx, dy; - x = y = dx = 0; - dy = -1; - int t = (int) MathHelper.Max(X, Y); - int maxI = t*t; - for (int i = 0; i < maxI; i++) - { - if ((-X/2 < x && x <= X/2) && (-Y/2 < y && y <= Y/2)) - { - Point point = new Point(x + mouseGridPos.X, y + mouseGridPos.Y); - if (collisionMap[point.X, point.Y] == 1) - { - if (soldierStack.Count == 0) - { - break; - } - var soldier = soldierStack.Pop(); - - if (soldier == null) - { - break; - } - else - { - if (soldier.AP >= soldier.GetComponent().Length) - { - soldier.GetComponent().Goal = point; - soldier.AP -= soldier.GetComponent().Length; - - Console.WriteLine(x + " " + y); - Console.WriteLine(soldier.GetComponent().Goal.X + " " + - soldier.GetComponent().Goal.Y); - - } - } - } - - - } - if ((x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1 - y))) - { - t = dx; - dx = -dy; - dy = t; - } - x += dx; - y += dy; - } - } - } - } - }; - - var button = new GUI.Button(UIParent); - button.SetTexture("images/Enter"); - button.X = 200; - button.Y = 100; - button.Width = 55; - button.Height = 40; - - // Test GUI frames - /*var frame = new GUI.Frame() - { - Y = 100 - }; - - var button = new GUI.Button(frame) - { - Width = 48, - Height = 23, - Texture = core.Content.Load("images/Enter"), - OnClick = delegate(Point clickPos) - { - Debug.WriteLine("That ugly button was clicked at (" + clickPos.X + "," + clickPos.Y + ")"); - } - }; - - var text = new GUI.Text(frame); - text.SetFont("Arial"); - text.Value = "Hello world!";*/ - - // Create some unit frames - /*var panicFrame = CreatePanicFrame(); - var unit1 = CreateUnitFrame("Flight captain Rainbow"); - unit1.X = panicFrame.X; - unit1.Y = panicFrame.Y + panicFrame.Height; - unit1.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) - { - frame.Color = Color.Red; - }; - var unit2 = CreateUnitFrame("Mr. Sparkle"); - unit2.X = unit1.X; - unit2.Y = unit1.Y + unit1.Height; - unit2.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) - { - frame.Color = Color.Red; - };*/ - - /*var frame1 = new GUI.Frame(); - frame1.Layer = 0; - frame1.SetTexture("images/Enter"); - frame1.Color = Color.Red; - frame1.Width = 100; - frame1.Height = 100; - frame1.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) - { - if (frame.Color == Color.Red) - frame.Color = Color.Green; - else - frame.Color = Color.Red; - }; - var frame1_child = new GUI.Frame(frame1); - frame1_child.SetTexture("images/Enter"); - frame1_child.Color = Color.Purple; - frame1_child.Width = 60; - frame1_child.Height = 60; - frame1_child.X = 20; - frame1_child.Y = 20; - - var frame2 = new GUI.Frame(); - frame2.Layer = 0; - frame2.SetTexture("images/Enter"); - frame2.Color = Color.Blue; - frame2.Width = 100; - frame2.Height = 100; - frame2.X = 50; - frame2.Y = 50; - frame2.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) - { - if (frame.Color == Color.Blue) - frame.Color = Color.Yellow; - else - frame.Color = Color.Blue; - };*/ - } - - private GUI.Frame CreatePanicFrame() - { - var frame = new GUI.Frame(UIParent); - frame.SetTexture("images/GUI/unit_background"); - frame.Color = Color.Black; - 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; - panicBarBg.Height = 13; - panicBarBg.X = 3; - panicBarBg.Y = 3; - frame["panicBarBg"] = panicBarBg; - - var panicBar = new GUI.Frame(panicBarBg); - panicBar.SetTexture("images/GUI/bar_solid"); - panicBar.Color = new Color(87, 55, 253); - panicBar.Width = (int)(panicBarBg.Width * 0.5); - panicBar.Height = 11; - panicBar.X = 1; - 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; - } - - private GUI.Frame CreateUnitFrame(Soldier soldier) - { - var frame = new GUI.Frame(UIParent); - frame.SetTexture("images/GUI/unit_background"); - frame.Color = Color.Black; - frame.Width = 164; - frame.Height = 35; - - var nameText = new GUI.Text(frame); - nameText.SetFont("fonts/UnitName"); - nameText.Value = soldier.Name + " "/* + soldier.GetHashCode()*/; - nameText.X = 4; - nameText.Y = 1; - frame["nameText"] = nameText; - - var healthBarBg = new GUI.Frame(frame); - healthBarBg.SetTexture("images/GUI/health_background"); - healthBarBg.Width = 136; - healthBarBg.Height = 13; - healthBarBg.X = 3; - healthBarBg.Y = 19; - frame["healthBarBg"] = healthBarBg; - - var healthBar = new GUI.Frame(healthBarBg); - healthBar.SetTexture("images/GUI/bar_solid"); - healthBar.Color = Color.Red; - healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); - healthBar.Height = 11; - healthBar.X = 1; - healthBar.Y = 1; - frame["healthBar"] = healthBar; - - return frame; - } - - public void CreateUnitFrames(List squad) - { - // TODO: ForEach squad in Squads... - /*GUI.Frame lastFrame = null; - foreach (Soldier soldier in squad) - { - // TODO: Remove this test ;) - soldier.GetComponent().HP = random.Next(0, (int) soldier.GetComponent().MaxHP - 1); - - var uFrame = CreateUnitFrame(soldier); - uFrame["soldier"] = soldier; - soldier["unitFrame"] = uFrame; - if (lastFrame != null) - { - uFrame.X = lastFrame.X; - uFrame.Y = lastFrame.Y + lastFrame.Height; - } - uFrame.OnClick += delegate(Frame f, GUIManager.MouseEventArgs e) - { - var s = (Soldier) f["soldier"]; - KeyboardState ks = Keyboard.GetState(); - - if (!ks.IsKeyDown(Keys.LeftControl)) - { - // Deselect all units - foreach (var unitFrame in UnitFrames) - { - ((Soldier) unitFrame["soldier"]).Selected = false; - unitFrame.Color = Color.Black; - } - } - - if (!s.Selected) - { - s.Selected = true; - uFrame.Color = Color.Blue; - } - }; - UnitFrames.Add(uFrame); - lastFrame = uFrame; - }*/ - - foreach (var soldier in squad) - { - PanicFrames.Add(CreatePanicFrame()); - - // TODO: Remove this test ;) - //soldier.GetComponent().HP = random.Next(0, (int)soldier.GetComponent().MaxHP - 1); - - var uFrame = CreateUnitFrame(soldier); - uFrame["soldier"] = soldier; - soldier["unitFrame"] = uFrame; - uFrame.OnPress += delegate(Frame frame, GUIManager.MouseEventArgs args) { }; - uFrame.OnRelease += delegate(Frame f, GUIManager.MouseEventArgs e) - { - var s = (Soldier)f["soldier"]; - KeyboardState ks = Keyboard.GetState(); - - if (!ks.IsKeyDown(Keys.LeftControl)) - { - // Deselect all units - foreach (var unitFrame in UnitFrames) - { - ((Soldier)unitFrame["soldier"]).Selected = false; - unitFrame.Color = Color.Black; - } - } - - if (!s.Selected) - { - s.Selected = true; - uFrame.Color = Color.Blue; - } - }; - UnitFrames.Add(uFrame); - } - } - - public void UpdateUnitFrames() - { - core.GroupManager.UpdateGroups(); - var groups = core.GroupManager.Groups; - - foreach (var panicFrame in PanicFrames) - panicFrame.Visible = false; - - GUI.Frame lastFrame = null; - for (int index = 0; index < groups.Count; index++) - { - var group = groups[index]; - - var pFrame = PanicFrames[index]; - pFrame["group"] = group; - var pFrameBarBg = (GUI.Frame)pFrame["panicBarBg"]; - 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() + "%)"; - - pFrame.Visible = true; - if (lastFrame != null) - { - pFrame.X = lastFrame.X; - pFrame.Y = lastFrame.Y + lastFrame.Height + 15; - } - lastFrame = pFrame; - - foreach (Soldier soldier in @group.Entities) - { - var frame = (GUI.Frame) soldier["unitFrame"]; - frame.X = lastFrame.X; - frame.Y = lastFrame.Y + lastFrame.Height; - - // Update HP - //var healthBarBg = (GUI.Frame)frame["healthBarBg"]; - //var healthBar = (GUI.Frame)frame["healthBar"]; - //healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); - - lastFrame = frame; - } - } - } - - public void Update(GameTime gameTime) - { - MouseState ms = Mouse.GetState(); - var mousePos = new Point(ms.X, ms.Y); - var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); - var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); - var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); - - // Update the selection rectangle - var selectionFrame = (GUI.Frame)UIParent["selectionFrame"]; - if (selectionFrame.Visible) - { - selectionFrame.Width = (int)mousePos.X - selectionFrame.X; - selectionFrame.Height = (int)mousePos.Y - selectionFrame.Y; - } - - // Update rotations - if (checkingDirection) - { - foreach (var unit in core.Squad) - if (unit.Selected) - { - float directionX = mouseWorldPos.X - unit.Transform.World.X; - float directionY = mouseWorldPos.Y - unit.Transform.World.Y; - //var mouseDirection = mouseWorldPos; - //mouseDirection.Normalize(); - unit.GetComponent().World.Rotation = - (float) - Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y - unit.Transform.World.Origin.Y, - mouseWorldPos.X - unit.Transform.World.X - unit.Transform.World.Origin.X); - } - } - - UpdateUnitFrames(); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using DepthsBelow.GUI; +using Microsoft.Xna.Framework; +using System.Diagnostics; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Content; + +namespace DepthsBelow +{ + public class Interface + { + Core core; + + /// + /// The master frame covering the whole game screen. Parent of all frames. + /// This frame handles all mouse interaction with the game world + /// + public Frame UIParent; + + public List PanicFrames = new List(); + public List UnitFrames = new List(); + public Dictionary SoldierToFrame = new Dictionary(); + + Random random = new Random(); + + private bool checkingDirection; + private Vector2 directionStart; + + GUI.Text hitChance; + + public Interface(Core core) + { + this.core = core; + + UIParent = new Frame(); + UIParent.Width = GameServices.GetService().Viewport.Width; + UIParent.Height = GameServices.GetService().Viewport.Height; + + // Selection rectangle + var selectionFrame = new Frame(UIParent); + selectionFrame.Texture = Utility.GetSolidTexture(); + selectionFrame.Color = Color.Red * 0.5f; + selectionFrame.Visible = false; + UIParent["selectionFrame"] = selectionFrame; + + // OnPress + UIParent.OnPress += delegate(Frame frame, GUIManager.MouseEventArgs args) + { + //KeyboardState ks = Keyboard.GetState(); + MouseState ms = args.MouseState; + var mousePos = new Point(ms.X, ms.Y); + var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); + var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); + var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); + + // Show the selection frame + if (args.LeftButton == ButtonState.Pressed) + { + var selectFrame = (GUI.Frame)frame["selectionFrame"]; + if (!selectFrame.Visible) + { + selectFrame.X = mousePos.X; + selectFrame.Y = mousePos.Y; + selectFrame.Visible = true; + } + } + + if (args.RightButton == ButtonState.Pressed) + { + // Unit rotation + foreach (var unit in core.Squad) + { + if (unit.Selected && mouseWorldRectangle.Intersects(unit.GetComponent().Rectangle)) + { + checkingDirection = true; + directionStart = unit.Transform.World + unit.Transform.World.Origin; + } + } + } + }; + + // OnRelease + UIParent.OnRelease += delegate(Frame frame, GUIManager.MouseEventArgs args) + { + KeyboardState ks = Keyboard.GetState(); + MouseState ms = args.MouseState; + var mousePos = new Point(ms.X, ms.Y); + + var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); + var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); + var mouseGridPos= Grid.WorldToGrid(mouseWorldPos); + var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); + + if (args.LeftButton == ButtonState.Pressed) + { + // Deselect all units + if (!ks.IsKeyDown(Keys.LeftControl)) + { + foreach (var unit in core.Squad) + unit.Selected = false; + + foreach (var unitFrame in UnitFrames) + unitFrame.Color = Color.Black; + } + + // Select all soldier units inside the selection rectangle + var selectFrame = (GUI.Frame)frame["selectionFrame"]; + if (selectFrame.Visible) + { + Console.WriteLine("Before: " + selectFrame.AbsoluteRectangle.X + ", " + selectFrame.AbsoluteRectangle.Y + ", " + selectFrame.AbsoluteRectangle.Width + ", " + selectFrame.AbsoluteRectangle.Height); + + var intersectionRectangle = core.Camera.ScreenToWorld(selectFrame.AbsoluteRectangle); + + Console.WriteLine("After: " + intersectionRectangle.X + ", " + intersectionRectangle.Y + ", " + intersectionRectangle.Width + ", " + intersectionRectangle.Height); + + + // Select all units in the rectangle + foreach (var soldier in core.Squad) + { + if (intersectionRectangle.Intersects(soldier.GetComponent().Rectangle)) + { + soldier.Selected = true; + foreach (var unitFrame in UnitFrames) + { + if (unitFrame["soldier"] == soldier) + unitFrame.Color = Color.Blue; + } + } + } + + selectFrame.Visible = false; + } + } + + // Send orders with right click + if (args.RightButton == ButtonState.Pressed) + { + if (checkingDirection) + { + checkingDirection = false; + } + else + { + Debug.WriteLine("Right button pressed on UIParent"); + Point mainpath = Point.Zero; + Stack soldierStack = new Stack(); + //core.Squad.Where(a=>a.Selected).ToList().ForEach(a => soldierStack.Push(a)); + /*foreach (var soldier in core.Squad) + { + if (soldier.Selected) + { + soldierStack.Push(soldier); + } + }*/ + + // Don't move into other soldiers + bool blocked = false; + foreach (var soldier in core.Squad) + if (soldier.Position == mouseGridPos) + blocked = true; + + if (!blocked) + { + byte[,] collisionMap = Core.Map.GetCollisionMap(); + + // Try pathfinding + foreach (var unit in core.Squad) + { + if (unit.Selected) + { + if (mainpath == Point.Zero) + { + mainpath = unit.Position; + } + Vector2 fromMain = new Vector2((mainpath.X - unit.Position.X)*Grid.TileSize, + (mainpath.Y - unit.Position.Y)*Grid.TileSize); + var goal = Grid.WorldToGrid(mouseWorldPos - fromMain); + Console.WriteLine("First " + unit.AP); + unit.GetComponent().Goal = goal; + var length = unit.GetComponent().Length - 1; + if (unit.AP >= length) + { + + if (unit.GetComponent().IsMoving == false) + { + // If a path was not found, add the unit to the stack + soldierStack.Push(unit); + } + else + { + unit.AP -= length; + Console.WriteLine("then " + unit.AP); + collisionMap[goal.X, goal.Y] = 0; + } + } + else + { + unit.GetComponent().Stop(); + } + + } + } + + // Loop in a spiral and assign the soldiers in the stack their own unblocked positions + int X = 10; + int Y = 10; + int x, y, dx, dy; + x = y = dx = 0; + dy = -1; + int t = (int) MathHelper.Max(X, Y); + int maxI = t*t; + for (int i = 0; i < maxI; i++) + { + if ((-X/2 < x && x <= X/2) && (-Y/2 < y && y <= Y/2)) + { + Point point = new Point(x + mouseGridPos.X, y + mouseGridPos.Y); + if (collisionMap[point.X, point.Y] == 1) + { + if (soldierStack.Count == 0) + { + break; + } + var soldier = soldierStack.Pop(); + + if (soldier == null) + { + break; + } + else + { + if (soldier.AP >= soldier.GetComponent().Length) + { + soldier.GetComponent().Goal = point; + soldier.AP -= soldier.GetComponent().Length; + + Console.WriteLine(x + " " + y); + Console.WriteLine(soldier.GetComponent().Goal.X + " " + + soldier.GetComponent().Goal.Y); + + } + } + } + + + } + if ((x == y) || ((x < 0) && (x == -y)) || ((x > 0) && (x == 1 - y))) + { + t = dx; + dx = -dy; + dy = t; + } + x += dx; + y += dy; + } + } + } + } + }; + + hitChance = new Text(UIParent); + hitChance.SetFont("Arial"); + hitChance.Value = ""; + + var button = new GUI.Button(UIParent); + button.SetTexture("images/Enter"); + button.X = 200; + button.Y = 100; + button.Width = 55; + button.Height = 40; + + // Test GUI frames + /*var frame = new GUI.Frame() + { + Y = 100 + }; + + var button = new GUI.Button(frame) + { + Width = 48, + Height = 23, + Texture = core.Content.Load("images/Enter"), + OnClick = delegate(Point clickPos) + { + Debug.WriteLine("That ugly button was clicked at (" + clickPos.X + "," + clickPos.Y + ")"); + } + }; + + var text = new GUI.Text(frame); + text.SetFont("Arial"); + text.Value = "Hello world!";*/ + + // Create some unit frames + /*var panicFrame = CreatePanicFrame(); + var unit1 = CreateUnitFrame("Flight captain Rainbow"); + unit1.X = panicFrame.X; + unit1.Y = panicFrame.Y + panicFrame.Height; + unit1.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) + { + frame.Color = Color.Red; + }; + var unit2 = CreateUnitFrame("Mr. Sparkle"); + unit2.X = unit1.X; + unit2.Y = unit1.Y + unit1.Height; + unit2.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) + { + frame.Color = Color.Red; + };*/ + + /*var frame1 = new GUI.Frame(); + frame1.Layer = 0; + frame1.SetTexture("images/Enter"); + frame1.Color = Color.Red; + frame1.Width = 100; + frame1.Height = 100; + frame1.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) + { + if (frame.Color == Color.Red) + frame.Color = Color.Green; + else + frame.Color = Color.Red; + }; + var frame1_child = new GUI.Frame(frame1); + frame1_child.SetTexture("images/Enter"); + frame1_child.Color = Color.Purple; + frame1_child.Width = 60; + frame1_child.Height = 60; + frame1_child.X = 20; + frame1_child.Y = 20; + + var frame2 = new GUI.Frame(); + frame2.Layer = 0; + frame2.SetTexture("images/Enter"); + frame2.Color = Color.Blue; + frame2.Width = 100; + frame2.Height = 100; + frame2.X = 50; + frame2.Y = 50; + frame2.OnClick += delegate(Frame frame, Frame.MouseEventArgs args) + { + if (frame.Color == Color.Blue) + frame.Color = Color.Yellow; + else + frame.Color = Color.Blue; + };*/ + } + + private GUI.Frame CreatePanicFrame() + { + var frame = new GUI.Frame(UIParent); + frame.SetTexture("images/GUI/unit_background"); + frame.Color = Color.Black; + 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; + panicBarBg.Height = 13; + panicBarBg.X = 3; + panicBarBg.Y = 3; + frame["panicBarBg"] = panicBarBg; + + var panicBar = new GUI.Frame(panicBarBg); + panicBar.SetTexture("images/GUI/bar_solid"); + panicBar.Color = new Color(87, 55, 253); + panicBar.Width = (int)(panicBarBg.Width * 0.5); + panicBar.Height = 11; + panicBar.X = 1; + 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; + } + + private GUI.Frame CreateUnitFrame(Soldier soldier) + { + var frame = new GUI.Frame(UIParent); + frame.SetTexture("images/GUI/unit_background"); + frame.Color = Color.Black; + frame.Width = 164; + frame.Height = 35; + + var nameText = new GUI.Text(frame); + nameText.SetFont("fonts/UnitName"); + nameText.Value = soldier.Name + " "/* + soldier.GetHashCode()*/; + nameText.X = 4; + nameText.Y = 1; + frame["nameText"] = nameText; + + var healthBarBg = new GUI.Frame(frame); + healthBarBg.SetTexture("images/GUI/health_background"); + healthBarBg.Width = 136; + healthBarBg.Height = 13; + healthBarBg.X = 3; + healthBarBg.Y = 19; + frame["healthBarBg"] = healthBarBg; + + var healthBar = new GUI.Frame(healthBarBg); + healthBar.SetTexture("images/GUI/bar_solid"); + healthBar.Color = Color.Red; + healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); + healthBar.Height = 11; + healthBar.X = 1; + healthBar.Y = 1; + frame["healthBar"] = healthBar; + + return frame; + } + + public void CreateUnitFrames(List squad) + { + // TODO: ForEach squad in Squads... + /*GUI.Frame lastFrame = null; + foreach (Soldier soldier in squad) + { + // TODO: Remove this test ;) + soldier.GetComponent().HP = random.Next(0, (int) soldier.GetComponent().MaxHP - 1); + + var uFrame = CreateUnitFrame(soldier); + uFrame["soldier"] = soldier; + soldier["unitFrame"] = uFrame; + if (lastFrame != null) + { + uFrame.X = lastFrame.X; + uFrame.Y = lastFrame.Y + lastFrame.Height; + } + uFrame.OnClick += delegate(Frame f, GUIManager.MouseEventArgs e) + { + var s = (Soldier) f["soldier"]; + KeyboardState ks = Keyboard.GetState(); + + if (!ks.IsKeyDown(Keys.LeftControl)) + { + // Deselect all units + foreach (var unitFrame in UnitFrames) + { + ((Soldier) unitFrame["soldier"]).Selected = false; + unitFrame.Color = Color.Black; + } + } + + if (!s.Selected) + { + s.Selected = true; + uFrame.Color = Color.Blue; + } + }; + UnitFrames.Add(uFrame); + lastFrame = uFrame; + }*/ + + foreach (var soldier in squad) + { + PanicFrames.Add(CreatePanicFrame()); + + // TODO: Remove this test ;) + //soldier.GetComponent().HP = random.Next(0, (int)soldier.GetComponent().MaxHP - 1); + + var uFrame = CreateUnitFrame(soldier); + uFrame["soldier"] = soldier; + soldier["unitFrame"] = uFrame; + uFrame.OnPress += delegate(Frame frame, GUIManager.MouseEventArgs args) { }; + uFrame.OnRelease += delegate(Frame f, GUIManager.MouseEventArgs e) + { + var s = (Soldier)f["soldier"]; + KeyboardState ks = Keyboard.GetState(); + + if (!ks.IsKeyDown(Keys.LeftControl)) + { + // Deselect all units + foreach (var unitFrame in UnitFrames) + { + ((Soldier)unitFrame["soldier"]).Selected = false; + unitFrame.Color = Color.Black; + } + } + + if (!s.Selected) + { + s.Selected = true; + uFrame.Color = Color.Blue; + } + }; + UnitFrames.Add(uFrame); + } + } + + public void UpdateUnitFrames() + { + core.GroupManager.UpdateGroups(); + var groups = core.GroupManager.Groups; + + foreach (var panicFrame in PanicFrames) + panicFrame.Visible = false; + + GUI.Frame lastFrame = null; + for (int index = 0; index < groups.Count; index++) + { + var group = groups[index]; + + var pFrame = PanicFrames[index]; + pFrame["group"] = group; + var pFrameBarBg = (GUI.Frame)pFrame["panicBarBg"]; + 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() + "%)"; + + pFrame.Visible = true; + if (lastFrame != null) + { + pFrame.X = lastFrame.X; + pFrame.Y = lastFrame.Y + lastFrame.Height + 15; + } + lastFrame = pFrame; + + foreach (Soldier soldier in @group.Entities) + { + var frame = (GUI.Frame) soldier["unitFrame"]; + frame.X = lastFrame.X; + frame.Y = lastFrame.Y + lastFrame.Height; + + // Update HP + //var healthBarBg = (GUI.Frame)frame["healthBarBg"]; + //var healthBar = (GUI.Frame)frame["healthBar"]; + //healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); + + lastFrame = frame; + } + } + } + + public void Update(GameTime gameTime) + { + MouseState ms = Mouse.GetState(); + var mousePos = new Point(ms.X, ms.Y); + var mouseRectangle = new Rectangle(mousePos.X, mousePos.Y, 1, 1); + var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y)); + var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1); + + // Update the selection rectangle + var selectionFrame = (GUI.Frame)UIParent["selectionFrame"]; + if (selectionFrame.Visible) + { + selectionFrame.Width = (int)mousePos.X - selectionFrame.X; + selectionFrame.Height = (int)mousePos.Y - selectionFrame.Y; + } + + // Update rotations + if (checkingDirection) + { + foreach (var unit in core.Squad) + if (unit.Selected) + { + float directionX = mouseWorldPos.X - unit.Transform.World.X; + float directionY = mouseWorldPos.Y - unit.Transform.World.Y; + //var mouseDirection = mouseWorldPos; + //mouseDirection.Normalize(); + unit.GetComponent().World.Rotation = + (float) + Math.Atan2(mouseWorldPos.Y - unit.Transform.World.Y - unit.Transform.World.Origin.Y, + mouseWorldPos.X - unit.Transform.World.X - unit.Transform.World.Origin.X); + } + } + + bool onSomething = false; + + foreach (var unit in core.Squad) + { + if (unit.Selected == true && unit.Fired == false) + { + foreach (var enemy in core.Swarm) + { + if (core.MouseInput.gridRectangle.Intersects(enemy.GetComponent().Rectangle)) + { + onSomething = true; + hitChance.Visible = true; + int chanceToHit = Utility.CalculateHitChance(unit.GetComponent(), unit.GetComponent().World.Position, enemy); + hitChance.Value = chanceToHit.ToString() + "%"; + hitChance.X = ms.X - 15; + hitChance.Y = ms.Y - 15; + break; + } + } + if (onSomething == true) + { + break; + } + } + } + if (onSomething == false) + { + hitChance.Visible = false; + } + + UpdateUnitFrames(); + } + } +} diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index 7dfb5e8..1de178a 100755 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -17,7 +17,7 @@ namespace DepthsBelow MouseState lastMouseState; Rectangle selectionRectangle; Texture2D selectionTexture; - Rectangle gridRectangle; + public Rectangle gridRectangle; Texture2D gridTexture; Vector2 directionStart; diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs index e47a19f..5cb19f6 100755 --- a/DepthsBelow/DepthsBelow/SmallEnemy.cs +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -1,172 +1,172 @@ -using System; -using System.Collections.Generic; -using DepthsBelow.Component; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; - -namespace DepthsBelow -{ - public class SmallEnemy : Entity - { - public static Texture2D Texture; - public Color Color; - public static Point Origin; - private bool _selected; //I guess as in "currently doing something" - - public List Swarm; - - private PathFinder.Node nextNode; - - public int numberOfSteps = 5; - public int currentStep = 0; - - public int step - { - get { return currentStep; } - set - { - currentStep = value; - } - } - - public SmallEnemy(EntityManager entityManager, ref List swarm) - : base(entityManager) - { - if (Texture == null) - LoadContent(); - - this.Swarm = swarm; - - Transform.World.Origin = new Vector2(20, 16); - - this.Color = Color.White; - var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White }; - AddComponent(rc); - - var cc = new Collision(this, 32, 32); - AddComponent(cc); - - var pfc = new PathFinder(this); - AddComponent(pfc); - - var stat = new Component.Stat(this) - { - Life = 2, - Defence = 2, - Strength = 5000, - GetAim = 100, - GetDodge = 50 - }; - AddComponent(stat); - } - public override void Remove() - { - Swarm.Remove(this); - - base.Remove(); - } - - public bool Selected - { - get { return _selected; } - set - { - _selected = value; - GetComponent().Color = (value) ? Color.Blue : this.Color; - } - } - - public static void LoadContent() - { - Texture = GameServices.GetService().Load("images/Monster"); - } - - public override void Update(GameTime gameTime) - { - base.Update(gameTime); - - float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f; - - if (nextNode == null) - nextNode = GetComponent().Next(); - - if (nextNode != null) - { - List soldierCollisions = new List(); - - // Collision with moving units - foreach (var body in Swarm) - { - if (body != this) - { - if (body.Transform.Grid == nextNode.Position) - { - soldierCollisions.Add(body.Transform.Grid); - GetComponent().RecreatePath(soldierCollisions); - nextNode = GetComponent().Next(); - break; - } - } - } - - if (nextNode != null) - { - var nodeWorldPos = Grid.GridToWorld(nextNode.Position); - // HACK: Make this work properly with other speeds... - float speed = 4f; - if (Transform.World.X < nodeWorldPos.X) - { - Transform.World.X += speed; - GetComponent().World.Rotation = MathHelper.ToRadians(0); - } - if (Transform.World.X > nodeWorldPos.X) - { - Transform.World.X -= speed; - GetComponent().World.Rotation = MathHelper.ToRadians(180); - } - if (Transform.World.Y < nodeWorldPos.Y) - { - Transform.World.Y += speed; - GetComponent().World.Rotation = MathHelper.ToRadians(90); - } - if (Transform.World.Y > nodeWorldPos.Y) - { - Transform.World.Y -= speed; - GetComponent().World.Rotation = MathHelper.ToRadians(270); - } - if (Transform.World == nodeWorldPos) - { - if (currentStep < numberOfSteps) - { - currentStep++; - //lastLastNode = lastNode; - //lastNode = nextNode; - nextNode = GetComponent().Next(); - } - else - { - - GetComponent().Stop(); - } - foreach (var entity in entityManager.Entities) - { - if (entity is Soldier) - { - if (entity.GetComponent().Rectangle.Intersects(this.GetComponent().Rectangle)) - { - if (Utility.AttackTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) - { - break; - } - } - } - } - } - } - - } - } - } +using System; +using System.Collections.Generic; +using DepthsBelow.Component; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace DepthsBelow +{ + public class SmallEnemy : Entity + { + public static Texture2D Texture; + public Color Color; + public static Point Origin; + private bool _selected; //I guess as in "currently doing something" + + public List Swarm; + + private PathFinder.Node nextNode; + + public int numberOfSteps = 5; + public int currentStep = 0; + + public int step + { + get { return currentStep; } + set + { + currentStep = value; + } + } + + public SmallEnemy(EntityManager entityManager, ref List swarm) + : base(entityManager) + { + if (Texture == null) + LoadContent(); + + this.Swarm = swarm; + + Transform.World.Origin = new Vector2(20, 16); + + this.Color = Color.White; + var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White }; + AddComponent(rc); + + var cc = new Collision(this, 32, 32); + AddComponent(cc); + + var pfc = new PathFinder(this); + AddComponent(pfc); + + var stat = new Component.Stat(this) + { + Life = 50, + Defence = 25, + Strength = 26, + GetAim = 100, + GetDodge = 50 + }; + AddComponent(stat); + } + public override void Remove() + { + Swarm.Remove(this); + + base.Remove(); + } + + public bool Selected + { + get { return _selected; } + set + { + _selected = value; + GetComponent().Color = (value) ? Color.Blue : this.Color; + } + } + + public static void LoadContent() + { + Texture = GameServices.GetService().Load("images/Monster"); + } + + public override void Update(GameTime gameTime) + { + base.Update(gameTime); + + float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f; + + if (nextNode == null) + nextNode = GetComponent().Next(); + + if (nextNode != null) + { + List soldierCollisions = new List(); + + // Collision with moving units + foreach (var body in Swarm) + { + if (body != this) + { + if (body.Transform.Grid == nextNode.Position) + { + soldierCollisions.Add(body.Transform.Grid); + GetComponent().RecreatePath(soldierCollisions); + nextNode = GetComponent().Next(); + break; + } + } + } + + if (nextNode != null) + { + var nodeWorldPos = Grid.GridToWorld(nextNode.Position); + // HACK: Make this work properly with other speeds... + float speed = 4f; + if (Transform.World.X < nodeWorldPos.X) + { + Transform.World.X += speed; + GetComponent().World.Rotation = MathHelper.ToRadians(0); + } + if (Transform.World.X > nodeWorldPos.X) + { + Transform.World.X -= speed; + GetComponent().World.Rotation = MathHelper.ToRadians(180); + } + if (Transform.World.Y < nodeWorldPos.Y) + { + Transform.World.Y += speed; + GetComponent().World.Rotation = MathHelper.ToRadians(90); + } + if (Transform.World.Y > nodeWorldPos.Y) + { + Transform.World.Y -= speed; + GetComponent().World.Rotation = MathHelper.ToRadians(270); + } + if (Transform.World == nodeWorldPos) + { + if (currentStep < numberOfSteps) + { + currentStep++; + //lastLastNode = lastNode; + //lastNode = nextNode; + nextNode = GetComponent().Next(); + } + else + { + + GetComponent().Stop(); + } + foreach (var entity in entityManager.Entities) + { + if (entity is Soldier) + { + if (entity.GetComponent().Rectangle.Intersects(this.GetComponent().Rectangle)) + { + if (Utility.AttackTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) + { + break; + } + } + } + } + } + } + + } + } + } } \ No newline at end of file From 8f0b981bd39d6e0643c963c72531554b1af0c0e6 Mon Sep 17 00:00:00 2001 From: Niklas Ulf Anders Cullberg Date: Tue, 30 Oct 2012 22:22:45 +0100 Subject: [PATCH 2/3] Monster Autokill disabled, HP in bars Updated --- DepthsBelow/DepthsBelow/Interface.cs | 6 +- DepthsBelow/DepthsBelow/KeyboardInput.cs | 653 ++++++++++++----------- DepthsBelow/DepthsBelow/SmallEnemy.cs | 11 +- DepthsBelow/DepthsBelow/Soldier.cs | 4 +- 4 files changed, 341 insertions(+), 333 deletions(-) diff --git a/DepthsBelow/DepthsBelow/Interface.cs b/DepthsBelow/DepthsBelow/Interface.cs index 7f0fd6d..f1324e8 100755 --- a/DepthsBelow/DepthsBelow/Interface.cs +++ b/DepthsBelow/DepthsBelow/Interface.cs @@ -539,9 +539,9 @@ namespace DepthsBelow frame.Y = lastFrame.Y + lastFrame.Height; // Update HP - //var healthBarBg = (GUI.Frame)frame["healthBarBg"]; - //var healthBar = (GUI.Frame)frame["healthBar"]; - //healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().HP / soldier.GetComponent().MaxHP)); + var healthBarBg = (GUI.Frame)frame["healthBarBg"]; + var healthBar = (GUI.Frame)frame["healthBar"]; + healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent().Life / soldier.GetComponent().MaxHP)); lastFrame = frame; } diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs index 0d740d3..df0e153 100755 --- a/DepthsBelow/DepthsBelow/KeyboardInput.cs +++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs @@ -1,327 +1,328 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Media; - -namespace DepthsBelow -{ - public class KeyboardInput - { - Core core; - private KeyboardState lastKeyboardState; - - int checkerSpeed = 2; - - int bulletCost = 5; - int rocketCost = 10; - - public KeyboardInput(Core core) - { - this.core = core; - } - - /*public List> GetGroups(List soldiers) - { - var ungrouped = soldiers.ToList(); - var groups = new List>(); - - for (int index = 0; index < soldiers.Count; index++) - { - var checkingSoldier = soldiers[index]; - var group = new List(); - - for (int i = 0; i < soldiers.Count; i++) - { - var soldier = soldiers[i]; - if (ungrouped.Contains(soldier)) - { - float distance = Vector2.Distance(checkingSoldier.Transform.World + checkingSoldier.Transform.World.Origin, - soldier.Transform.World + soldier.Transform.World.Origin); - if (distance <= ((float) Grid.TileSize * 1f)) - { - ungrouped.Remove(soldier); - group.Add(soldier); - } - } - } - - if (group.Count > 0) - groups.Add(group); - } - - return groups; - }*/ - - // Get a list of dynamic soldier groups - public List> GetGroups(List soldiers, float maxRange) - { - var alreadyGrouped = new List(); - var groups = new List>(); - - for (int index = 0; index < soldiers.Count; index++) - { - var soldier = soldiers[index]; - - if (!alreadyGrouped.Contains(soldier)) - { - var group = new List(); - GetNearChain(ref group, soldiers, soldier, maxRange); - alreadyGrouped.AddRange(group); - - if (group.Count > 0) - groups.Add(group); - } - } - - return groups; - } - - // Get all soldiers who are close to each other in a chain - public void GetNearChain(ref List group, List soldiers, Soldier soldier, float maxRange) - { - for (int index = 0; index < soldiers.Count; index++) - { - var nearSoldier = soldiers[index]; - - if (!group.Contains(nearSoldier)) - { - float distance = Vector2.Distance(nearSoldier.Transform.World + nearSoldier.Transform.World.Origin, - soldier.Transform.World + soldier.Transform.World.Origin); - if (distance <= maxRange) - { - group.Add(nearSoldier); - GetNearChain(ref group, soldiers, nearSoldier, maxRange); - } - } - } - } - - private DynamicGroupManager groupManager; - - public void Update(GameTime gameTime) - { - KeyboardState ks = Keyboard.GetState(); - - // 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)) - { - if (groupManager == null) - groupManager = new DynamicGroupManager(core.Squad.Cast().ToList(), Grid.TileSize * 1.5f); - groupManager.UpdateGroups(); - //var groups = GetGroups(core.Squad, (float)Grid.TileSize * 1.5f); - var groups = groupManager.Groups; - foreach (var group in groups) - { - Debug.WriteLine("Group #" + groups.IndexOf(group) + " Panic: " + group.Panic); - foreach (var entity in group.Entities) - { - var soldier = (Soldier)entity; - Debug.WriteLine(soldier.Name + " " + soldier.GetHashCode()); - } - } - } - - // Next turn - if (ks.IsKeyDown(Keys.Enter) && lastKeyboardState.IsKeyUp(Keys.Enter)) - { - if (core.TurnManager.CurrentTurn == core.TurnManager["Player"]) - { - foreach (var unit in core.Squad) - { - unit.AP = unit.MaxActionPoints; - unit.Fired = false; - } - - core.TurnManager.EndTurn(); - } - - if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"]) - { - foreach (var enemy in core.Swarm) - { - enemy.step = 0; - Point target = Point.Zero; - float distance = 7000; - foreach (var unit in core.Squad) - { - Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); - Vector2 monster = new Vector2(enemy.Transform.Grid.X, enemy.Transform.Grid.Y); - - float newDistance = Vector2.Distance(soldier, monster); - - if (newDistance < distance) - { - target = unit.Transform.Grid; - distance = newDistance; - } - } - enemy.GetComponent().Goal = target; - distance = 7000; - - } - - core.TestMonster.step = 0; - Point testTarget = Point.Zero; - float testDistance = 7000; - foreach (var unit in core.Squad) - { - Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); - Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y); - - float newDistance = Vector2.Distance(soldier, monster); - - if (newDistance < testDistance) - { - testTarget = unit.Transform.Grid; - testDistance = newDistance; - } - } - core.TestMonster.GetComponent().Goal = testTarget; - testDistance = 7000; - - core.TurnManager.EndTurn(); - } - } - if (ks.IsKeyDown(Keys.A)) - { - /*foreach (var unit in core.Swarm) - { - unit.X = 200; - unit.Y = 200; - }*/ - core.TestMonster.X = 12; - core.TestMonster.Y = 4; - } - if (ks.IsKeyDown(Keys.N)) - { - - } - if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R)) - { - foreach (var soldier in core.Squad) - { - if (soldier.Selected == true && soldier.Fired == false) - { - bool enoughActionPoints = true; - int cost = 0; - string type = ""; - if (ks.IsKeyDown(Keys.S)) - { - cost = bulletCost; - type = "bullet"; - } - else if (ks.IsKeyDown(Keys.R)) - { - cost = rocketCost; - type = "Rocket"; - } - if (soldier.AP >= cost) - { - core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), type)); - soldier.AP -= cost; - soldier.Fired = true; - } - else - { - enoughActionPoints = false; - } - if (enoughActionPoints == true) - { - foreach (var shot in core.Volley) - { - if (shot.select == false) - { - shot.select = true; - shot.X = soldier.X; - shot.Y = soldier.Y; - //shot.Transform.World.X += Grid.TileSize / 2; - //shot.Transform.World.Y += Grid.TileSize / 2; - } - if (shot.direction == Vector2.Zero) - { - double directionX = Math.Cos(soldier.Transform.World.Rotation); - double directionY = Math.Sin(soldier.Transform.World.Rotation); - shot.direction = new Vector2((float)directionX, (float)directionY); - shot.Transform.World.Rotation = soldier.Transform.World.Rotation; - Vector2 yo = soldier.Transform.World.Position; - shot.Stat.Remember = yo; - } - } - } - } - } - } - if (ks.IsKeyDown(Keys.C)) - { - foreach (var soldier in core.Squad) - { - if (soldier.Selected == true && soldier.Fired == false) - { - Point checker = Point.Zero; - double directionX = Math.Cos(soldier.GetComponent().World.Rotation); - double directionY = Math.Sin(soldier.GetComponent().World.Rotation); - Vector2 direction = new Vector2((int)directionX, (int)directionY); - int range = 120; - int current = 0; - bool hit = false; - checker = new Point((int)soldier.Transform.World.Origin.X, (int)soldier.Transform.World.Origin.Y); - do - { - checker.X += (int)direction.X * checkerSpeed; - checker.Y += (int)direction.Y * checkerSpeed; - foreach (var creature in core.Swarm) - { - if (creature.GetComponent().Rectangle.Contains(checker)) - { - hit = true; - } - } - if (core.TestMonster.GetComponent().Rectangle.Contains(checker)) - { - - } - current++; - } while (hit == false && current < range); - current = 0; - if (soldier.Selected == true && soldier.Fired == false && hit == true) - { - core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), "Bullet")); - soldier.Fired = true; - foreach (var shot in core.Volley) - { - if (shot.select == false) - { - shot.select = true; - shot.X = soldier.X; - shot.Y = soldier.Y; - //shot.Transform.World.X += Grid.TileSize / 2; - //shot.Transform.World.Y += Grid.TileSize / 2; - } - if (shot.direction == Vector2.Zero) - { - shot.direction = new Vector2((float)directionX, (float)directionY); - shot.Transform.World.Rotation = soldier.Transform.World.Rotation; - } - } - } - hit = false; - } - } - } - - lastKeyboardState = ks; - } - } +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Media; + +namespace DepthsBelow +{ + public class KeyboardInput + { + Core core; + private KeyboardState lastKeyboardState; + + int checkerSpeed = 2; + + int bulletCost = 5; + int rocketCost = 10; + + public KeyboardInput(Core core) + { + this.core = core; + } + + /*public List> GetGroups(List soldiers) + { + var ungrouped = soldiers.ToList(); + var groups = new List>(); + + for (int index = 0; index < soldiers.Count; index++) + { + var checkingSoldier = soldiers[index]; + var group = new List(); + + for (int i = 0; i < soldiers.Count; i++) + { + var soldier = soldiers[i]; + if (ungrouped.Contains(soldier)) + { + float distance = Vector2.Distance(checkingSoldier.Transform.World + checkingSoldier.Transform.World.Origin, + soldier.Transform.World + soldier.Transform.World.Origin); + if (distance <= ((float) Grid.TileSize * 1f)) + { + ungrouped.Remove(soldier); + group.Add(soldier); + } + } + } + + if (group.Count > 0) + groups.Add(group); + } + + return groups; + }*/ + + // Get a list of dynamic soldier groups + public List> GetGroups(List soldiers, float maxRange) + { + var alreadyGrouped = new List(); + var groups = new List>(); + + for (int index = 0; index < soldiers.Count; index++) + { + var soldier = soldiers[index]; + + if (!alreadyGrouped.Contains(soldier)) + { + var group = new List(); + GetNearChain(ref group, soldiers, soldier, maxRange); + alreadyGrouped.AddRange(group); + + if (group.Count > 0) + groups.Add(group); + } + } + + return groups; + } + + // Get all soldiers who are close to each other in a chain + public void GetNearChain(ref List group, List soldiers, Soldier soldier, float maxRange) + { + for (int index = 0; index < soldiers.Count; index++) + { + var nearSoldier = soldiers[index]; + + if (!group.Contains(nearSoldier)) + { + float distance = Vector2.Distance(nearSoldier.Transform.World + nearSoldier.Transform.World.Origin, + soldier.Transform.World + soldier.Transform.World.Origin); + if (distance <= maxRange) + { + group.Add(nearSoldier); + GetNearChain(ref group, soldiers, nearSoldier, maxRange); + } + } + } + } + + private DynamicGroupManager groupManager; + + public void Update(GameTime gameTime) + { + KeyboardState ks = Keyboard.GetState(); + + // 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)) + { + if (groupManager == null) + groupManager = new DynamicGroupManager(core.Squad.Cast().ToList(), Grid.TileSize * 1.5f); + groupManager.UpdateGroups(); + //var groups = GetGroups(core.Squad, (float)Grid.TileSize * 1.5f); + var groups = groupManager.Groups; + foreach (var group in groups) + { + Debug.WriteLine("Group #" + groups.IndexOf(group) + " Panic: " + group.Panic); + foreach (var entity in group.Entities) + { + var soldier = (Soldier)entity; + Debug.WriteLine(soldier.Name + " " + soldier.GetHashCode()); + } + } + } + + // Next turn + if (ks.IsKeyDown(Keys.Enter) && lastKeyboardState.IsKeyUp(Keys.Enter)) + { + if (core.TurnManager.CurrentTurn == core.TurnManager["Player"]) + { + foreach (var unit in core.Squad) + { + unit.AP = unit.MaxActionPoints; + unit.Fired = false; + } + + core.TurnManager.EndTurn(); + } + + if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"]) + { + foreach (var enemy in core.Swarm) + { + enemy.step = 0; + enemy.AttackedThisTurn = false; + Point target = Point.Zero; + float distance = 7000; + foreach (var unit in core.Squad) + { + Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); + Vector2 monster = new Vector2(enemy.Transform.Grid.X, enemy.Transform.Grid.Y); + + float newDistance = Vector2.Distance(soldier, monster); + + if (newDistance < distance) + { + target = unit.Transform.Grid; + distance = newDistance; + } + } + enemy.GetComponent().Goal = target; + distance = 7000; + + } + + core.TestMonster.step = 0; + Point testTarget = Point.Zero; + float testDistance = 7000; + foreach (var unit in core.Squad) + { + Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); + Vector2 monster = new Vector2(core.TestMonster.Transform.Grid.X, core.TestMonster.Transform.Grid.Y); + + float newDistance = Vector2.Distance(soldier, monster); + + if (newDistance < testDistance) + { + testTarget = unit.Transform.Grid; + testDistance = newDistance; + } + } + core.TestMonster.GetComponent().Goal = testTarget; + testDistance = 7000; + + core.TurnManager.EndTurn(); + } + } + if (ks.IsKeyDown(Keys.A)) + { + /*foreach (var unit in core.Swarm) + { + unit.X = 200; + unit.Y = 200; + }*/ + core.TestMonster.X = 12; + core.TestMonster.Y = 4; + } + if (ks.IsKeyDown(Keys.N)) + { + + } + if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R)) + { + foreach (var soldier in core.Squad) + { + if (soldier.Selected == true && soldier.Fired == false) + { + bool enoughActionPoints = true; + int cost = 0; + string type = ""; + if (ks.IsKeyDown(Keys.S)) + { + cost = bulletCost; + type = "bullet"; + } + else if (ks.IsKeyDown(Keys.R)) + { + cost = rocketCost; + type = "Rocket"; + } + if (soldier.AP >= cost) + { + core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), type)); + soldier.AP -= cost; + soldier.Fired = true; + } + else + { + enoughActionPoints = false; + } + if (enoughActionPoints == true) + { + foreach (var shot in core.Volley) + { + if (shot.select == false) + { + shot.select = true; + shot.X = soldier.X; + shot.Y = soldier.Y; + //shot.Transform.World.X += Grid.TileSize / 2; + //shot.Transform.World.Y += Grid.TileSize / 2; + } + if (shot.direction == Vector2.Zero) + { + double directionX = Math.Cos(soldier.Transform.World.Rotation); + double directionY = Math.Sin(soldier.Transform.World.Rotation); + shot.direction = new Vector2((float)directionX, (float)directionY); + shot.Transform.World.Rotation = soldier.Transform.World.Rotation; + Vector2 yo = soldier.Transform.World.Position; + shot.Stat.Remember = yo; + } + } + } + } + } + } + if (ks.IsKeyDown(Keys.C)) + { + foreach (var soldier in core.Squad) + { + if (soldier.Selected == true && soldier.Fired == false) + { + Point checker = Point.Zero; + double directionX = Math.Cos(soldier.GetComponent().World.Rotation); + double directionY = Math.Sin(soldier.GetComponent().World.Rotation); + Vector2 direction = new Vector2((int)directionX, (int)directionY); + int range = 120; + int current = 0; + bool hit = false; + checker = new Point((int)soldier.Transform.World.Origin.X, (int)soldier.Transform.World.Origin.Y); + do + { + checker.X += (int)direction.X * checkerSpeed; + checker.Y += (int)direction.Y * checkerSpeed; + foreach (var creature in core.Swarm) + { + if (creature.GetComponent().Rectangle.Contains(checker)) + { + hit = true; + } + } + if (core.TestMonster.GetComponent().Rectangle.Contains(checker)) + { + + } + current++; + } while (hit == false && current < range); + current = 0; + if (soldier.Selected == true && soldier.Fired == false && hit == true) + { + core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), "Bullet")); + soldier.Fired = true; + foreach (var shot in core.Volley) + { + if (shot.select == false) + { + shot.select = true; + shot.X = soldier.X; + shot.Y = soldier.Y; + //shot.Transform.World.X += Grid.TileSize / 2; + //shot.Transform.World.Y += Grid.TileSize / 2; + } + if (shot.direction == Vector2.Zero) + { + shot.direction = new Vector2((float)directionX, (float)directionY); + shot.Transform.World.Rotation = soldier.Transform.World.Rotation; + } + } + } + hit = false; + } + } + } + + lastKeyboardState = ks; + } + } } \ No newline at end of file diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs index 5cb19f6..b21b26f 100755 --- a/DepthsBelow/DepthsBelow/SmallEnemy.cs +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -22,6 +22,8 @@ namespace DepthsBelow public int numberOfSteps = 5; public int currentStep = 0; + public bool AttackedThisTurn = false; + public int step { get { return currentStep; } @@ -150,15 +152,20 @@ namespace DepthsBelow GetComponent().Stop(); } + foreach (var entity in entityManager.Entities) { if (entity is Soldier) { if (entity.GetComponent().Rectangle.Intersects(this.GetComponent().Rectangle)) { - if (Utility.AttackTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) + if (AttackedThisTurn == false) { - break; + if (Utility.AttackTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) + { + AttackedThisTurn = true; + break; + } } } } diff --git a/DepthsBelow/DepthsBelow/Soldier.cs b/DepthsBelow/DepthsBelow/Soldier.cs index 8f0eb7a..f1b099c 100755 --- a/DepthsBelow/DepthsBelow/Soldier.cs +++ b/DepthsBelow/DepthsBelow/Soldier.cs @@ -78,8 +78,8 @@ namespace DepthsBelow { MaxHP = 100, MaxPanic = 100, - //Life = 10, - Defence = 10, + Life = 100, + Defence = 25, Strength = 50, GetAim = 40, GetDodge = 20 From a785067218211753d353a4240fe49cee9e868ed7 Mon Sep 17 00:00:00 2001 From: Niklas Ulf Anders Cullberg Date: Tue, 30 Oct 2012 22:50:40 +0100 Subject: [PATCH 3/3] What? I just added a few extra surprises... --- DepthsBelow/DepthsBelow/MonsterSpawn.cs | 5 +- .../DepthsBelowContent/maps/Aztek.Test.tmx | 83 ++++++++++--------- 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/DepthsBelow/DepthsBelow/MonsterSpawn.cs b/DepthsBelow/DepthsBelow/MonsterSpawn.cs index 1ad98df..15b1f1f 100755 --- a/DepthsBelow/DepthsBelow/MonsterSpawn.cs +++ b/DepthsBelow/DepthsBelow/MonsterSpawn.cs @@ -11,7 +11,8 @@ namespace DepthsBelow { //EntityManager entityManager; - int wakingDistance = 6; + int wakingDistance = 7; + int sleepingDistance = 6; List swarm; @@ -33,7 +34,7 @@ namespace DepthsBelow this.GetComponent().Grid.Position.Y); Vector2 distance2 = new Vector2(entity.GetComponent().Grid.Position.X, entity.GetComponent().Grid.Position.Y); - if (Vector2.Distance(distance1, distance2) < wakingDistance) + if (Vector2.Distance(distance1, distance2) < wakingDistance/* && Vector2.Distance(distance1, distance2) > sleepingDistance*/) { var enemy = new SmallEnemy(entityManager, ref swarm); enemy.X = this.X; diff --git a/DepthsBelow/DepthsBelowContent/maps/Aztek.Test.tmx b/DepthsBelow/DepthsBelowContent/maps/Aztek.Test.tmx index f0de30c..f3879aa 100755 --- a/DepthsBelow/DepthsBelowContent/maps/Aztek.Test.tmx +++ b/DepthsBelow/DepthsBelowContent/maps/Aztek.Test.tmx @@ -1,38 +1,45 @@ - - - - - - - - - - - eJzt1sEJgEAMAMED++/ZCsTzYVxhBtJA9pGsBQAA0HVsDHP0aNjpoMccPZr0aNGjS4MWPVr0aHjya2n1Pj2a7nauxyw9WvRouerhjnxDjxY9WvRocc9b9GjRo0WPFj1a9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4M9ODsMCBQ== - - - - - eJzt2MlOwzAQBmA/Ajvc2OEGYr0BLcuN7f2fhqlUS1GqNCfHQfk+6ZeqxAdLk2TGTQkAAMg2IpuRrTXZjuzU2uDEHEaOIsdrchI5rbS/KVk8+w+Rx551N5Hb8tuZvMWz/x756FmnHsN4iexHDnrWqccwviMXkcuedeoxnKfIc1p9V3Yje8vrs8i8xuYm6DPylVbflbPI+fL6Ir9VdjdtV5Hr5W/fqHrymbA5+95F7pPzYQ35TNicfV8jb8n5sIbc07v6eU6+71tWVu7p6/p5s9+rxzD6+nm+rx7D6KpHu9/nXq+vl9VVj3a/z71eXy+rqx7N602+W2Wpx7h01aM9D+dZeJb8r1VSVz3a83CehX+S/7VKMu+Oi3qMi3qMi3qMi3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDf/QHD8yhT - - - - - eJzt0bEJgEAQRNHrx6tAq/BswP6rcCODC0Qw2BXeg58PTGsAAADwbERH9ghu/qjFH7X4AwAAgLfWaMseAQB8skQ9ewQAv7JPkeucAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAai5YqQYl - - - - - - - - - - - - - - eJzt1rENAyEQAMF3X+6/LpdgeA5pgxnpUoJbCXgeAJj1/dwd9ujRokeLHi0ne9Rknh4tJ7vTY54eLe6rFj1advfpz3vX7R7s0aNlcpd6nLvdQ5M9E/fVv7NYp0eLHi0nPVbPZJ0eLXq06NFy+z1njx49erTo0aJHix49K+/6m+EdPVr06LFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoO4HZimKNQ== - - - + + + + + + + + + + + eJzt1sEJgEAMAMED++/ZCsTzYVxhBtJA9pGsBQAA0HVsDHP0aNjpoMccPZr0aNGjS4MWPVr0aHjya2n1Pj2a7nauxyw9WvRouerhjnxDjxY9WvRocc9b9GjRo0WPFj1a9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4M9ODsMCBQ== + + + + + eJzt2MlOwzAQBmA/Ajvc2OEGYr0BLcuN7f2fhqlUS1GqNCfHQfk+6ZeqxAdLk2TGTQkAAMg2IpuRrTXZjuzU2uDEHEaOIsdrchI5rbS/KVk8+w+Rx551N5Hb8tuZvMWz/x756FmnHsN4iexHDnrWqccwviMXkcuedeoxnKfIc1p9V3Yje8vrs8i8xuYm6DPylVbflbPI+fL6Ir9VdjdtV5Hr5W/fqHrymbA5+95F7pPzYQ35TNicfV8jb8n5sIbc07v6eU6+71tWVu7p6/p5s9+rxzD6+nm+rx7D6KpHu9/nXq+vl9VVj3a/z71eXy+rqx7N602+W2Wpx7h01aM9D+dZeJb8r1VSVz3a83CehX+S/7VKMu+Oi3qMi3qMi3qMi3oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPDf/QHD8yhT + + + + + eJzt0bEJgEAQRNHrx6tAq/BswP6rcCODC0Qw2BXeg58PTGsAAADwbERH9ghu/qjFH7X4AwAAgLfWaMseAQB8skQ9ewQAv7JPkeucAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAai5YqQYl + + + + + + + + + + + + + + + + + + + + + eJzt1rENAyEQAMF3X+6/LpdgeA5pgxnpUoJbCXgeAJj1/dwd9ujRokeLHi0ne9Rknh4tJ7vTY54eLe6rFj1advfpz3vX7R7s0aNlcpd6nLvdQ5M9E/fVv7NYp0eLHi0nPVbPZJ0eLXq06NFy+z1njx49erTo0aJHix49K+/6m+EdPVr06LFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoO4HZimKNQ== + + +