Maiu Merge Hunchman

This commit is contained in:
MARKPRO44 2023-08-18 18:20:45 +03:00
commit 38f1064ec4
16 changed files with 212 additions and 91 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -2,8 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View file

@ -2,7 +2,6 @@
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
using System;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
@ -17,13 +16,6 @@ namespace AnimationsFileCreator
Console.WriteLine("Добро пожаловать в костыльную программу по созданию файлов анимации для игры DungerousD");
Console.Write("Введите название текстуры (нажмите enter, чтобы выбрать файл во всплывающем окошке): ");
string textureName = Console.ReadLine();
if (textureName == "")
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
textureName = dialog.FileName.Split('\\').Last();
textureName = textureName.Split('.')[0];
}
Console.WriteLine("Введите количество кадров анимации: ");
int framesCount = int.Parse(Console.ReadLine());
Console.WriteLine("Введите длительность кадра в анимации: ");

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

@ -734,7 +734,7 @@
</object>
</objectgroup>
<objectgroup id="10" name="Player" class="LivingEntities.Player">
<object id="47" x="-500" y="461.333">
<object id="47" x="0" y="461.333">
<point/>
</object>
</objectgroup>

View file

@ -1,3 +1,64 @@
<<<<<<< HEAD
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="200" height="200" tilewidth="16" tileheight="16" infinite="1" nextlayerid="5" nextobjectid="5">
<tileset firstgid="1" source="../Desktop/DangerousD map/map.tsx"/>
<layer id="1" name="Слой тайлов 1" class="StopTile" width="200" height="200">
<data encoding="csv">
<chunk x="-16" y="0" width="16" height="16">
294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294
</chunk>
<chunk x="0" y="0" width="16" height="16">
294,294,294,294,294,321,321,321,321,321,321,321,321,321,321,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,321,321,321,321,321,321,321,321,321,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,321,
294,294,294,294,321,321,321,321,321,321,321,321,321,321,321,321
</chunk>
</data>
</layer>
<objectgroup id="2" name="Слой объектов 1" class="LivingEntities.Monsters.FlameSkull">
<object id="1" x="400" y="1000">
<point/>
</object>
</objectgroup>
<objectgroup id="3" name="Слой объектов 2" class="LivingEntities.Monsters.FrankBalls">
<object id="2" x="-162" y="160">
<point/>
</object>
</objectgroup>
<objectgroup id="4" name="Слой объектов 3" class="LivingEntities.Monsters.Hunchman">
<object id="3" x="300" y="230">
<point/>
</object>
</objectgroup>
</map>
=======
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="left-up" width="200" height="200" tilewidth="16" tileheight="16" infinite="1" nextlayerid="5" nextobjectid="5">
<tileset firstgid="1" source="../Desktop/DangerousD map/map.tsx"/>
@ -73,3 +134,4 @@
</objectgroup>
</map>
>>>>>>> main

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

@ -38,6 +38,12 @@ namespace DangerousD.GameCore
{
}
protected int obsticles = 0;
public virtual void OnCollisionWithObsticle(GameObject gameObject)
{
obsticles++;//SD
}
public virtual void Initialize()
{
}
@ -53,6 +59,7 @@ namespace DangerousD.GameCore
public virtual void Update(GameTime gameTime)
{
obsticles = 0;
GraphicsComponent.Update();
}

View file

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.GameObjects.MapObjects;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
@ -17,21 +18,21 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
private bool isFlyRight = true;
private bool isFlyUp = true;
private bool isAttacking = false;
public Rectangle Collision
{
get { return collision; }
}
public FrankBalls(Vector2 position) : base(position)
public FrankBalls(Vector2 position) : base(new Vector2(300, 200))
{
this.position = position;
name = "FrankBalls";
Width = 40;
Height = 40;
monster_speed = 3;
velocity = new Vector2(3,-3);
acceleration = Vector2.Zero;
velocity = new Vector2(monster_speed, monster_speed);
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
@ -65,7 +66,6 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Move(GameTime gameTime)
{
var getColsHor = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2));
var getColsVer= AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y + Height / 2 - 2, 50, 2)); ;
if (isFlyRight)

View file

