Files
evilsatellites/EvilSatellites/Objects/AbstractGameObject.cs
T

94 lines
2.5 KiB
C#
Raw Normal View History

2021-04-10 14:08:20 +02:00
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
2021-04-11 17:09:57 +02:00
using EvilSatellites.Screens;
2021-04-10 14:08:20 +02:00
namespace EvilSatellites.Objects
{
public abstract class AbstractGameObject : IGameObject
{
private Vector3 _Position;
public Vector3 Position
{
get => _Position;
set => _Position = value;
}
2021-04-11 02:01:24 +02:00
private Vector3 _Dimensions;
public Vector3 Dimensions
{
get => _Dimensions;
set => _Dimensions = value;
}
public Vector3 Movement;
2021-04-10 14:08:20 +02:00
private Vector3 _Orientation;
public Vector3 Orientation
{
get => _Orientation;
set => _Orientation = value;
}
public float Theta { get; set; }
private Matrix _Rotation;
public Matrix Rotation
{
get => _Rotation;
set => _Rotation = value;
}
public IScreen Screen;
public ObjectType Type { get; set; }
2021-04-11 14:12:55 +02:00
public bool IsDynamic { get => true; }
2021-04-10 14:08:20 +02:00
public AbstractGameObject(IScreen screen)
{
Screen = screen;
Type = ObjectType.Generic;
}
public void RotateX(float angle)
{
Matrix rotate = Matrix.CreateFromAxisAngle(_Rotation.Right, angle);
_Rotation *= rotate;
Orientation = _Rotation.Forward;
}
public void RotateY(float angle)
{
Matrix rotate = Matrix.CreateFromAxisAngle(_Rotation.Up, angle);
_Rotation *= rotate;
Orientation = _Rotation.Forward;
}
public void RotateZ(float angle)
{
Matrix rotate = Matrix.CreateFromAxisAngle(_Rotation.Forward, angle);
_Rotation *= rotate;
Orientation = _Rotation.Forward;
}
public void Pitch(Single pitch)
{
Matrix rotate = Matrix.CreateFromYawPitchRoll(0, pitch, 0);
_Rotation *= rotate;
Orientation = _Rotation.Forward;
}
public void Move(Vector3 pose)
{
var move = Vector3.Transform(pose, _Rotation);
// move.Normalize();
_Position += move;
}
public abstract void Update(GameTime gameTime);
public abstract void Activate();
public abstract void Destroy();
2021-04-11 14:12:55 +02:00
public virtual void OnCollision(IGameObject obj)
{
return;
}
2021-04-10 14:08:20 +02:00
}
}