fixesAdnSomeHunchManAdditions
This commit is contained in:
parent
d34f541a7d
commit
b9d259bfa0
3 changed files with 86 additions and 17 deletions
|
@ -4,7 +4,9 @@ using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Authentication.ExtendedProtection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -12,51 +14,104 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Hunchman : CoreEnemy
|
public class Hunchman : CoreEnemy
|
||||||
{
|
{
|
||||||
|
GameManager gameManager;
|
||||||
|
bool isAttacking;
|
||||||
public Hunchman(Vector2 position) : base(position)
|
public Hunchman(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
Width = 72;
|
Width = 48;
|
||||||
Height = 72;
|
Height = 48;
|
||||||
monster_speed = 5;
|
monster_speed = -2;
|
||||||
|
monster_health = 1;
|
||||||
name = "HunchMan";
|
name = "HunchMan";
|
||||||
velocity = new Vector2(monster_speed, 0);
|
velocity = new Vector2(monster_speed, 0);
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
isAttacking = false;
|
||||||
|
isAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
|
||||||
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveRight");
|
{ "HunchmanMoveLeft", "HunchmanMoveRight", "HunchmanAttackLeft", "HunchmanAttackRight" }, "HunchmanMoveLeft");
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
Move(gameTime);
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
|
||||||
|
if (!isAttacking)
|
||||||
|
{
|
||||||
|
Attack();
|
||||||
|
Move(gameTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
Death();
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Attack()
|
public override void Attack()
|
||||||
{
|
{
|
||||||
|
GameObject gameObject;
|
||||||
|
foreach (var player in gameManager.players)
|
||||||
|
{
|
||||||
|
if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height)
|
||||||
|
{
|
||||||
|
gameObject = gameManager.physicsManager.RayCast(this, player);
|
||||||
|
if (gameObject is null)
|
||||||
|
{
|
||||||
|
isAttacking = true;
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackRight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanAttackLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanAttackLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Death()
|
public override void Death()
|
||||||
{
|
{
|
||||||
|
if (monster_health <= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
velocity.X = monster_speed;
|
||||||
if (velocity.X > 0)
|
if (velocity.X > 0)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
|
||||||
|
{
|
||||||
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (velocity.X < 0)
|
else if (velocity.X < 0)
|
||||||
{
|
{
|
||||||
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
|
||||||
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnCollision()
|
public override void OnCollision(GameObject gameObject)
|
||||||
{
|
{
|
||||||
monster_speed *= -1;
|
monster_speed *= -1;
|
||||||
|
_pos.X += 5 * monster_speed;
|
||||||
|
Debug.WriteLine("Collision");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
using DangerousD.GameCore.Graphics;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
{
|
||||||
|
class Knife : Entity
|
||||||
|
{
|
||||||
|
public Knife(Vector2 position) : base(position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override GraphicsComponent GraphicsComponent => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,17 +10,12 @@ namespace DangerousD.GameCore.Levels
|
||||||
{
|
{
|
||||||
public void InitLevel()
|
public void InitLevel()
|
||||||
{
|
{
|
||||||
new Player(new Vector2(0,0));
|
new Player(new Vector2(50,100));
|
||||||
|
|
||||||
var Zombie = new Zombie(new Vector2(140, 128));
|
var Zombie = new Zombie(new Vector2(140, 128));
|
||||||
var Frank = new Frank(new Vector2(384, 128));
|
|
||||||
var Spider = new Spider(new Vector2(112, 0));
|
|
||||||
var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
|
||||||
var Werewolf = new Werewolf(new Vector2(640, 0));
|
|
||||||
var Ghost = new Ghost(new Vector2(730, 0));
|
|
||||||
var FrankBalls = new FrankBalls(new Vector2(Frank.Pos.X, Frank.Pos.Y));
|
|
||||||
var HunchMan = new Hunchman(new Vector2(100, 100));
|
|
||||||
|
|
||||||
|
var HunchMan = new Hunchman(new Vector2(300, 100));
|
||||||
//Spider down-up
|
//Spider down-up
|
||||||
|
|
||||||
new GrassBlock(new Vector2(0, 224));
|
new GrassBlock(new Vector2(0, 224));
|
||||||
|
|
Loading…
Add table
Reference in a new issue