Prepare for Merge

This commit is contained in:
MARKPRO44 2023-08-18 13:54:31 +03:00
parent 89ae555102
commit 323932e945
7 changed files with 165 additions and 13 deletions

View 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"}

View file

@ -0,0 +1 @@
{"id":"HunchmanMoveRight","textureName":"MonstersAnimations","startSpriteRectangle":{"X":1,"Y":100,"Width":24,"Height":23},"frameSecond":[{"Item1":0,"Item2":10}],"textureFrameInterval":1,"framesCount":4,"isCycle":true,"offset":"0, 0"}

View file

@ -42,7 +42,7 @@
</data> </data>
</layer> </layer>
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull"> <objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull">
<object id="1" x="-56" y="80"> <object id="1" x="400" y="1000">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>
@ -51,8 +51,8 @@
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>
<objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Frank"> <objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Hunchman">
<object id="3" x="-53" y="158"> <object id="3" x="300" y="230">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>

25
DangerousD/DangerousD.sln Normal file
View file

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1705.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DangerousD", "DangerousD.csproj", "{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A51FB3C2-D16C-42DF-B65A-6EC67AF07506}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F6C9C555-FA45-4C6A-BEB3-8352B2653CB0}
EndGlobalSection
EndGlobal

View file

@ -4,45 +4,144 @@ 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;
using DangerousD.GameCore.Managers;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public class Hunchman : CoreEnemy public class Hunchman : CoreEnemy
{ {
private bool isGoRight = true; private bool isGoRight = false;
private bool isAttaking = false;
private bool isTarget = false;
private bool isVisible = true;
float leftBoarder;
float rightBoarder;
PhysicsManager physicsManager;
public Hunchman(Vector2 position) : base(position) public Hunchman(Vector2 position) : base(position)
{ {
Width = 20; Width = 20;
Height = 30; Height = 30;
leftBoarder = (int)position.X - 100;
rightBoarder = (int)position.X + 100;
name = "Hunchman"; name = "Hunchman";
GraphicsComponent.StartAnimation(""); GraphicsComponent.StartAnimation("HunchmanMoveLeft");
monster_speed = 3; monster_speed = 3;
physicsManager = new PhysicsManager();
} }
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", "HunchmanDaggerLeft", "HunchmanDaggerRight" }, "HunchmanMoveLeft");
public override void Update(GameTime gameTime)
{
if (!isAttaking)
{
Target();
Move(gameTime);
}
base.Update(gameTime);
}
public override void Attack() public override void Attack()
{ {
var animation = GraphicsComponent.GetCurrentAnimation;
isAttaking = true;
if (isGoRight)
{
if (animation != "HunchmanDaggerRight")
{
GraphicsComponent.StartAnimation("HunchmanDaggerRight");
}
}
else
{
if (animation != "HunchmanDaggerLeft")
{
GraphicsComponent.StartAnimation("HunchmanDaggerLeft");
}
}
} }
public override void Death() public override void Death()
{ {
if (monster_health <= 0)
{
isVisible = false;
}
} }
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
var player = AppManager.Instance.GameManager.players[0]; velocity.X = 0;
if(player.Pos.X > 0) var animation = GraphicsComponent.GetCurrentAnimation;
if (isGoRight)
{ {
if (animation != "HunchmanMoveRight")
{
GraphicsComponent.StartAnimation("HunchmanMoveRight");
}
velocity.X = monster_speed;
}
else
{
if (animation != "HunchmanMoveLeft")
{
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
}
velocity.X = -monster_speed;
}
if (_pos.X >= rightBoarder)
{
isGoRight = false;
}
else if (_pos.X <= leftBoarder)
{
isGoRight = true;
}
}
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
if (AppManager.Instance.GameManager.players[0].IsAlive)
{
Attack();
}
}
base.OnCollision(gameObject);
}
public void Target()
{
var player = AppManager.Instance.GameManager.players[0];
if (physicsManager.RayCast(this, player) == null)
{
if(this._pos.X <= player.Pos.X)
{
isTarget = true;
leftBoarder = Pos.X - 10;
rightBoarder = player.Pos.X;
}
else if(this._pos.X >= player.Pos.X)
{
isTarget = true;
rightBoarder = Pos.X + 10;
leftBoarder = player.Pos.X;
}
}
}
} }
} }
}
}

View file

@ -12,10 +12,12 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{ {
public class HunchmanDagger : CoreEnemy public class HunchmanDagger : CoreEnemy
{ {
private bool isGoRight = false;
public HunchmanDagger(Vector2 position) : base(position) public HunchmanDagger(Vector2 position) : base(position)
{ {
name = "Hunchman"; name = "Hunchman";
monster_speed = 1; monster_speed = 4;
Width = 9; Width = 9;
Height = 6; Height = 6;
} }
@ -34,7 +36,31 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime) public override void Move(GameTime gameTime)
{ {
velocity.X = 0;
var animation = GraphicsComponent.GetCurrentAnimation;
if (animation == "HunchmanDaggerRight")
{
velocity.X = monster_speed;
}
else if (animation == "HunchmanDaggerLeft")
{
velocity.X = -monster_speed;
}
}
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
AppManager.Instance.GameManager.players[0].Death(name);
}
else
{
Death();
}
base.OnCollision(gameObject);
} }
} }
} }