C# Class PathfindingTest.Units.Unit

Inheritance: OnCollisionChangedListener, Aggroable, Damageable
ファイルを表示 Open project: Wotuu/RTS_XNA_v2 Class Usage Examples

Public Properties

Property Type Description
isDead System.Boolean

Private Properties

Property Type Description
Draw void
DrawHealthBar void
Move void
SetMoveToTarget void
isTargetDead System.Boolean
isUnitDead System.Boolean

Public Methods

Method Description
AttackBuilding ( Building enemyBuilding ) : void
AttackUnit ( Unit unitToAttack ) : void

Sets the target to attack

CalculatePath ( Point p ) : CustomArrayList

Calculates a path between the current unit and the point.

CheckCollision ( ) : void

Repels other units that dare come close to our unit!

CheckForBuildingsInRange ( float rangeToCheck ) : void

Updates the buildingsInRange variable, to contain all the buildings within the attack range of this unit.

CheckForEnemiesInRange ( float rangeToCheck ) : void

Updates the enemiesInRange variable, to contain all the enemies within the attack range of this unit.

Defend ( Unit unitToDefend ) : void

Sets the target to defend

DefineDrawRectangle ( ) : Rectangle

Defines the rectangle/hitbox for the Unit. With draw offset

DefineRectangle ( ) : Rectangle

Defines the rectangle/hitbox for the Unit. without draw offset

Dispose ( ) : void

Dispose of this unit.

GetCost ( Type t ) : int

Gets the cost of a unit

GetDrawRectangle ( ) : Rectangle

Gets the draw rectangle of this unit.

GetLocation ( ) : Point

Gets a point location of this unit

MoveToNow ( Point p ) : void

Feel free to use "\ <(*^_^*)> /"

MoveToQueue ( Point p ) : void

Moves to a point in a while, by placing this unit and the point in a queue. When the time is there, process the pathfind This method is preferred to MoveToNow(Point p), as it doesn't cause a performance peek, but it may take a few frames before your path is ready.

OnAggro ( AggroEvent e ) : void
OnAggroRecieved ( AggroEvent e ) : void
OnCollisionChangedListener ( CollisionChangedEvent collisionEvent ) : void
OnDamage ( DamageEvent e ) : void
SetAssaultLocation ( Point assaultPoint ) : void
SetJob ( Unit newJob ) : void

Set's the new Job for the unit

Swing ( Damageable target ) : void

This unit will attempt to fire/swing/kill/cast!

TryToSwing ( ) : void
Unit ( Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire ) : System
Update ( KeyboardState ks, Microsoft.Xna.Framework.Input.MouseState ms ) : void
UpdateAttack ( ) : void
UpdateDefense ( ) : void

Protected Methods

Method Description
UpdateMovement ( ) : void

Updates the movement of this unit.

Private Methods

Method Description
Draw ( SpriteBatch sb ) : void
DrawHealthBar ( SpriteBatch sb ) : void
Move ( ) : void

Updates the drawing position of this Unit.

SetMoveToTarget ( int x, int y ) : void

Set the point this Unit has to move to. direction != direction is used for checking NaNExceptions.

isTargetDead ( ) : System.Boolean

Checks to see wether the set target has died yet.

isUnitDead ( Unit unit ) : System.Boolean

Method Details

AttackBuilding() public method

public AttackBuilding ( Building enemyBuilding ) : void
enemyBuilding Building
return void

AttackUnit() public method

Sets the target to attack
public AttackUnit ( Unit unitToAttack ) : void
unitToAttack Unit
return void

CalculatePath() public method

Calculates a path between the current unit and the point.
public CalculatePath ( Point p ) : CustomArrayList
p Point The point to calculate to.
return CustomArrayList

CheckCollision() public method

Repels other units that dare come close to our unit!
public CheckCollision ( ) : void
return void

CheckForBuildingsInRange() public method

Updates the buildingsInRange variable, to contain all the buildings within the attack range of this unit.
public CheckForBuildingsInRange ( float rangeToCheck ) : void
rangeToCheck float
return void

CheckForEnemiesInRange() public method

Updates the enemiesInRange variable, to contain all the enemies within the attack range of this unit.
public CheckForEnemiesInRange ( float rangeToCheck ) : void
rangeToCheck float
return void

Defend() public method

Sets the target to defend
public Defend ( Unit unitToDefend ) : void
unitToDefend Unit
return void

DefineDrawRectangle() public method

Defines the rectangle/hitbox for the Unit. With draw offset
public DefineDrawRectangle ( ) : Rectangle
return Microsoft.Xna.Framework.Rectangle

DefineRectangle() public method

Defines the rectangle/hitbox for the Unit. without draw offset
public DefineRectangle ( ) : Rectangle
return Microsoft.Xna.Framework.Rectangle

Dispose() public method

Dispose of this unit.
public Dispose ( ) : void
return void

GetCost() public static method

Gets the cost of a unit
public static GetCost ( Type t ) : int
t System.Type The unit type of which the cost is wanted
return int

GetDrawRectangle() public method

Gets the draw rectangle of this unit.
public GetDrawRectangle ( ) : Rectangle
return Microsoft.Xna.Framework.Rectangle

GetLocation() public method

Gets a point location of this unit
public GetLocation ( ) : Point
return Point

MoveToNow() public method

Feel free to use "\ <(*^_^*)> /"
public MoveToNow ( Point p ) : void
p Point The point to move to
return void

MoveToQueue() public method

Moves to a point in a while, by placing this unit and the point in a queue. When the time is there, process the pathfind This method is preferred to MoveToNow(Point p), as it doesn't cause a performance peek, but it may take a few frames before your path is ready.
public MoveToQueue ( Point p ) : void
p Point The point to move to, in a few frames depending on the queue
return void

OnAggro() public abstract method

public abstract OnAggro ( AggroEvent e ) : void
e PathfindingTest.Combat.AggroEvent
return void

OnAggroRecieved() public abstract method

public abstract OnAggroRecieved ( AggroEvent e ) : void
e PathfindingTest.Combat.AggroEvent
return void

OnCollisionChangedListener() public method

public OnCollisionChangedListener ( CollisionChangedEvent collisionEvent ) : void
collisionEvent AStarCollisionMap.Collision.CollisionChangedEvent
return void

OnDamage() public method

public OnDamage ( DamageEvent e ) : void
e PathfindingTest.Combat.DamageEvent
return void

SetAssaultLocation() public method

public SetAssaultLocation ( Point assaultPoint ) : void
assaultPoint Point
return void

SetJob() public method

Set's the new Job for the unit
public SetJob ( Unit newJob ) : void
newJob Unit
return void

Swing() public abstract method

This unit will attempt to fire/swing/kill/cast!
public abstract Swing ( Damageable target ) : void
target Damageable
return void

TryToSwing() public method

public TryToSwing ( ) : void
return void

Unit() public method

public Unit ( Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire ) : System
p PathfindingTest.Players.Player
x int
y int
movementSpeed float
attackRange float
aggroRange float
rateOfFire float
return System

Update() public abstract method

public abstract Update ( KeyboardState ks, Microsoft.Xna.Framework.Input.MouseState ms ) : void
ks Microsoft.Xna.Framework.Input.KeyboardState
ms Microsoft.Xna.Framework.Input.MouseState
return void

UpdateAttack() public method

public UpdateAttack ( ) : void
return void

UpdateDefense() public method

public UpdateDefense ( ) : void
return void

UpdateMovement() protected method

Updates the movement of this unit.
protected UpdateMovement ( ) : void
return void

Property Details

isDead public_oe property

public Boolean,System isDead
return System.Boolean