abstract Target add
This commit is contained in:
parent
4d8172f3bd
commit
1c56378003
17 changed files with 68 additions and 51 deletions
|
@ -62,7 +62,7 @@
|
|||
</object>
|
||||
</objectgroup>
|
||||
<objectgroup id="5" name="Zombies" class="LivingEntities.Monsters.Spider">
|
||||
<object id="4" x="-80" y="100">
|
||||
<object id="4" x="-50" y="200">
|
||||
<point/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
public abstract class CoreEnemy : LivingEntity
|
||||
{
|
||||
protected int monster_health;
|
||||
protected int monster_speed;
|
||||
protected float monster_speed;
|
||||
protected string name;
|
||||
protected bool isAlive = true;
|
||||
protected int leftBoarder = 0;
|
||||
|
@ -45,5 +45,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
|
|||
isAlive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void Target();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
Width = 62;
|
||||
Height = 40;
|
||||
monster_speed = 3;
|
||||
monster_speed = 0.25f;
|
||||
name = "Skull";
|
||||
acceleration = Vector2.Zero;
|
||||
}
|
||||
|
@ -63,19 +63,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
velocity.X = -monster_speed;
|
||||
}
|
||||
if (Pos.X >= rightBoarder)
|
||||
{
|
||||
isGoRight = false;
|
||||
}
|
||||
else if (Pos.X <= leftBoarder)
|
||||
{
|
||||
isGoRight = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Attack(GameTime gameTime)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public override void Target()
|
||||
{
|
||||
if (true)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
velocity.Y -= monster_speed;
|
||||
}
|
||||
}
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
@ -129,9 +129,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
Debug.WriteLine("Collision");
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,9 +62,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
|
|
|
@ -111,9 +111,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
protected SpiderWeb web;
|
||||
protected float delay;
|
||||
protected int webLength;
|
||||
protected int widthS;
|
||||
protected bool isDown;
|
||||
protected bool isDownUp;
|
||||
protected PhysicsManager physicsManager;
|
||||
protected Player player;
|
||||
protected Vector2 oldPosition;
|
||||
|
||||
public Spider(Vector2 position) : base(position)
|
||||
{
|
||||
|
@ -30,10 +32,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
isDownUp = true;
|
||||
isDown = true;
|
||||
physicsManager = AppManager.Instance.GameManager.physicsManager;
|
||||
web = new SpiderWeb(Pos);
|
||||
name = "Spider";
|
||||
Width = 112;
|
||||
Height = 24;
|
||||
widthS = Width;
|
||||
web = new SpiderWeb(new Vector2(Pos.X+Width/2,Pos.Y));
|
||||
delay = 0;
|
||||
webLength = 0;
|
||||
monster_speed = 3;
|
||||
|
@ -45,7 +48,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (!isAttack)
|
||||
if (isAttack == false)
|
||||
{
|
||||
Move(gameTime);
|
||||
}
|
||||
|
@ -68,12 +71,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
/// </summary>
|
||||
/// <param name="gameTime"></param>
|
||||
public override void Attack(GameTime gameTime)
|
||||
{ //48 72
|
||||
velocity.X = 0;
|
||||
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
{
|
||||
if (isAttack)
|
||||
{
|
||||
if (delay > 0.5 && webLength <= 4 && isDown)
|
||||
velocity.X = 0;
|
||||
delay += (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||
|
||||
if (delay > 0.25 && webLength <= 4 && isDown)
|
||||
{
|
||||
Width = 48;
|
||||
Height = 72;
|
||||
|
@ -104,22 +108,19 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
isDown = true;
|
||||
}
|
||||
}
|
||||
var entitiesInter = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, 200, 600));
|
||||
if (entitiesInter.Count > 0)
|
||||
{
|
||||
foreach (var entity in entitiesInter)
|
||||
{
|
||||
if (entity.GetType() == typeof(Player))
|
||||
{
|
||||
player.Death(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (webLength == 0)
|
||||
{
|
||||
isAttack = false;
|
||||
}
|
||||
var entities = physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height + 200));
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
if (webLength == 4 && entity is Player)
|
||||
{
|
||||
AppManager.Instance.GameManager.players[0].Death(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
|
@ -169,12 +170,24 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
}
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
if (player.Pos.X >= Pos.X && player.Pos.X <= Pos.X+Width)
|
||||
{
|
||||
isAttack = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnCollision(GameObject gameObject)
|
||||
{
|
||||
if (gameObject is Player)
|
||||
{
|
||||
if (AppManager.Instance.GameManager.players[0].IsAlive)
|
||||
{
|
||||
Attack();
|
||||
}
|
||||
}
|
||||
base.OnCollision(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
public SpiderWeb(Vector2 position) : base(position)
|
||||
{
|
||||
name = "Web";
|
||||
monster_speed = 1;
|
||||
Width = 16;
|
||||
Height = 0;
|
||||
acceleration = Vector2.Zero;
|
||||
|
@ -43,9 +42,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
{
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
|||
base.OnCollision(gameObject);
|
||||
}
|
||||
|
||||
public void Target()
|
||||
public override void Target()
|
||||
{
|
||||
if (AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X - 50, (int)Pos.Y, Width + 100, Height), typeof(Player)).Count > 0)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,10 @@ public abstract class LivingEntity : Entity
|
|||
//}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="animationName"></param>
|
||||
public virtual void StartCicycleAnimation(string animationName)
|
||||
{
|
||||
if (GraphicsComponent.GetCurrentAnimation != animationName)
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace DangerousD.GameCore
|
|||
case GameState.Lobby:
|
||||
break;
|
||||
case GameState.Game:
|
||||
GameManager.mapManager.LoadLevel("lvl");
|
||||
GameManager.mapManager.LoadLevel("map");
|
||||
GameManager.FindBorders();
|
||||
break;
|
||||
case GameState.Death:
|
||||
|
|
Loading…
Add table
Reference in a new issue