Merge pull request #5 from progtime-net/livingEntitiesHunchMan
Merge Hunchman
This commit is contained in:
commit
8d6e3e6ba7
6 changed files with 104 additions and 7 deletions
1
DangerousD/Content/animations/HunchmanAttackLeft
Normal file
1
DangerousD/Content/animations/HunchmanAttackLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanAttackLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":101,"Y":124,"Width":40,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":3,"isCycle":true,"offset":"0, 0"}
|
1
DangerousD/Content/animations/HunchmanAttackRight
Normal file
1
DangerousD/Content/animations/HunchmanAttackRight
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"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"}
|
1
DangerousD/Content/animations/HunchmanMoveLeft
Normal file
1
DangerousD/Content/animations/HunchmanMoveLeft
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"HunchmanMoveLeft","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":124,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
|
@ -1 +1,3 @@
|
||||||
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":12}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
|
||||||
|
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":99,"Width":24,"Height":24},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}
|
||||||
|
|
||||||
|
|
|
@ -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,25 +14,114 @@ 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 = 48;
|
||||||
|
Height = 48;
|
||||||
|
monster_speed = -2;
|
||||||
|
monster_health = 1;
|
||||||
|
name = "HunchMan";
|
||||||
|
velocity = new Vector2(monster_speed, 0);
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
isAttacking = false;
|
||||||
|
isAlive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
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" }, "HunchmanMoveLeft");
|
||||||
|
|
||||||
|
public override void Update(GameTime gameTime)
|
||||||
|
{
|
||||||
|
// P.S. Всё в классе можешь смело удалять и переписывать с нуля.
|
||||||
|
gameManager = AppManager.Instance.GameManager;
|
||||||
|
|
||||||
|
if (!isAttacking)
|
||||||
|
{
|
||||||
|
Attack();
|
||||||
|
Move(gameTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.X = 0;
|
||||||
|
}
|
||||||
|
Death();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
GraphicsComponent.StopAnimation();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
velocity.X = monster_speed;
|
||||||
|
|
||||||
|
if (velocity.X > 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveRight");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (velocity.X < 0)
|
||||||
|
{
|
||||||
|
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
|
||||||
|
{
|
||||||
|
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnCollision(GameObject gameObject)
|
||||||
|
{
|
||||||
|
monster_speed *= -1;
|
||||||
|
_pos.X += 5 * monster_speed;
|
||||||
|
Debug.WriteLine("Collision");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,10 @@ namespace DangerousD.GameCore.Levels
|
||||||
{
|
{
|
||||||
public void InitLevel()
|
public void InitLevel()
|
||||||
{
|
{
|
||||||
|
|
||||||
new Player(new Vector2(350,0));
|
new Player(new Vector2(350,0));
|
||||||
var Zombie = new Zombie(new Vector2(100, 128));
|
var Zombie = new Zombie(new Vector2(100, 128));
|
||||||
|
|
||||||
//var Frank = new Frank(new Vector2(384, 128));
|
//var Frank = new Frank(new Vector2(384, 128));
|
||||||
//var Spider = new Spider(new Vector2(112, 0));
|
//var Spider = new Spider(new Vector2(112, 0));
|
||||||
//var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
//var FlameSkull = new FlameSkull(new Vector2(512, 0));
|
||||||
|
@ -20,16 +22,15 @@ namespace DangerousD.GameCore.Levels
|
||||||
//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 SilasHand = new SilasHands(new Vector2(200,64));
|
//var SilasHand = new SilasHands(new Vector2(200,64));
|
||||||
//var SilasMaster = new SilasMaster(new Vector2(400, 64));
|
//var SilasMaster = new SilasMaster(new Vector2(400, 64));
|
||||||
|
|
||||||
|
var HunchMan = new Hunchman(new Vector2(300, 100));
|
||||||
|
|
||||||
new GrassBlock(new Vector2(0, 224));
|
new GrassBlock(new Vector2(0, 224));
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
new GrassBlock(new Vector2(i*32, 256));
|
new GrassBlock(new Vector2(i*32, 256));
|
||||||
}
|
}
|
||||||
new GrassBlock(new Vector2(500, 224));
|
new GrassBlock(new Vector2(500, 224));
|
||||||
Player player = new Player(new Vector2(400, 64));
|
|
||||||
player.Jump();
|
|
||||||
|
|
||||||
//new GrassBlock(new Vector2(500, 224));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue