Initial commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public abstract class AbstractGameObject : IGameObject
|
||||
{
|
||||
private Vector3 _Position;
|
||||
public Vector3 Position
|
||||
{
|
||||
get => _Position;
|
||||
set => _Position = value;
|
||||
}
|
||||
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; }
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public interface IGameObject
|
||||
{
|
||||
void Activate();
|
||||
void Destroy();
|
||||
Vector3 Position { get; set; }
|
||||
Vector3 Orientation { get; set; }
|
||||
float Theta { get; set; }
|
||||
Matrix Rotation { get; set; }
|
||||
void Update(GameTime gameTime);
|
||||
ObjectType Type { get; set; }
|
||||
void Move(Vector3 pose);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public enum ObjectType
|
||||
{
|
||||
Generic,
|
||||
Player
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
public class Player : AbstractGameObject
|
||||
{
|
||||
private Vector3 _PrevPos;
|
||||
public Player(IScreen screen): base(screen)
|
||||
{
|
||||
Type = ObjectType.Player;
|
||||
Position = new Vector3(10, 0, 0);
|
||||
Rotation = Matrix.Identity;
|
||||
Orientation = Rotation.Forward;
|
||||
Activate();
|
||||
}
|
||||
|
||||
override public void Activate()
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
return;
|
||||
}
|
||||
override public void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using SynthySound;
|
||||
|
||||
namespace EvilSatellites.Objects
|
||||
{
|
||||
class SynthyProp : AbstractGameObject
|
||||
{
|
||||
private ISoundEffect3D Sound;
|
||||
public SynthyProp(IScreen screen, Vector3 pos): base(screen)
|
||||
{
|
||||
Sound = Screen.Manager.Sound.Load3D(@"sfx/ambience/water1.wav");
|
||||
Sound.Loop = true;
|
||||
Position = pos;
|
||||
Sound.Position = new System.Numerics.Vector3(pos.X, pos.Y, pos.Z);
|
||||
Sound.ConnectToEffect(Screen.Manager.EnvironmentEffect);
|
||||
Activate();
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
Sound.Play();
|
||||
}
|
||||
public override void Destroy()
|
||||
{
|
||||
Sound.Destroy();
|
||||
}
|
||||
|
||||
override public void Update(GameTime gameTime)
|
||||
{
|
||||
Sound.Position = new System.Numerics.Vector3(Position.X, Position.Y, Position.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user