@ -9,129 +9,126 @@ using System.Linq;
using System.Security.Authentication.ExtendedProtection;
using System.Text;
using System.Threading.Tasks;
using DangerousD.GameCore.Managers;
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class Hunchman : CoreEnemy
{
GameManager gameManager;
bool isAttacking;
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)
{
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;
Width = 20;
Height = 30;
leftBoarder = (int)position.X - 100;
rightBoarder = (int)position.X + 100;
name = "Hunchman";
GraphicsComponent.StartAnimation("HunchmanMoveLeft");
monster_speed = 3;
physicsManager = new PhysicsManager();
}
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string>
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)
if (!isAttaking)
{
Attack();
Target();
Move(gameTime);
}
else
{
velocity.X = 0;
}
Death();
base.Update(gameTime);
}
public override void Attack()
{
GameObject gameObject;
foreach (var player in gameManager.players)
var animation = GraphicsComponent.GetCurrentAnimation;
isAttaking = true;
if (isGoRight)
{
if (player.Pos.Y + player.Height >= Pos.Y && player.Pos.Y <= Pos.Y + Height)
if (animation != "HunchmanAttackRight")
{
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");
}
}
}
GraphicsComponent.StartAnimation("HunchmanAttackRight");
}
HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos,isGoRight);
}
else
{
if (animation != "HunchmanAttackLeft")
{
GraphicsComponent.StartAnimation("HunchmanAttackLeft");
}
HunchmanDagger hunchmanDagger = new HunchmanDagger(Pos, isGoRight);
}
}
public override void Attack(GameTime gameTime)
{
}
{}
public override void Death()
{
for (int i = 0; i < 3; i++)
{
Particle particle = new Particle(Pos);
}
if (monster_health <= 0)
{
isVisible = false;
}
}
public override void Move(GameTime gameTime)
{
if (gameManager.physicsManager.RayCast(this, new Vector2(Pos.X + Width + 10, Pos.Y + Height)) is not null)
velocity.X = 0;
var animation = GraphicsComponent.GetCurrentAnimation;
if (isGoRight)
{
monster_speed *= -1;
}
velocity.X = monster_speed;
if (velocity.X > 0)
{
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveRight")
if (animation != "HunchmanMoveRight")
{
GraphicsComponent.StartAnimation("HunchmanMoveRight");
}
velocity.X = monster_speed;
}
else if (velocity.X < 0)
else
{
if (GraphicsComponent.GetCurrentAnimation != "HunchmanMoveLeft")
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)
{
monster_speed *= -1;
_pos.X += 5 * monster_speed;
Debug.WriteLine("Collision");
}
public void Target()
{
throw new NotImplementedException();
var player = AppManager.Instance.GameManager.players[0];
if (physicsManager.RayCast(this, player) == null)
{
Attack();
}
}
}
}
}

View file

@ -12,10 +12,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
{
public class HunchmanDagger : CoreEnemy
{
public HunchmanDagger(Vector2 position) : base(position)
private bool isGoRight = false;
public HunchmanDagger(Vector2 position, bool isGoRight) : base(position)
{
this.isGoRight = isGoRight;
name = "Hunchman";
monster_speed = 1;
monster_speed = 4;
Width = 9;
Height = 6;
}
@ -34,12 +37,46 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
public override void Death()
{
AppManager.Instance.GameManager.Remove(this);
}
public override void Move(GameTime gameTime)
{
velocity.X = 0;
var getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle(0, 0, 0, 0));
if (isGoRight)
{
StartCicycleAnimation("HunchmanDaggerRight");
velocity.X = monster_speed;
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X, (int)Pos.Y, Width+5, Height));
if(getCols.Count>0)
{
Death();
}
}
else if (!isGoRight)
{
StartCicycleAnimation("HunchmanDaggerLeft");
velocity.X = -monster_speed;
getCols = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)Pos.X-5, (int)Pos.Y, Width + 5, Height));
if (getCols.Count > 0)
{
Death();
}
}
}
public override void OnCollision(GameObject gameObject)
{
if (gameObject is Player)
{
AppManager.Instance.GameManager.players[0].Death(name);
}
base.OnCollision(gameObject);
}
public void Target()

View file

@ -236,7 +236,7 @@ namespace DangerousD.GameCore.Graphics
private void SetInterval()
{
Tuple<int, int> i = currentAnimation.FrameTime.Find(x => x.Item1 == currentFrame);
Tuple<int, int> i = currentAnimation.FrameTime.Find(x => x.Item1 == currentFrame);
if (i != null)
{
interval = i.Item2;

View file

@ -49,6 +49,7 @@ namespace DangerousD.GameCore
internal void Register(GameObject gameObject)
{
GetAllGameObjects.Add(gameObject);
if (gameObject is Entity)
{
gameObject.id = currentEntityId;

View file

@ -68,7 +68,7 @@ namespace DangerousD.GameCore.Managers
{
if (tiles[i] != 0)
{
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale,
Vector2 pos = new(((chunkX+ i % chunkW) * tileSize.X + offsetX) * _scale + 400,
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
//pos *= _scale;
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());

View file

@ -135,7 +135,6 @@ namespace DangerousD.GameCore.Managers
player.isOnGround = true;
player.velocity.Y = 0;
}
player.SetPosition(new Vector2(newRect.X, newRect.Y));
}