Moved DrawLine from RenderHelpers to Utility.

This commit is contained in:
Simon Holmberg
2012-10-19 03:45:17 +02:00
parent 5cb05d1c3f
commit ce2264c737
6 changed files with 29 additions and 48 deletions
-6
View File
@@ -69,13 +69,7 @@ namespace DepthsBelow
// TODO: Add your initialization logic here // TODO: Add your initialization logic here
EntityManager = new EntityManager(); EntityManager = new EntityManager();
TurnManager = new TurnManager(new string[] { "Player", "Computer" }); 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);
Camera = new Camera(this); Camera = new Camera(this);
Squad = new List<Soldier>(); Squad = new List<Soldier>();
+1 -1
View File
@@ -197,7 +197,7 @@ namespace DepthsBelow
if (checkingDirection == true) if (checkingDirection == true)
{ {
RenderHelpers.DrawLine(spriteBatch, Color.White, 2, directionStart, directionNow); Utility.DrawLine(spriteBatch, Color.White, 2, directionStart, directionNow);
} }
} }
-30
View File
@@ -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);
}
}
}
-1
View File
@@ -22,7 +22,6 @@ namespace DepthsBelow
public string Name { get; private set; } public string Name { get; private set; }
private TurnManager turnManager; private TurnManager turnManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Token" /> class. /// Initializes a new instance of the <see cref="Token" /> class.
/// Preferably use <see cref="TurnManager.CreateToken" /> instead. /// Preferably use <see cref="TurnManager.CreateToken" /> instead.
+22 -3
View File
@@ -2,7 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using DepthsBelow.Component;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace DepthsBelow namespace DepthsBelow
{ {
@@ -19,15 +21,15 @@ namespace DepthsBelow
/// <returns>Returns a hit chance percentage.</returns> /// <returns>Returns a hit chance percentage.</returns>
public static int CalculateHitChance(Entity attacker, Entity defender) public static int CalculateHitChance(Entity attacker, Entity defender)
{ {
Component.Stat shooting = attacker.GetComponent<Component.Stat>(); Stat shooting = attacker.GetComponent<Stat>();
Component.Stat dodging = defender.GetComponent<Component.Stat>(); Stat dodging = defender.GetComponent<Stat>();
if (shooting == null || dodging == null) if (shooting == null || dodging == null)
{ {
return 0; return 0;
} }
int baseHitChance = shooting.GetAim; int baseHitChance = shooting.GetAim;
int baseDodgeChance = dodging.GetDodge; int baseDodgeChance = dodging.GetDodge;
int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent<Component.Transform>().World.Position, defender.GetComponent<Component.Transform>().World.Position) / Grid.TileSize); int basePenalty = shooting.Penalty((int)Vector2.Distance(attacker.GetComponent<Transform>().World.Position, defender.GetComponent<Transform>().World.Position) / Grid.TileSize);
int chanceToHit = baseHitChance - baseDodgeChance - basePenalty; int chanceToHit = baseHitChance - baseDodgeChance - basePenalty;
//Console.WriteLine(chanceToHit); //Console.WriteLine(chanceToHit);
return chanceToHit; return chanceToHit;
@@ -44,5 +46,22 @@ namespace DepthsBelow
} }
return false; 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);
}
} }
} }
@@ -3,4 +3,3 @@ ToolTip = CreateFrame("Frame")
local text = CreateFrame("Text", ToolTip) local text = CreateFrame("Text", ToolTip)
text:SetFont("Arial") text:SetFont("Arial")
text.Value = "99%" text.Value = "99%"
ToolTip.Text = text