FrankBall_2
This commit is contained in:
parent
044f2f410e
commit
c35f288fba
5 changed files with 49 additions and 10 deletions
BIN
DangerousD/GameCore/.DS_Store
vendored
Normal file
BIN
DangerousD/GameCore/.DS_Store
vendored
Normal file
Binary file not shown.
|
@ -15,6 +15,8 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
private Rectangle collision;
|
||||
private Vector2 position;
|
||||
private int healthBall;
|
||||
private bool isFlyRight = true;
|
||||
private bool isAttacking = false;
|
||||
|
||||
public Rectangle Collision
|
||||
{
|
||||
|
@ -27,16 +29,36 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
name = "FrankBalls";
|
||||
Width = 40;
|
||||
Height = 40;
|
||||
monster_speed = 1;
|
||||
monster_speed = 3;
|
||||
acceleration = Vector2.Zero;
|
||||
}
|
||||
|
||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if(!isAttacking)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Attack()
|
||||
{
|
||||
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
|
||||
|
||||
isAttacking = true;
|
||||
|
||||
if(isFlyRight)
|
||||
{
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
else if(!isFlyRight)
|
||||
{
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Death()
|
||||
|
@ -46,7 +68,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Move(GameTime gameTime)
|
||||
{
|
||||
|
||||
velocity.X = 0;
|
||||
velocity.Y = 0;
|
||||
|
||||
if(isFlyRight)
|
||||
{
|
||||
velocity.X += monster_speed;
|
||||
velocity.Y += monster_speed;
|
||||
}
|
||||
else if(!isFlyRight)
|
||||
{
|
||||
velocity.X -= monster_speed;
|
||||
velocity.Y -= monster_speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
isAttaking = true;
|
||||
if (isGoRight)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieMoveRight")
|
||||
if (GraphicsComponent.GetCurrentAnimation != "ZombieRightAttack")
|
||||
{
|
||||
GraphicsComponent.StartAnimation("ZombieAttackRight");
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
{
|
||||
Width = 32;
|
||||
Height = 64;
|
||||
GraphicsComponent.actionOfAnimationEnd += () =>
|
||||
GraphicsComponent.actionOfAnimationEnd += (a) =>
|
||||
{
|
||||
AppManager.Instance.ChangeGameState(GameState.GameOver);
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
if(monsterName == "Zombie")
|
||||
{
|
||||
DeathRectangle deathRectangle = new DeathRectangle(Pos, "DeathFrom" + monsterName);
|
||||
GraphicsComponent.actionOfAnimationEnd();
|
||||
GraphicsComponent.actionOfAnimationEnd("0");
|
||||
}
|
||||
isAlive = false;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,17 @@ namespace DangerousD.GameCore
|
|||
|
||||
public void LoadSounds() // метод для загрузки звуков из папки
|
||||
{
|
||||
string[] soundFiles = Directory.GetFiles("../../../Content").Where(x=>x.EndsWith("mp3")).Select(x=>x.Split("\\").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
|
||||
foreach (var soundFile in soundFiles)
|
||||
var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
|
||||
if (k.Count()>0)
|
||||
{
|
||||
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(soundFile).CreateInstance());
|
||||
}
|
||||
|
||||
string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
|
||||
foreach (var soundFile in soundFiles)
|
||||
{
|
||||
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(soundFile).CreateInstance());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции
|
||||
|
|
Loading…
Add table
Reference in a new issue