Huchman_1
This commit is contained in:
parent
8e464223de
commit
89ae555102
11 changed files with 115 additions and 34 deletions
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
|
@ -17,13 +16,6 @@ namespace AnimationsFileCreator
|
||||||
Console.WriteLine("Добро пожаловать в костыльную программу по созданию файлов анимации для игры DungerousD");
|
Console.WriteLine("Добро пожаловать в костыльную программу по созданию файлов анимации для игры DungerousD");
|
||||||
Console.Write("Введите название текстуры (нажмите enter, чтобы выбрать файл во всплывающем окошке): ");
|
Console.Write("Введите название текстуры (нажмите enter, чтобы выбрать файл во всплывающем окошке): ");
|
||||||
string textureName = Console.ReadLine();
|
string textureName = Console.ReadLine();
|
||||||
if (textureName == "")
|
|
||||||
{
|
|
||||||
OpenFileDialog dialog = new OpenFileDialog();
|
|
||||||
dialog.ShowDialog();
|
|
||||||
textureName = dialog.FileName.Split('\\').Last();
|
|
||||||
textureName = textureName.Split('.')[0];
|
|
||||||
}
|
|
||||||
Console.WriteLine("Введите количество кадров анимации: ");
|
Console.WriteLine("Введите количество кадров анимации: ");
|
||||||
int framesCount = int.Parse(Console.ReadLine());
|
int framesCount = int.Parse(Console.ReadLine());
|
||||||
Console.WriteLine("Введите длительность кадра в анимации: ");
|
Console.WriteLine("Введите длительность кадра в анимации: ");
|
||||||
|
|
59
DangerousD/Content/map.tmx
Normal file
59
DangerousD/Content/map.tmx
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?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="-56" y="80">
|
||||||
|
<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.Frank">
|
||||||
|
<object id="3" x="-53" y="158">
|
||||||
|
<point/>
|
||||||
|
</object>
|
||||||
|
</objectgroup>
|
||||||
|
</map>
|
|
@ -36,6 +36,12 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int obsticles = 0;
|
||||||
|
public virtual void OnCollisionWithObsticle(GameObject gameObject)
|
||||||
|
{
|
||||||
|
obsticles++;//SD
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -47,6 +53,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
public virtual void Update(GameTime gameTime)
|
public virtual void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
obsticles = 0;
|
||||||
GraphicsComponent.Update();
|
GraphicsComponent.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,13 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
get { return position; }
|
get { return position; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Frank(Vector2 position) : base(position)
|
public Frank(Vector2 position) : base(new Vector2(300, 200))
|
||||||
{
|
{
|
||||||
this.position = position;
|
//position = new Vector2(300, 200);
|
||||||
Width = 112;
|
Width = 112;
|
||||||
Height = 160;
|
Height = 160;
|
||||||
GraphicsComponent.StartAnimation("FrankMoveLeft");
|
GraphicsComponent.StartAnimation("FrankMoveLeft");
|
||||||
monster_speed = 1;
|
monster_speed = 3;
|
||||||
name = "Frank";
|
name = "Frank";
|
||||||
}
|
}
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "FrankMoveRight", "FrankMoveLeft" }, "FrankMoveRight");
|
||||||
|
|
|
@ -7,37 +7,37 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DangerousD.GameCore.GameObjects.MapObjects;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class FrankBalls : CoreEnemy
|
public class FrankBalls : CoreEnemy
|
||||||
{
|
{
|
||||||
private Rectangle collision;
|
private Rectangle collision;
|
||||||
private Vector2 position;
|
|
||||||
private int healthBall;
|
|
||||||
private bool isFlyRight = true;
|
private bool isFlyRight = true;
|
||||||
private bool isAttacking = false;
|
private bool isAttacking = false;
|
||||||
|
|
||||||
public Rectangle Collision
|
public Rectangle Collision
|
||||||
{
|
{
|
||||||
get { return collision; }
|
get { return collision; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrankBalls(Vector2 position) : base(position)
|
public FrankBalls(Vector2 position) : base(new Vector2(300, 200))
|
||||||
{
|
{
|
||||||
this.position = position;
|
|
||||||
name = "FrankBalls";
|
name = "FrankBalls";
|
||||||
Width = 40;
|
Width = 40;
|
||||||
Height = 40;
|
Height = 40;
|
||||||
monster_speed = 2;
|
monster_speed = 2;
|
||||||
|
monster_health = 13;
|
||||||
acceleration = Vector2.Zero;
|
acceleration = Vector2.Zero;
|
||||||
|
velocity = new Vector2(monster_speed, monster_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
protected override GraphicsComponent GraphicsComponent { get; } = new(new List<string> { "BallMoveRight" }, "BallMoveRight");
|
||||||
|
|
||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
collision = new Rectangle((int)position.X, (int)position.Y, 40, 40);
|
collision = new Rectangle((int)_pos.X, (int)_pos.Y, 40, 40);
|
||||||
|
|
||||||
if (!isAttacking)
|
if (!isAttacking)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,25 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
isFlyRight = false;
|
isFlyRight = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var foundObj = AppManager.Instance.GameManager.physicsManager.CheckRectangle(new Rectangle((int)_pos.X-1, (int)_pos.Y-1, Width+2, Height+2), typeof(StopTile));
|
||||||
|
|
||||||
|
if (foundObj != null && foundObj.Count > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
float av = foundObj.Sum(x => x.Rectangle.X)/foundObj.Count;
|
||||||
|
float avy = foundObj.Sum(x => x.Rectangle.Y)/foundObj.Count;
|
||||||
|
|
||||||
|
if (avy <= _pos.Y)
|
||||||
|
velocity.Y = monster_speed;
|
||||||
|
else if (avy >= _pos.Y)
|
||||||
|
velocity.Y = -monster_speed;
|
||||||
|
if (av <= _pos.X)
|
||||||
|
velocity.X = -monster_speed;
|
||||||
|
else if (av >= _pos.X)
|
||||||
|
velocity.X = monster_speed;
|
||||||
|
monster_health--;
|
||||||
|
}
|
||||||
|
|
||||||
base.Update(gameTime);
|
base.Update(gameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,19 +97,7 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
velocity.X = 0;
|
|
||||||
velocity.Y = 0;
|
|
||||||
|
|
||||||
if(isFlyRight)
|
|
||||||
{
|
|
||||||
velocity.X += monster_speed;
|
|
||||||
velocity.Y += monster_speed;
|
|
||||||
}
|
|
||||||
else if(!isFlyRight)
|
|
||||||
{
|
|
||||||
velocity.X -= monster_speed;
|
|
||||||
velocity.Y -= monster_speed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,16 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
{
|
{
|
||||||
public class Hunchman : CoreEnemy
|
public class Hunchman : CoreEnemy
|
||||||
{
|
{
|
||||||
|
private bool isGoRight = true;
|
||||||
|
|
||||||
public Hunchman(Vector2 position) : base(position)
|
public Hunchman(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
Width = 20;
|
||||||
|
Height = 30;
|
||||||
|
name = "Hunchman";
|
||||||
|
GraphicsComponent.StartAnimation("");
|
||||||
|
monster_speed = 3;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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" }, "HunchmanMoveRight");
|
||||||
|
@ -30,7 +38,11 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities.Monsters
|
||||||
|
|
||||||
public override void Move(GameTime gameTime)
|
public override void Move(GameTime gameTime)
|
||||||
{
|
{
|
||||||
|
var player = AppManager.Instance.GameManager.players[0];
|
||||||
|
if(player.Pos.X > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ namespace DangerousD.GameCore
|
||||||
case GameState.Lobby:
|
case GameState.Lobby:
|
||||||
break;
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
GameManager.mapManager.LoadLevel("lvl");
|
GameManager.mapManager.LoadLevel("map");
|
||||||
break;
|
break;
|
||||||
case GameState.GameOver:
|
case GameState.GameOver:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
internal void Register(GameObject gameObject)
|
internal void Register(GameObject gameObject)
|
||||||
{
|
{
|
||||||
|
GetAllGameObjects.Add(gameObject);
|
||||||
if (gameObject is Player)
|
if (gameObject is Player)
|
||||||
{
|
{
|
||||||
livingEntities.Add(gameObject as LivingEntity);
|
livingEntities.Add(gameObject as LivingEntity);
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace DangerousD.GameCore.Managers
|
||||||
{
|
{
|
||||||
if (tiles[i] != 0)
|
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);
|
((chunkY + i / chunkW) * tileSize.Y + offsetY) * _scale);
|
||||||
//pos *= _scale;
|
//pos *= _scale;
|
||||||
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());
|
Rectangle sourceRect = new(new Point((tiles[i] -1) % _columns, (tiles[i] -1) / _columns) * tileSize.ToPoint(), tileSize.ToPoint());
|
||||||
|
|
|
@ -97,6 +97,10 @@ namespace DangerousD.GameCore.Managers
|
||||||
if (!isYNormalise)
|
if (!isYNormalise)
|
||||||
currentEntity.velocity.Y = 0;
|
currentEntity.velocity.Y = 0;
|
||||||
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
currentEntity.SetPosition(new Vector2(oldRect.X, oldRect.Y));
|
||||||
|
if (!isXNormalise || !isYNormalise)
|
||||||
|
{
|
||||||
|
currentEntity.OnCollisionWithObsticle(mapObjects[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue