public Shockwave(Device device) { this.device = device; shockWaveMesh = new PositionedMesh(device, MediaUtilities.FindFile("shockwave.x")); shockWaveMesh.Position.Location = new Vector3(0, 0, 0); shockWaveMesh.Position.Rotate(0, 0, 10); }
public HelpScreen() { // // Required for Windows Form Designer support // InitializeComponent(); string helpFile = MediaUtilities.FindFile("Help.txt"); if (File.Exists(helpFile)) { StreamReader sr; try { sr = new StreamReader(helpFile); helpText.Text = sr.ReadToEnd(); sr.Close(); } catch (Exception e) { helpText.Text = e.ToString(); } } else { helpText.Text = "Unable to locate " + helpFile.ToString(); } }
/// <summary> /// Creates a new mesh /// </summary> /// <param name="device">The device used to create the mesh</param> /// <param name="filename">the file to load</param> public void Create(Device device, string filename) { worldPosition = new WorldPosition(); GraphicsStream adjacencyBuffer; ExtendedMaterial[] Mat; this.device = device; if (device != null) { device.DeviceLost += new System.EventHandler(this.InvalidateDeviceObjects); device.Disposing += new System.EventHandler(this.InvalidateDeviceObjects); device.DeviceReset += new System.EventHandler(this.RestoreDeviceObjects); } filename = MediaUtilities.FindFile(filename); // Load the mesh systemMemoryMesh = Mesh.FromFile(filename, MeshFlags.SystemMemory, device, out adjacencyBuffer, out Mat); Mesh tempMesh = null; string errorString; tempMesh = Mesh.Clean(CleanType.Optimization, systemMemoryMesh, adjacencyBuffer, adjacencyBuffer, out errorString); if (tempMesh != systemMemoryMesh) { systemMemoryMesh.Dispose(); systemMemoryMesh = tempMesh; } // Optimize the mesh for performance MeshFlags flags = MeshFlags.OptimizeCompact | MeshFlags.OptimizeAttributeSort | MeshFlags.OptimizeVertexCache; systemMemoryMesh.OptimizeInPlace(flags, adjacencyBuffer); adjacencyBuffer.Close(); adjacencyBuffer = null; // Setup bounding volumes VertexBuffer vb = systemMemoryMesh.VertexBuffer; GraphicsStream vertexData = vb.Lock(0, 0, LockFlags.ReadOnly); boundingSphere.Radius = Geometry.ComputeBoundingSphere(vertexData, systemMemoryMesh.NumberVertices, systemMemoryMesh.VertexFormat, out boundingSphere.CenterPoint); vb.Unlock(); vb.Dispose(); textures = new Texture[Mat.Length]; materials = new Direct3D.Material[Mat.Length]; for (int i = 0; i < Mat.Length; i++) { materials[i] = Mat[i].Material3D; // Set the ambient color for the material (D3DX does not do this) materials[i].Ambient = materials[i].Diffuse; if (Mat[i].TextureFilename != null) { // Create the texture textures[i] = TextureLoader.FromFile(device, MediaUtilities.FindFile(Mat[i].TextureFilename)); } } RestoreDeviceObjects(device, null); }
/// <summary> /// Initialize scene objects. /// </summary> protected override void InitializeDeviceObjects() { drawingFont.InitializeDeviceObjects(device); string spaceSphereFileName = MediaUtilities.FindFile("SpaceSphere.x"); spaceSphere = Mesh.FromFile(spaceSphereFileName, MeshFlags.Managed, device); }
public Ship(Device device, GameClass gameClass, HullColors hullColor) { this.device = device; this.game = gameClass; shots = new Shots(device); if (hullColor == HullColors.White) { shipMesh = new PositionedMesh(device, "WhiteShip.x"); startingPosition = new Vector3(10, 0, 10); } else { shipMesh = new PositionedMesh(device, "RedShip.x"); startingPosition = new Vector3(-50, 0, -150); } vaporTrail = new ParticleEffects(device); vaporTrail.ParticleTexture = TextureLoader.FromFile(device, MediaUtilities.FindFile("particle-blue.bmp")); shockWave = new Shockwave(device); SetRandomPosition(true); }
void CreateSoundBuffers() { AddBuffer(MediaUtilities.FindFile("hypercharge.wav"), Sounds.ShipHyper, false); AddBuffer(MediaUtilities.FindFile("sci fi bass.wav"), Sounds.ShipAppear, false); AddBuffer(MediaUtilities.FindFile("laser2.wav"), Sounds.ShipFire, false); AddBuffer(MediaUtilities.FindFile("explode.wav"), Sounds.ShipExplode, false); AddBuffer(MediaUtilities.FindFile("engine.wav"), Sounds.ShipThrust, true, VolumeEngine); AddBuffer(MediaUtilities.FindFile("laser2_other.wav"), Sounds.OtherShipFire, false, VolumeOtherShot); AddBuffer(MediaUtilities.FindFile("explode_other.wav"), Sounds.OtherShipExplode, false); AddBuffer(MediaUtilities.FindFile("engine_other.wav"), Sounds.OtherShipThrust, true, VolumeEngine); AddBuffer(MediaUtilities.FindFile("sci fi bass.wav"), Sounds.OtherShipAppear, false); AddBuffer(MediaUtilities.FindFile("haha.wav"), Sounds.Taunt, false, VolumeHaHa); AddBuffer(MediaUtilities.FindFile("dude_quest1.wav"), Sounds.Dude1, false); AddBuffer(MediaUtilities.FindFile("dude_quest2.wav"), Sounds.Dude2, false); AddBuffer(MediaUtilities.FindFile("dude_quest3.wav"), Sounds.Dude3, false); AddBuffer(MediaUtilities.FindFile("dude_quest4.wav"), Sounds.Dude4, false); AddBuffer(MediaUtilities.FindFile("dude_quest5.wav"), Sounds.Dude5, false); }
/// <summary> /// Initialize scene objects. /// </summary> protected override void InitializeDeviceObjects() { drawingFont.InitializeDeviceObjects(device); spaceSphere = new PositionedMesh(device, "SpaceSphere.x"); HullColors hullColor = HullColors.White; playerShip = new Ship(device, this, hullColor); if (playerShip.HostName == null) { playerShip.HostName = "Player"; } playerShip.State = ShipState.Normal; HullColors opponentHullColor; if (hullColor == HullColors.Red) { opponentHullColor = HullColors.White; } else { opponentHullColor = HullColors.Red; } opponentShip = new Ship(device, this, opponentHullColor); if (opponentShip.HostName == null) { opponentShip.HostName = "Opponent"; } opponentShip.State = ShipState.Normal; bgPointer = new BGPointer(device); vectorPanel = TextureLoader.FromFile(device, MediaUtilities.FindFile("vectorPanel.png")); rts = new RenderToSurface(device, 128, 128, Format.X8R8G8B8, true, DepthFormat.D16); }