Add collision detection with octree
This commit is contained in:
@@ -21,12 +21,6 @@ namespace EvilSatellites.Objects
|
||||
set => _Dimensions = value;
|
||||
}
|
||||
public Vector3 Movement;
|
||||
// public Vector3 Movement
|
||||
// {
|
||||
// get => _Movement;
|
||||
// set => _Movement = value;
|
||||
// }
|
||||
|
||||
private Vector3 _Orientation;
|
||||
public Vector3 Orientation
|
||||
{
|
||||
@@ -42,7 +36,7 @@ namespace EvilSatellites.Objects
|
||||
}
|
||||
public IScreen Screen;
|
||||
public ObjectType Type { get; set; }
|
||||
|
||||
public bool IsDynamic { get => true; }
|
||||
public AbstractGameObject(IScreen screen)
|
||||
{
|
||||
Screen = screen;
|
||||
@@ -90,5 +84,9 @@ namespace EvilSatellites.Objects
|
||||
public abstract void Activate();
|
||||
|
||||
public abstract void Destroy();
|
||||
public virtual void OnCollision(IGameObject obj)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@ using Microsoft.Xna.Framework;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public interface IGameObject
|
||||
public interface IGameObject : EvilSatellites.Quadtree.Positional
|
||||
{
|
||||
void Activate();
|
||||
void Destroy();
|
||||
Vector3 Position { get; set; }
|
||||
Vector3 Dimensions { get; set; }
|
||||
Vector3 Orientation { get; set; }
|
||||
// Vector3 Movement { get; set; }
|
||||
bool IsDynamic { get; }
|
||||
float Theta { get; set; }
|
||||
Matrix Rotation { get; set; }
|
||||
void Update(GameTime gameTime);
|
||||
ObjectType Type { get; set; }
|
||||
void Move(Vector3 pose);
|
||||
|
||||
void OnCollision(IGameObject obj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +75,11 @@ namespace EvilSatellites.Objects
|
||||
}
|
||||
}
|
||||
|
||||
public void Accelerate()
|
||||
public void Accelerate(Vector3 direction)
|
||||
{
|
||||
Vector3 acc = new Vector3(0f, 0f, -0.035f);
|
||||
if (Math.Abs(Movement.X) < MaxSpeed.X && Math.Abs(Movement.Y) < MaxSpeed.Y && Math.Abs(Movement.Z) < MaxSpeed.Z)
|
||||
{
|
||||
Movement += acc;
|
||||
Movement += direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace EvilSatellites.Objects
|
||||
Sound = Screen.Manager.Sound.Load3D(@"sfx/ui/chat.wav");
|
||||
Sound.Loop = true;
|
||||
Position = pos;
|
||||
Dimensions = new Vector3(5, 5, 5);
|
||||
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
|
||||
// Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
|
||||
Activate();
|
||||
@@ -32,5 +33,10 @@ namespace EvilSatellites.Objects
|
||||
{
|
||||
Sound.Position = new System.Numerics.Vector3(Position.X, Position.Y, Position.Z);
|
||||
}
|
||||
|
||||
public override void OnCollision(IGameObject obj)
|
||||
{
|
||||
Sound.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user