added player death
This commit is contained in:
parent
f7ef5e835b
commit
adc2d44243
4 changed files with 13 additions and 8 deletions
|
@ -20,6 +20,9 @@ namespace DangerousD.GameCore.GameObjects.PlayerDeath
|
|||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> {"DeathFromZombie"},
|
||||
"DeathFromZombie");
|
||||
|
||||
public GraphicsComponent Gr => GraphicsComponent;
|
||||
|
||||
private void PlayDeath(string deathName)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "DeathFromZombie")
|
||||
|
|
|
@ -16,10 +16,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
{
|
||||
Width = 32;
|
||||
Height = 64;
|
||||
/*GraphicsComponent.actionOfAnimationEnd += () =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
||||
};*/
|
||||
}
|
||||
public bool IsAlive { get { return isAlive; } }
|
||||
|
||||
|
@ -35,7 +31,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
if(monsterName == "Zombie")
|
||||
{
|
||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||
//GraphicsComponent.actionOfAnimationEnd();
|
||||
deathRectangle.Gr.actionOfAnimationEnd += (a) =>
|
||||
{
|
||||
if (a == "DeathFrom" + monsterName)
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
||||
}
|
||||
};
|
||||
}
|
||||
isAlive = false;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace DangerousD.GameCore.Graphics
|
|||
|
||||
public class GraphicsComponent
|
||||
{
|
||||
public Action<string> actionOfAnimationEnd;
|
||||
public event Action<string> actionOfAnimationEnd;
|
||||
private List<AnimationContainer> animations;
|
||||
private List<Texture2D> textures;
|
||||
private List<string> texturesNames;
|
||||
|
@ -29,13 +29,11 @@ namespace DangerousD.GameCore.Graphics
|
|||
private int interval;
|
||||
private int lastInterval;
|
||||
private Rectangle sourceRectangle;
|
||||
|
||||
public GraphicsComponent(List<string> animationsId, string neitralAnimationId)
|
||||
{
|
||||
//this._spriteBatch = _spriteBatch;
|
||||
currentFrame = 0;
|
||||
lastInterval = 1;
|
||||
|
||||
LoadAnimations(animationsId, neitralAnimationId);
|
||||
currentAnimation = neitralAnimation;
|
||||
SetInterval();
|
||||
|
|
|
@ -162,6 +162,8 @@ namespace DangerousD.GameCore
|
|||
case GameState.Game:
|
||||
GameManager.mapManager.LoadLevel("");
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue