Merge branch 'main' of https://github.com/progtime-net/DangerousD
This commit is contained in:
commit
e6beffb420
4 changed files with 80 additions and 6 deletions
|
@ -1,10 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects
|
||||
{
|
||||
class Entity
|
||||
{
|
||||
abstract class Entity : GameObject
|
||||
{
|
||||
private Vector2 targetPosition;
|
||||
public float speed;
|
||||
|
||||
public Entity(Texture2D texture, Vector2 position) : base(texture, position) {}
|
||||
public Entity(Texture2D texture, Vector2 position, GraphicsComponent animator) : base(texture, position, animator) {}
|
||||
|
||||
|
||||
public void SetPosition(Vector2 position) { targetPosition = position; }
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Vector2.Distance(Position, targetPosition) > 0.5f)
|
||||
{
|
||||
Vector2 dir = targetPosition - Position;
|
||||
dir.Normalize();
|
||||
Position += dir * speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
class GameObject
|
||||
public abstract class GameObject
|
||||
{
|
||||
GraphicsComponent graphicsComponent;
|
||||
public GameObject()
|
||||
protected Texture2D Texture;
|
||||
public Vector2 Position;
|
||||
protected GraphicsComponent Animator;
|
||||
|
||||
public GameObject(Texture2D texture, Vector2 position)
|
||||
{
|
||||
Texture = texture;
|
||||
Position = position;
|
||||
GameManager.Register(this);
|
||||
}
|
||||
|
||||
public GameObject(Texture2D texture, Vector2 position, GraphicsComponent animator)
|
||||
{
|
||||
Texture = texture;
|
||||
Position = position;
|
||||
Animator = animator;
|
||||
GameManager.Register(this);
|
||||
}
|
||||
|
||||
public virtual void OnCollision()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace DangerousD.GameCore.GameObjects
|
||||
{
|
||||
class LivingEntity : GameObject
|
||||
abstract class LivingEntity : Entity
|
||||
{
|
||||
public LivingEntity(Texture2D texture, Vector2 position) : base(texture, position)
|
||||
{
|
||||
}
|
||||
|
||||
public LivingEntity(Texture2D texture, Vector2 position, GraphicsComponent animator) : base(texture, position, animator)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
DangerousD/GameCore/GraphicsComponent.cs
Normal file
11
DangerousD/GameCore/GraphicsComponent.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.Xna.Framework.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DangerousD.GameCore
|
||||
{
|
||||
public class GraphicsComponent
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue