using System;
using FRB;
using FRB.Gui;
using FRB.Text;
using FRB.Particle;
using FRB.Collections;
using FRB.MSG;
using FRB.Audio;
using FRB.Shapes;
using Math2D;
using Microsoft.DirectX.DirectInput;
using Mesh = Microsoft.DirectX.Direct3D.Mesh;
namespace GameName
{
public class GameData
{
#region reference to engine managers and data
public GameForm form;
public InputManager inpMan;
public SpriteManager sprMan;
public TextManager textMan;
public GuiManager guiMan;
public Camera camera;
public Cursor cursor;
public Random random;
public ShapeManager shaMan;
public GameName.Screens.ScreenManager screenManager;
#endregion
// declare variables of class scope here
Microsoft.DirectX.Direct3D.Mesh mesh;
public void Initialize(GameForm form)
{
#region initialize engine managers and data
this.form = form;
sprMan = GameForm.sprMan;
inpMan = GameForm.inpMan;
textMan = GameForm.textMan;
guiMan = GameForm.guiMan;
camera = GameForm.camera;
cursor = GameForm.cursor;
random = GameForm.random;
shaMan = GameForm.shaMan;
screenManager = GameForm.screenManager;
#endregion
// uncomment this line and pass the qualified string name of the first
// Screen class that the game should show upon execution.
//screenManager.Start("NameSpace.Screens.ScreenClassName");
mesh = Mesh.Sphere(sprMan.D3DDevice, 2, 16, 16);
}
public void Activity()
{
// this can be left uncommented - won't do anything if there are no active Screens
screenManager.Activity();
}
public void AfterFrameActivity()
{
// usually, the only code that goes here is text printing with the TextManager
// if drawing text, uncomment the following line:
//textMan.BeginDrawing();
}
public void Draw()
{
// easier to just reference device rather than
// sprMan.D3DDevice so create an alias
Microsoft.DirectX.Direct3D.Device device = sprMan.D3DDevice;
// set the view and projection. This is a quick way to use the FRB camera
device.Transform.View = camera.GetLookAtLHMatrix();
device.Transform.Projection = camera.GetProjectionMatrix();
// this value is used to set the light's position
// based on the mouse position
float lightZ = -10;
// enable lighting
device.RenderState.Lighting = true;
// create a regular Point light.
device.Lights[0].Enabled = true;
device.Lights[0].Type =
Microsoft.DirectX.Direct3D.LightType.Point;
device.Lights[0].Position = new Microsoft.DirectX.Vector3(
cursor.XAt(lightZ), cursor.YAt(lightZ), lightZ);
device.Lights[0].Diffuse = System.Drawing.Color.Gray;
device.Lights[0].Attenuation0 = .2f;
device.Lights[0].Range = 10000;
device.Lights[0].Update();
// create the material for the ball
Microsoft.DirectX.Direct3D.Material material =
new Microsoft.DirectX.Direct3D.Material();
material.Diffuse = System.Drawing.Color.Gray;
// assign the material
device.Material = material;
// draw the mesh
mesh.DrawSubset(0);
}
}
}