Skip to content

Commit

Permalink
Add the anims as parameters of the Player class
Browse files Browse the repository at this point in the history
  • Loading branch information
timotei committed Sep 13, 2011
1 parent 31d3bcc commit a067b16
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
19 changes: 10 additions & 9 deletions egp_story/Levels/DarkvilleFarmsLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ public class DarkvilleFarmsLevel : IStoryLevel

public DarkvilleFarmsLevel( )
{
_player = new Player( CardinalDirection.EAST );

_player.AttackEastAnim = new AnimatedSprite( Assets.SilverboltShootEast, 10, 10 );
_player.AttackSouthAnim = new AnimatedSprite( Assets.SilverboltShootSouth, 10, 10 );
_player.AttackNorthAnim = new AnimatedSprite( Assets.SilverboltShootNorth, 10, 10 );

_player.WalkEastAnim = new AnimatedSprite( Assets.SilverboltWalkEast, 2, 10 );
_player.WalkSouthAnim = new AnimatedSprite( Assets.SilverboltWalkSouth, 2, 10 );
_player.WalkNorthAnim = new AnimatedSprite( Assets.SilverboltWalkNorth, 2, 10 );
_player = new Player( CardinalDirection.EAST,
new[] {
new AnimatedSprite( Assets.SilverboltShootNorth, 10, 10 ),
new AnimatedSprite( Assets.SilverboltShootSouth, 10, 10 ),
new AnimatedSprite( Assets.SilverboltShootEast, 10, 10 ) },
new[] {
new AnimatedSprite( Assets.SilverboltWalkNorth, 2, 10 ),
new AnimatedSprite( Assets.SilverboltWalkSouth, 2, 10 ),
new AnimatedSprite( Assets.SilverboltWalkEast, 2, 10 )}
);
}

public void Update( GameTime gameTime )
Expand Down
19 changes: 18 additions & 1 deletion egp_story/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,25 @@ public class Player : IUpdateable, IDrawable

public AnimatedSprite CurrentAnimation { get; set; }

public Player( CardinalDirection initialFacingDirection )
/// <summary>
///
/// </summary>
/// <param name="initialFacingDirection"></param>
/// <param name="attackAnims">The order of the animations: North, South, East</param>
/// <param name="walkAnims">The order of the animations: North, South, East</param>
public Player( CardinalDirection initialFacingDirection, AnimatedSprite[] attackAnims,
AnimatedSprite[] walkAnims )
{
AttackNorthAnim = attackAnims[0];
AttackSouthAnim = attackAnims[1];
AttackEastAnim = attackAnims[2];

WalkNorthAnim = walkAnims[0];
WalkSouthAnim = walkAnims[1];
WalkEastAnim = walkAnims[2];

FacingDirection = initialFacingDirection;
ReplaceCurrentAnimation( );
}

private void ReplaceCurrentAnimation( )
Expand Down

0 comments on commit a067b16

Please sign in to comment.