Made Soldier Public and Made MouseInput Collision
This commit is contained in:
committed by
Simon Holmberg
parent
52bb50ce6e
commit
7e88d7c68a
@@ -0,0 +1,65 @@
|
||||
<<<<<<< HEAD
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DepthsBelow.Component
|
||||
{
|
||||
public class Collision : Component
|
||||
{
|
||||
|
||||
public Rectangle Rectangle;
|
||||
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
public Collision(Entity parent, int width, int height)
|
||||
: base(parent)
|
||||
{
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
this.Rectangle = new Rectangle(0, 0, width, height);
|
||||
}
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
PixelTransform pt = this.Parent.GetComponent<PixelTransform>();
|
||||
this.Rectangle.X = (int)pt.X;
|
||||
this.Rectangle.Y = (int)pt.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace DepthsBelow.Component
|
||||
{
|
||||
public class Collision : Component
|
||||
{
|
||||
|
||||
public Rectangle Rectangle;
|
||||
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
public Collision(Entity parent, int width, int height)
|
||||
: base(parent)
|
||||
{
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
this.Rectangle = new Rectangle(0, 0, width, height);
|
||||
}
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
PixelTransform pt = this.Parent.GetComponent<PixelTransform>();
|
||||
this.Rectangle.X = (int)pt.X;
|
||||
this.Rectangle.Y = (int)pt.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> Made Soldier Public and Made MouseInput Collision
|
||||
@@ -21,7 +21,7 @@ namespace DepthsBelow
|
||||
|
||||
public Camera camera;
|
||||
MouseInput mouse;
|
||||
Soldier soldier;
|
||||
public Soldier soldier;
|
||||
|
||||
public Core()
|
||||
{
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace DepthsBelow
|
||||
|
||||
if (ms.LeftButton == ButtonState.Released && selectionRectangle != Rectangle.Empty)
|
||||
{
|
||||
/*if (selectionRectangle.Intersects())
|
||||
if (selectionRectangle.Intersects(core.soldier.collision.Rectangle))
|
||||
{
|
||||
|
||||
}*/
|
||||
core.soldier.selected = true;
|
||||
}
|
||||
selectionRectangle = Rectangle.Empty;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace DepthsBelow
|
||||
public class Soldier : Entity
|
||||
{
|
||||
Core game;
|
||||
bool selected = false;
|
||||
public bool selected = false;
|
||||
static Texture2D Texture;
|
||||
|
||||
private KeyboardState lastKeyboardState;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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 Soldier : Entity
|
||||
{
|
||||
Core game;
|
||||
public bool selected = false;
|
||||
static Texture2D Texture;
|
||||
|
||||
private KeyboardState lastKeyboardState;
|
||||
|
||||
static public void LoadContent(Core game)
|
||||
{
|
||||
Texture = game.Content.Load<Texture2D>("images/soldier");
|
||||
}
|
||||
|
||||
public Soldier(Core game)
|
||||
{
|
||||
if (Texture == null)
|
||||
LoadContent(game);
|
||||
|
||||
Component.SpriteRenderer rc = new Component.SpriteRenderer(this);
|
||||
rc.Texture = Texture;
|
||||
rc.Color = Color.HotPink;
|
||||
this.AddComponent(rc);
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
/*KeyboardState ks = Keyboard.GetState();
|
||||
if (ks.IsKeyDown(Keys.Right) && lastKeyboardState.IsKeyUp(Keys.Right))
|
||||
gridTransform.Position.X += 1;
|
||||
lastKeyboardState = ks;*/
|
||||
|
||||
if (pixelTransform.Position.X < gridTransform.X * 32)
|
||||
{
|
||||
pixelTransform.Position.X += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user