AP on UI, and bub is moving!

This commit is contained in:
2012-10-31 19:22:28 +01:00
parent 7ecf6dabce
commit be5b073f31
5 changed files with 49 additions and 19 deletions
@@ -26,6 +26,9 @@ namespace DepthsBelow.Component
/// Scale of the texture.
/// </summary>
public float Scale;
public Vector2 Offset;
public SpriteEffects SpriteEffects;
public SpriteRenderer(Entity parent)
@@ -39,14 +42,7 @@ namespace DepthsBelow.Component
public void Draw(SpriteBatch spriteBatch)
{
var transform = this.Parent.GetComponent<Transform>();
if (AlternativeTexture == null)
{
spriteBatch.Draw(Texture, transform.World.Position + transform.World.Origin, null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0);
}
else
{
spriteBatch.Draw(AlternativeTexture, transform.World.Position + transform.World.Origin - new Vector2(Grid.TileSize, Grid.TileSize), null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0);
}
spriteBatch.Draw(Texture, transform.World.Position + transform.World.Origin + Offset, null, Color, transform.World.Rotation, transform.World.Origin, Scale, SpriteEffects, 0);
}
}
}
+3 -3
View File
@@ -123,7 +123,7 @@ namespace DepthsBelow
// TODO: use this.Content to load your game content here
Soldier.LoadContent();
SmallEnemy.LoadContent();
//SmallEnemy.LoadContent();
//Shot.LoadContent();
MouseInput = new MouseInput(this);
@@ -222,14 +222,14 @@ namespace DepthsBelow
}
}
/*#if DEBUG
#if DEBUG
var debugTexture = new Texture2D(GraphicsDevice, 1, 1);
debugTexture.SetData(new Color[] { Color.White });
foreach (var collisionComponent in EntityManager.GetComponents<Component.Collision>())
{
spriteBatch.Draw(debugTexture, collisionComponent.Rectangle, Color.Red * 0.5f);
}
#endif*/
#endif
// Draw mouse input visuals
MouseInput.Draw(spriteBatch);
+33 -2
View File
@@ -406,7 +406,7 @@ namespace DepthsBelow
frame.SetTexture("images/GUI/unit_background");
frame.Color = Color.Black;
frame.Width = 164;
frame.Height = 35;
frame.Height = 42;
var nameText = new GUI.Text(frame);
nameText.SetFont("fonts/UnitName");
@@ -432,6 +432,33 @@ namespace DepthsBelow
healthBar.Y = 1;
frame["healthBar"] = healthBar;
var actionBarBg = new GUI.Frame(frame);
actionBarBg.SetTexture("images/GUI/health_background");
actionBarBg.Width = 136;
actionBarBg.Height = 8;
actionBarBg.X = 3;
actionBarBg.Y = 31;
frame["actionBarBg"] = actionBarBg;
var actionBar = new GUI.Frame(actionBarBg);
actionBar.SetTexture("images/GUI/bar_solid");
actionBar.Color = Color.Orange;
actionBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent<Component.Stat>().HP / soldier.GetComponent<Component.Stat>().MaxHP));
actionBar.Height = 6;
actionBar.X = 1;
actionBar.Y = 1;
frame["actionBar"] = actionBar;
for (int i = 1; i < 10; i++)
{
var line = new GUI.Frame(actionBar);
line.Texture = Utility.GetSolidTexture();
line.Color = Color.Black;
line.Height = 6;
line.Width = 1;
line.X = (int)(i * ((float)actionBarBg.Width/10f)) - 1;
}
return frame;
}
@@ -532,7 +559,7 @@ namespace DepthsBelow
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() + "%)";
pFrameText.Value = Math.Round(group.Panic).ToString() + " (" + Math.Round(group.Panic / group.MaxPanic * 100f).ToString() + "%)";
pFrame.Visible = true;
if (lastFrame != null)
@@ -553,6 +580,10 @@ namespace DepthsBelow
var healthBar = (GUI.Frame)frame["healthBar"];
healthBar.Width = (int)((healthBarBg.Width - 2) * (soldier.GetComponent<Component.Stat>().Life / soldier.GetComponent<Component.Stat>().MaxHP));
// Update Action Points
var actionBarBg = (GUI.Frame)frame["actionBarBg"];
var actionBar = (GUI.Frame)frame["actionBar"];
actionBar.Width = (int)(((float)actionBarBg.Width - 2f) * ((float)soldier.AP / (float)soldier.MaxActionPoints));
lastFrame = frame;
}
}
+2 -2
View File
@@ -106,14 +106,14 @@ namespace DepthsBelow
enemy.X = mapObjectGridPos.X;
enemy.Y = mapObjectGridPos.Y;
}
/*if (mapObject.Type == "BossSpawn")
if (mapObject.Type == "BossSpawn")
{
var enemy = new MonsterSpawn("BUB", 12, 0, ref core.Swarm);
var mapObjectPos = new Vector2(mapObject.Bounds.X, mapObject.Bounds.Y - Grid.TileSize);
var mapObjectGridPos = Grid.WorldToGrid(mapObjectPos);
enemy.X = mapObjectGridPos.X;
enemy.Y = mapObjectGridPos.Y;
}*/
}
if (mapObject.Type == "Door")
{
var door = new Door();
+7 -4
View File
@@ -10,7 +10,7 @@ namespace DepthsBelow
{
public class SmallEnemy : Entity
{
public static Texture2D Texture;
public Texture2D Texture;
public Color Color;
public static Point Origin;
private bool _selected; //I guess as in "currently doing something"
@@ -81,14 +81,17 @@ namespace DepthsBelow
}
}
public static void LoadContent()
public void LoadContent()
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Monster");
}
public void LoadBoss()
{
GetComponent<SpriteRenderer>().AlternativeTexture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Pineapple");
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/Pineapple");
GetComponent<SpriteRenderer>().Texture = Texture;
Transform.World.Origin = new Vector2(((float)Texture.Width) / 2f, ((float)Texture.Height) / 2f);
GetComponent<SpriteRenderer>().Offset = (new Vector2(Texture.Width / 2f, Texture.Height / 2f) - new Vector2(Grid.TileSize / 2, Grid.TileSize / 2)) * -1;
var stat = new Component.Stat(this)
{
Life = 500,