StartSomething

This commit is contained in:
polten0 2023-08-17 11:18:22 +03:00
parent 7b16ad9543
commit 38257457a9
3 changed files with 31 additions and 3 deletions

View file

@ -1 +1 @@
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"} {"id":"HunchmanAttackRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":99,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}

View file

@ -14,9 +14,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public Hunchman(Vector2 position) : base(position) public Hunchman(Vector2 position) : base(position)
{ {
Width = 72;
Height = 72;
monster_speed = 5;
name = "HunchMan";
velocity = new Vector2(monster_speed, 0);
} }
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight"); protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
public override void Update(GameTime gameTime)
{
Move(gameTime);
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
@ -30,7 +42,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
if (velocity.X > 0)
{
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
GraphicsComponent.StartAnimation("HunchmanMoveRight");
}
else if (velocity.X < 0)
{
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
GraphicsComponent.StartAnimation("HunchmanMoveRight");
}
}
public override void OnCollision()
{
monster_speed *= -1;
} }
} }
} }

View file

@ -11,7 +11,7 @@ namespace DangerousD.GameCore.Levels
public void InitLevel() public void InitLevel()
{ {
new Player(new Vector2(0,0)); new Player(new Vector2(0,0));
/*
var Spider = new Spider(new Vector2(112, 0)); var Spider = new Spider(new Vector2(112, 0));
var Zombie = new Zombie(new Vector2(256, 0)); var Zombie = new Zombie(new Vector2(256, 0));
var Frank = new Frank(new Vector2(384, 0)); var Frank = new Frank(new Vector2(384, 0));
@ -19,6 +19,8 @@ namespace DangerousD.GameCore.Levels
var Werewolf = new Werewolf(new Vector2(640, 0)); var Werewolf = new Werewolf(new Vector2(640, 0));
var Ghost = new Ghost(new Vector2(730, 0)); var Ghost = new Ghost(new Vector2(730, 0));
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y)); var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
*/
var HunchMan = new Hunchman(new Vector2(100, 100));
//Spider down-up //Spider down-up