2020-08-05 19:21:42 +00:00
|
|
|
using System.IO;
|
|
|
|
using Encompass;
|
|
|
|
using KavTest.Components;
|
2020-08-05 20:57:15 +00:00
|
|
|
using KavTest.Engines;
|
2020-08-05 19:21:42 +00:00
|
|
|
using KavTest.Messages;
|
|
|
|
using KavTest.Renderers;
|
|
|
|
using KavTest.Spawners;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
|
|
namespace KavTest
|
|
|
|
{
|
|
|
|
class KavTestGame : Game
|
|
|
|
{
|
|
|
|
GraphicsDeviceManager graphics;
|
|
|
|
|
|
|
|
WorldBuilder WorldBuilder { get; } = new WorldBuilder();
|
|
|
|
World World { get; set; }
|
|
|
|
|
|
|
|
public KavTestGame()
|
|
|
|
{
|
|
|
|
graphics = new GraphicsDeviceManager(this);
|
|
|
|
graphics.PreferredBackBufferWidth = 1280;
|
|
|
|
graphics.PreferredBackBufferHeight = 720;
|
|
|
|
graphics.PreferMultiSampling = true;
|
|
|
|
Content.RootDirectory = "Content";
|
|
|
|
|
|
|
|
Window.AllowUserResizing = true;
|
|
|
|
IsMouseVisible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadContent()
|
|
|
|
{
|
|
|
|
var rustyBallModel = ModelLoader.Load(
|
|
|
|
GraphicsDevice,
|
|
|
|
Smuggler.Importer.ImportGLB(GraphicsDevice, File.OpenRead("Content/cube.glb"))
|
|
|
|
);
|
|
|
|
|
2020-08-05 20:57:15 +00:00
|
|
|
WorldBuilder.AddEngine(new RotationEngine());
|
2020-08-05 19:21:42 +00:00
|
|
|
WorldBuilder.AddEngine(new RustyBallSpawner(rustyBallModel));
|
|
|
|
WorldBuilder.AddEngine(new LightBulbSpawner());
|
|
|
|
WorldBuilder.AddGeneralRenderer(new SceneRenderer(GraphicsDevice), 0);
|
|
|
|
|
|
|
|
WorldBuilder.SendMessage(new RustyBallSpawnMessage(
|
2020-08-05 22:10:04 +00:00
|
|
|
new Transform3D(new Vector3(0, 0, 0)),
|
|
|
|
new Vector3(1, 1, -1)
|
2020-08-05 19:21:42 +00:00
|
|
|
));
|
2020-08-05 22:10:04 +00:00
|
|
|
|
|
|
|
WorldBuilder.SendMessage(new RustyBallSpawnMessage(
|
|
|
|
new Transform3D(new Vector3(-5, 0, 0)),
|
|
|
|
new Vector3(-1, 1, -1)
|
|
|
|
));
|
|
|
|
|
|
|
|
WorldBuilder.SendMessage(new RustyBallSpawnMessage(
|
|
|
|
new Transform3D(new Vector3(5, 0, 0)),
|
|
|
|
new Vector3(-1, 1, 1)
|
|
|
|
));
|
|
|
|
|
2020-08-05 19:21:42 +00:00
|
|
|
WorldBuilder.SendMessage(new LightBulbSpawnMessage(
|
2020-08-05 22:10:04 +00:00
|
|
|
new Transform3D(new Vector3(0, 2, -5)),
|
2020-08-05 19:21:42 +00:00
|
|
|
Color.White,
|
|
|
|
300f
|
|
|
|
));
|
|
|
|
|
|
|
|
var cameraMatrix = Matrix.CreateLookAt(new Vector3(10, 0, 0), Vector3.Zero, Vector3.Up);
|
|
|
|
var cameraEntity = WorldBuilder.CreateEntity();
|
|
|
|
WorldBuilder.SetComponent(cameraEntity, new CameraComponent(
|
|
|
|
new Kav.Camera(
|
|
|
|
cameraMatrix
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
World = WorldBuilder.Build();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UnloadContent()
|
|
|
|
{
|
|
|
|
base.UnloadContent();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update(GameTime gameTime)
|
|
|
|
{
|
|
|
|
World.Update(gameTime.ElapsedGameTime.TotalSeconds);
|
|
|
|
|
|
|
|
base.Update(gameTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Draw(GameTime gameTime)
|
|
|
|
{
|
|
|
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
|
|
|
|
|
|
|
World.Draw();
|
|
|
|
|
|
|
|
base.Draw(gameTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|