From ce2264c73723db02afaf78d1d8015c582cd167ff Mon Sep 17 00:00:00 2001 From: Simon Holmberg Date: Fri, 19 Oct 2012 03:45:17 +0200 Subject: [PATCH] Moved DrawLine from RenderHelpers to Utility. --- DepthsBelow/DepthsBelow/Core.cs | 8 +---- DepthsBelow/DepthsBelow/MouseInput.cs | 2 +- DepthsBelow/DepthsBelow/RenderHelpers.cs | 30 ----------------- DepthsBelow/DepthsBelow/TurnManager.cs | 1 - DepthsBelow/DepthsBelow/Utility.cs | 33 +++++++++++++++---- .../DepthsBelowContent/scripts/tooltip.lua | 3 +- 6 files changed, 29 insertions(+), 48 deletions(-) delete mode 100755 DepthsBelow/DepthsBelow/RenderHelpers.cs diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 9cd3eee..fc54e1b 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -69,13 +69,7 @@ namespace DepthsBelow // TODO: Add your initialization logic here EntityManager = new EntityManager(); - - TurnManager = new TurnManager(new string[] { "Player", "Computer" }); - Console.WriteLine("Current turn: " + TurnManager.CurrentTurn.Name); - TurnManager.EndTurn(); - Console.WriteLine("Current turn: " + TurnManager.CurrentTurn.Name); - TurnManager.EndTurn(); - Console.WriteLine("Current turn: " + TurnManager.CurrentTurn.Name); + TurnManager = new TurnManager(new string[] { "Player", "Computer" }); Camera = new Camera(this); Squad = new List(); diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index 7e01cf3..de6140c 100755 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -197,7 +197,7 @@ namespace DepthsBelow if (checkingDirection == true) { - RenderHelpers.DrawLine(spriteBatch, Color.White, 2, directionStart, directionNow); + Utility.DrawLine(spriteBatch, Color.White, 2, directionStart, directionNow); } } diff --git a/DepthsBelow/DepthsBelow/RenderHelpers.cs b/DepthsBelow/DepthsBelow/RenderHelpers.cs deleted file mode 100755 index ee8b95a..0000000 --- a/DepthsBelow/DepthsBelow/RenderHelpers.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -namespace DepthsBelow -{ - static class RenderHelpers - { - static Texture2D blank; - - public static void DrawLine(SpriteBatch batch, Color color, float width, Vector2 start, Vector2 end) - { - if (blank == null) - { - blank = new Texture2D(Core.GraphicsDeviceManager.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); - blank.SetData(new[] { color }); - } - - float angle = (float)Math.Atan2(end.Y - start.Y, end.X - start.X); - float length = Vector2.Distance(start, end); - - batch.Draw(blank, start, null, color, - angle, Vector2.Zero, new Vector2(length, width), - SpriteEffects.None, 0); - } - } -} diff --git a/DepthsBelow/DepthsBelow/TurnManager.cs b/DepthsBelow/DepthsBelow/TurnManager.cs index 15215c8..dcd4e2b 100755 --- a/DepthsBelow/DepthsBelow/TurnManager.cs +++ b/DepthsBelow/DepthsBelow/TurnManager.cs @@ -22,7 +22,6 @@ namespace DepthsBelow public string Name { get; private set; } private TurnManager turnManager; - /// /// Initializes a new instance of the class. /// Preferably use instead. diff --git a/DepthsBelow/DepthsBelow/Utility.cs b/DepthsBelow/DepthsBelow/Utility.cs index 1ee1487..56cb736 100644 --- a/DepthsBelow/DepthsBelow/Utility.cs +++ b/DepthsBelow/DepthsBelow/Utility.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Microsoft.Xna.Framework; - +using System.Text; +using DepthsBelow.Component; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + namespace DepthsBelow { /// @@ -19,15 +21,15 @@ namespace DepthsBelow /// Returns a hit chance percentage. public static int CalculateHitChance(Entity attacker, Entity defender) { - Component.Stat shooting = attacker.GetComponent(); - Component.Stat dodging = defender.GetComponent(); + Stat shooting = attacker.GetComponent(); + Stat dodging = defender.GetComponent(); if (shooting == null || dodging == null) { return 0; } int baseHitChance = shooting.GetAim; int baseDodgeChance = dodging.GetDodge; - int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent().World.Position, defender.GetComponent().World.Position) / Grid.TileSize); + int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent().World.Position, defender.GetComponent().World.Position) / Grid.TileSize); int chanceToHit = baseHitChance - baseDodgeChance - basePenalty; //Console.WriteLine(chanceToHit); return chanceToHit; @@ -43,6 +45,23 @@ namespace DepthsBelow return true; } return false; - }*/ + }*/ + private static Texture2D blank; + + public static void DrawLine(SpriteBatch batch, Color color, float width, Vector2 start, Vector2 end) + { + if (blank == null) + { + blank = new Texture2D(Core.GraphicsDeviceManager.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); + blank.SetData(new[] { color }); + } + + float angle = (float)Math.Atan2(end.Y - start.Y, end.X - start.X); + float length = Vector2.Distance(start, end); + + batch.Draw(blank, start, null, color, + angle, Vector2.Zero, new Vector2(length, width), + SpriteEffects.None, 0); + } } } diff --git a/DepthsBelow/DepthsBelowContent/scripts/tooltip.lua b/DepthsBelow/DepthsBelowContent/scripts/tooltip.lua index 0a2cf5d..036af35 100755 --- a/DepthsBelow/DepthsBelowContent/scripts/tooltip.lua +++ b/DepthsBelow/DepthsBelowContent/scripts/tooltip.lua @@ -2,5 +2,4 @@ ToolTip = CreateFrame("Frame") local text = CreateFrame("Text", ToolTip) text:SetFont("Arial") -text.Value = "99%" -ToolTip.Text = text +text.Value = "99%" \ No newline at end of file