small refactoring and minor changes

This commit is contained in:
SergoDobro 2023-08-15 01:19:10 +03:00
parent d7921124e1
commit e45b34ac06
9 changed files with 139 additions and 7 deletions

View file

@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GameObjects
{
abstract class Entity : GameObject
public abstract class Entity : GameObject
{
private Vector2 targetPosition;
public float speed;

View file

@ -15,8 +15,8 @@ namespace DangerousD.GameCore
public int Width { get; protected set; }
public int Height { get; protected set; }
public Rectangle Rectangle => new Rectangle((int)Pos.X, (int)Pos.Y, Width, Height);
protected GraphicsComponent Animator;
protected GraphicsComponent graphicsComponent;
public GameObject(Vector2 pos)
{
Pos = pos;
@ -31,14 +31,17 @@ namespace DangerousD.GameCore
}
public abstract void Initialize(GraphicsDevice graphicsDevice);
public abstract void LoadContent(ContentManager content);
public virtual void LoadContent(ContentManager content)
{
graphicsComponent.LoadContent(content);
}
public abstract void Update(GameTime gameTime);
public virtual void Draw(SpriteBatch spriteBatch)
{
//Animator.DrawAnimation(Rectangle, "playerIdle", spriteBatch);
graphicsComponent.DrawAnimation(Rectangle, spriteBatch);
}
}
}

View file

@ -0,0 +1,33 @@
using DangerousD.GameCore.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DangerousD.GameCore.GameObjects.LivingEntities
{
public class Enemy1 : LivingEntity
{
public Enemy1(Vector2 position) : base(position)
{
}
public override void Initialize(GraphicsDevice graphicsDevice)
{
graphicsComponent = new GraphicsComponent(new List<string>() { "IDLE", "WALK" }, "IDLE");
}
public override void Update(GameTime gameTime)
{
if (graphicsComponent.GetCurrentAnimation!="WALK")
graphicsComponent.StartAnimation("WALK");
base.Update(gameTime);
}
}
}

View file

@ -2,7 +2,7 @@
namespace DangerousD.GameCore.GameObjects;
internal abstract class LivingEntity : Entity
public abstract class LivingEntity : Entity
{
public LivingEntity(Vector2 position) : base(position)
{

View file

@ -1,10 +1,13 @@
using Microsoft.Xna.Framework;
using System.Security.Cryptography.X509Certificates;
namespace DangerousD.GameCore.GameObjects;
internal abstract class MapObject : GameObject
{
public bool IsColliderOn;
public MapObject(Vector2 position) : base(position)
{
}
}

View file

@ -0,0 +1,32 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DangerousD.GameCore.GameObjects.MapObjects
{
internal class GrassBlock : MapObject
{
public GrassBlock(Vector2 position) : base(position)
{
}
public override void Initialize(GraphicsDevice graphicsDevice)
{
}
public override void LoadContent(ContentManager content)
{
// graphicsComponent = new Graphics.GraphicsComponent();
base.LoadContent(content);
}
public override void Update(GameTime gameTime)
{
}
}
}

View file

@ -14,6 +14,7 @@ namespace DangerousD.GameCore.Graphics
private List<Texture2D> textures;
private List<string> texturesNames;
private AnimationContainer currentAnimation;
public string GetCurrentAnimation { get { return currentAnimation.Id; } }
private AnimationContainer neitralAnimation;
//private SpriteBatch _spriteBatch;

View file

@ -0,0 +1,35 @@
using DangerousD.GameCore.GameObjects;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Security;
using System.Text;
using System.Threading.Tasks;
namespace DangerousD.GameCore.Managers
{
interface ILevel
{
void InitLevel();
}
public class Level1 : ILevel
{
public void InitLevel()
{
//new MapObject(new Vector2(0,128));
}
}
public class MapManager
{
public void Init()
{
}
//Level
public void LoadLevel(string level)
{
}
}
}

View file

@ -0,0 +1,25 @@
using DangerousD.GameCore.GameObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DangerousD.GameCore.Managers
{
internal class PhysicsManager
{
public void UpdateCollisions(List<Entity> entities, List<LivingEntity> livingEntities,
List<MapObject> mapObjects)
{
//entities dont move
//Living entities dont move
//mapObjects dont move
//mapObjects have isCollisions on
//Check collisions
//Only Living entities move
//OnCollision
}
}
}