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
+1 -7
View File
@@ -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<Soldier>();
+1 -1
View File
@@ -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);
}
}
-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; }
private TurnManager turnManager;
/// <summary>
/// Initializes a new instance of the <see cref="Token" /> class.
/// Preferably use <see cref="TurnManager.CreateToken" /> instead.
+26 -7
View File
@@ -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
{
/// <summary>
@@ -19,15 +21,15 @@ namespace DepthsBelow
/// <returns>Returns a hit chance percentage.</returns>
public static int CalculateHitChance(Entity attacker, Entity defender)
{
Component.Stat shooting = attacker.GetComponent<Component.Stat>();
Component.Stat dodging = defender.GetComponent<Component.Stat>();
Stat shooting = attacker.GetComponent<Stat>();
Stat dodging = defender.GetComponent<Stat>();
if (shooting == null || dodging == null)
{
return 0;
}
int baseHitChance = shooting.GetAim;
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;
//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);
}
}
}
@@ -2,5 +2,4 @@ ToolTip = CreateFrame("Frame")
local text = CreateFrame("Text", ToolTip)
text:SetFont("Arial")
text.Value = "99%"
ToolTip.Text = text
text.Value = "99%"