//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {License Information: Creative Commons} //--------------------------------------------------------------------------------------------------------------------------------------------------- #define forPC namespace ElementalGame { #region Using Statements using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; using System.Xml; using System.Diagnostics; using System.Threading; #endregion // Container and Manager class for GameObjects public class ObjectLibrary { public static List darkMatter; public static int darkMatterIterator = 0; public int numberOfHumans; // CLEAN: EVALUATE NECCESSITY OR CLASS LOCALITY================================================= public ModelManager modelManager; public Effect effect; Stopwatch timer = new Stopwatch(); // Debug info public string levelName; public string currentLevelXmlFile = ""; public static Vector2 playerPosition; public Particle particle; //private UpdatePositionThreads updatePositionThreads; public class UpdateThreadStruct { public ObjectLibrary objectLibrary; public float dt; } public UpdateThreadStruct updateThreadStruct; // SPACIAL DATA STRUCTURE AND OBJECTS ================================================= public static GameObjectList gameObjectList; public List gameObjectLists; public static LookupMap lookupMap; public List> drawList; private List lastGetDrawList; // Game Objects public SkySphere skySphere; // The sky public Terrain terrain; // The ground public List humans; // A list of all Human Players public List bots = new List(); // A list of opponent AI Players public Texture2D enemyTargetReticle; // Load Objects public ObjectLibrary(int numHumans) { numberOfHumans = numHumans; gameObjectList = new GameObjectList(); } public void DeinitializeHumans() { //be warned.. MUST call ElementalGame.CheckForControllers after this!! foreach (Human human in humans) { human.playerController.playerControllerType = GameController.ControllerType.NONE; human.health = 0; human.manna = 0; } } // Create or reinitialize the DarkMatter queue public void LoadDarkMatter() { darkMatterIterator = 0; if (darkMatter == null) { darkMatter = new List(XML.LevelSettings.darkMatterCount); for (int i = 0; i < XML.LevelSettings.darkMatterCount; i++) { darkMatter.Add(new Mass()); } } else { for (int i = 0; i < XML.LevelSettings.darkMatterCount; i++) { darkMatter[i].ClearValues(); } Mass.accelDueToGravity = Vector3.Zero; Mass.gravityForce = 0.0f; } } // Initialize the GameObjects public void LoadMatter() { // Init skySphere = new SkySphere(darkMatter[darkMatterIterator++]); terrain = new Terrain(darkMatter[darkMatterIterator++]); XML.SystemSettings.TOTAL_PLAYERS = 0; humans = new List(numberOfHumans); for (int playerNumber = 0; playerNumber < numberOfHumans; playerNumber++) { humans.Add(new Human(playerNumber)); } modelManager = new ModelManager(); //updatePositionThreads = new UpdatePositionThreads(); //updateThreadStruct = new UpdateThreadStruct(); } // Load all non-content related variables public void LoadGame() { XML.LoadSystem(); modelManager.LoadGame(); } // Load the Terrain for the Terrain Demo public void LoadLevel_Stage1(string xmlFileName) { XML.LoadLevel_Stage1(xmlFileName); currentLevelXmlFile = xmlFileName; // Physics properties if (XML.physicsNode != null) { Mass.gravityForce = float.Parse(XML.physicsNode.Attributes["gravity"].Value); Mass.accelDueToGravity = new Vector3(0.0f, Mass.gravityForce, 0.0f); XML.PlayerSettings.JUMP_CONSTANT = Mass.gravityForce; XML.PlayerSettings.IN_AIR_JUMP_CONSTANT = XML.PlayerSettings.JUMP_CONSTANT * 1.5f; XML.LevelSettings.TERRAIN_FRICTION = float.Parse(XML.physicsNode.Attributes["friction"].Value); } // Fog properties if (XML.fogNode != null) { XML.LevelSettings.fogDensity = float.Parse(XML.fogNode.Attributes["density"].Value); XML.LevelSettings.zMaxDepth = float.Parse(XML.fogNode.Attributes["depth"].Value); XML.LevelSettings.fogColor[0] = float.Parse(XML.fogNode.Attributes["red"].Value); XML.LevelSettings.fogColor[1] = float.Parse(XML.fogNode.Attributes["green"].Value); XML.LevelSettings.fogColor[2] = float.Parse(XML.fogNode.Attributes["blue"].Value); XML.LevelSettings.fogColor[3] = float.Parse(XML.fogNode.Attributes["alpha"].Value); } // Terrain if (XML.terrainNode != null) { terrain.Load(XML.terrainNode); } // SkySphere if (XML.skyNode != null) { skySphere.Load(XML.skyNode); } effect = ElementalGame.content.Load("Shaders/ElementalGPU"); enemyTargetReticle = ElementalGame.content.Load("_textures/TargetMarker"); } // Load all textures and models public void LoadLevel_Stage2() { XML.LoadLevel_Stage2(currentLevelXmlFile); // Initialize the LookupMap class; Initialize after terrain size is set lookupMap = new LookupMap(Terrain.vertexMapSize, Terrain.vertexMapSize); // Audio if (XML.musicNode != null) { Audio.LoadXML(XML.musicNode); } LoadObjects(); // Humans for (int i = 0; i < humans.Count; i++) { if (XML.humanNodes[i] != null) { int x = (int)(Terrain.collisionMapSize * float.Parse(XML.humanNodes[i].Attributes["startx"].Value)); int z = (int)(Terrain.collisionMapSize * float.Parse(XML.humanNodes[i].Attributes["startz"].Value)); humans[i].spawnHeight = terrain.GetTerrainHeight(x / Terrain.terrainScaleFactor, z / Terrain.terrainScaleFactor); humans[i].Load(XML.humanNodes[i]); lookupMap.AddDynamic(humans[i].mass); } } // Bots bots = new List(); Random rand = new Random(); for (int i = 0; i < GameFlow.numberOfBots; i++) { int x = 0; int z = 0; if (XML.botNodes[i] != null) { x = (int)(Terrain.collisionMapSize * float.Parse(XML.botNodes[i].Attributes["startx"].Value)); z = (int)(Terrain.collisionMapSize * float.Parse(XML.botNodes[i].Attributes["startz"].Value)); } else { x = rand.Next(Terrain.collisionMapSize); z = rand.Next(Terrain.collisionMapSize); } bots.Add(new AI(i + humans.Count)); bots[i].spawnHeight = terrain.GetTerrainHeight(x / Terrain.terrainScaleFactor, z / Terrain.terrainScaleFactor); bots[i].Load(XML.botNodes[i]); bots[i].LoadPlayer(XML.playerInfo[0]); bots[i].intelligence = GameFlow.botIntelligence; bots[i].SetSpawnPoint(new Vector3(x, bots[i].spawnHeight + AI.BOT_SPAWN_HEIGHT, z)); lookupMap.AddDynamic(bots[i].mass); } drawList = new List>(4); for (int i = 0; i < 4; i++) { drawList.Add(new LinkedList()); } lastGetDrawList = new List(4); for (int i = 0; i < 4; i++) { lastGetDrawList.Add(humans[i].mass.currentPosition + Vector3.Zero); } } public void LoadObjects() { gameObjectLists = new List(); GameObjectList gameObjectList; if (XML.particlesNode != null) { foreach (XmlNode objectNode in XML.particlesNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.PARTICLE); gameObjectLists.Add(gameObjectList); } } if (XML.propsNode != null) { foreach (XmlNode objectNode in XML.propsNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.PROP); gameObjectLists.Add(gameObjectList); } } if (XML.quadsNode != null) { foreach (XmlNode objectNode in XML.quadsNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.QUAD); gameObjectLists.Add(gameObjectList); } } if (XML.circlesNode != null) { foreach (XmlNode objectNode in XML.circlesNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.CIRCLE); gameObjectLists.Add(gameObjectList); } } if (XML.cubesNode != null) { foreach (XmlNode objectNode in XML.cubesNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.CUBE); gameObjectLists.Add(gameObjectList); } } if (XML.cylindersNode != null) { foreach (XmlNode objectNode in XML.cylindersNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.CYLINDER); gameObjectLists.Add(gameObjectList); } } if (XML.pyramidsNode != null) { foreach (XmlNode objectNode in XML.pyramidsNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.PYRAMID); gameObjectLists.Add(gameObjectList); } } if (XML.spheresNode != null) { foreach (XmlNode objectNode in XML.spheresNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.SPHERE); gameObjectLists.Add(gameObjectList); } } if (XML.trianglesNode != null) { foreach (XmlNode objectNode in XML.trianglesNode.ChildNodes) { gameObjectList = new GameObjectList(); gameObjectList.LoadGenerics(objectNode, this, Mass.ObjectType.TRIANGLE); gameObjectLists.Add(gameObjectList); } } // And so on... as we add more generic object types } public void GetDrawObjects() { for (int i = 0; i < humans.Count; i++) { if (humans[i].IsAlive()) { lookupMap.GetDrawObjects(humans[i].mass, drawList[i]); } } } public void DrawShadow() { // Draw the terrain terrain.DrawShadow(modelManager); for (int i = 0; i < humans.Count; i++) { foreach (Mass massObject in drawList[i]) { if (massObject.gameObjectPointer != null) { massObject.gameObjectPointer.DrawShadow(modelManager); } else { Logging.addNull(); } } } //for (int i = 0; i < gameObjectLists.Count; i++) //{ // gameObjectLists[i].DrawShadow(modelManager); //} } public void Draw(int currentPlayerIndex) { List waterParticleList = new List(); ShaderParameters.light0.SetValue(XML.LevelSettings.lightInfo1); if (XML.SystemSettings.singleLightSource) { ShaderParameters.light1.SetValue(XML.LevelSettings.lightInfo1); } else { ShaderParameters.light1.SetValue(XML.LevelSettings.lightInfo2); } ShaderParameters.fogColor.SetValue(XML.LevelSettings.fogColor); ShaderParameters.fogDensity.SetValue(XML.LevelSettings.fogDensity); ShaderParameters.zMaxDepth.SetValue(XML.LevelSettings.zMaxDepth); terrain.planeRayIntersectionPoint = humans[currentPlayerIndex].lookAtPoint; terrain.terrainModRange = (int)(humans[currentPlayerIndex].particleMassValue / 25); terrain.lightUpTerrainMod = humans[currentPlayerIndex].terrainModEnabled; // Draw the sky skySphere.Draw(modelManager); // Draw the terrain playerPosition = new Vector2(humans[currentPlayerIndex].mass.currentPosition.X / Terrain.terrainScaleFactor, humans[currentPlayerIndex].mass.currentPosition.Z / Terrain.terrainScaleFactor); terrain.Draw(modelManager); // Draw Props, Particles and Quads foreach (Mass massObject in drawList[currentPlayerIndex]) { //Extra pick up point for nulls. if (massObject.gameObjectPointer == null) { Logging.addNull(); } if (massObject.objectType != Mass.ObjectType.PLAYER && massObject.gameObjectPointer != null) { //don't draw particles here massObject.gameObjectPointer.Draw(modelManager); } } // Draw AI bots foreach (Player bot in bots) { if (bot.IsAlive()) { bot.Draw(modelManager); bot.DrawShield(); } } // Draw Humans foreach (Player player in humans) { if (player.IsAlive()) { if (player != humans[currentPlayerIndex]) { player.Draw(modelManager); } } } // Draw generics #if !XBOX360 for (int i = 0; i < gameObjectLists.Count; i++) { gameObjectLists[i].DrawTriangleStrips(modelManager); } #endif ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// // H4k... draws the bounding spheres of all particles //foreach (Mass massObject in drawList[currentPlayerIndex]) //{ // if (massObject.objectType == Mass.ObjectType.PARTICLE && massObject.gameObjectPointer != null) // { // ((Particle)massObject.gameObjectPointer).DrawBoundingSphere(modelManager); // } //} foreach (Player player in humans) { if (player.IsAlive()) { player.DrawEnergyBeam(this); } } // Draw Human Shields (NOTE: draw last for transparency reasons) foreach (Player player in humans) { if (player.IsAlive()) { player.DrawShield(); } } } public void DrawTargets(int currentPlayerIndex) { //draw markers for other players in the game //disable depth check so it always shows up //ElementalGame.graphics.GraphicsDevice.RenderState.DepthBufferEnable = false; Vector3 position = new Vector3(); float distance = 0.0f; float distRatio = 0.0f; float totalScale = 0.25f; //the further the enemy is the smaller and fainter the icon //scale range: 0.25-1.0, alpha range: 50-200 //ElementalGame.graphics.GraphicsDevice.Viewport = ElementalGame.viewportList[currentPlayerIndex]; // Set the View port // Draw AI bots foreach (Player bot in bots) { if (bot.IsAlive()) { distance = Vector3.Distance(bot.mass.currentPosition, humans[currentPlayerIndex].mass.currentPosition); if (distance > XML.PlayerSettings.ENEMY_MARKER_MIN_DISTANCE) { position = ElementalGame.graphics.GraphicsDevice.Viewport.Project(bot.mass.currentPosition, Renderer.matrixProjection, Renderer.matrixModelView, Matrix.Identity); if (position.Z < 1) { position.X -= ElementalGame.graphics.GraphicsDevice.Viewport.X; position.Y -= ElementalGame.graphics.GraphicsDevice.Viewport.Y; if (position.X >= 0 && position.X < ElementalGame.graphics.GraphicsDevice.Viewport.Width && position.Y >= 0 && position.Y < ElementalGame.graphics.GraphicsDevice.Viewport.Height) { distRatio = 1.0f - (distance / XML.PlayerSettings.ENEMY_MARKER_MAX_DISTANCE); //if negative they are too far away if (distRatio < 0) { distRatio = 0; } ElementalGame.spriteBatch.Draw(enemyTargetReticle, new Rectangle((int)(position.X - (enemyTargetReticle.Width * distRatio * totalScale) / 2), (int)(position.Y - (enemyTargetReticle.Height * distRatio * totalScale)), (int)(enemyTargetReticle.Width * distRatio * totalScale), (int)(enemyTargetReticle.Height * distRatio * totalScale)), new Color(255, 255, 255, (byte)(200 * distRatio))); } } } } } // Draw Humans foreach (Player player in humans) { if (player.IsAlive() && player != humans[currentPlayerIndex]) { distance = Vector3.Distance(player.mass.currentPosition, humans[currentPlayerIndex].mass.currentPosition); if (distance > XML.PlayerSettings.ENEMY_MARKER_MIN_DISTANCE) { position = ElementalGame.graphics.GraphicsDevice.Viewport.Project(player.mass.currentPosition, Renderer.matrixProjection, Renderer.matrixModelView, Matrix.Identity); if (position.Z < 1) { position.X -= ElementalGame.graphics.GraphicsDevice.Viewport.X; position.Y -= ElementalGame.graphics.GraphicsDevice.Viewport.Y; if (position.X >= 0 && position.X < ElementalGame.graphics.GraphicsDevice.Viewport.Width && position.Y >= 0 && position.Y < ElementalGame.graphics.GraphicsDevice.Viewport.Height) { distRatio = 1.0f - (distance / XML.PlayerSettings.ENEMY_MARKER_MAX_DISTANCE); //if negative they are too far away if (distRatio < 0) { distRatio = 0; } ElementalGame.spriteBatch.Draw(enemyTargetReticle, new Rectangle((int)(position.X - (enemyTargetReticle.Width * distRatio * totalScale) / 2), (int)(position.Y - (enemyTargetReticle.Height * distRatio * totalScale)), (int)(enemyTargetReticle.Width * distRatio * totalScale), (int)(enemyTargetReticle.Height * distRatio * totalScale)), new Color(255, 255, 255, (byte)(200 * distRatio))); } } } } } } // Call all GameObject Updates to handle gravity and motion public void UpdatePosition() { // Modify terrain if changed terrain.Update(this); // Rotate Skysphere skySphere.Update(this); // Update Dynamic Props, Particles, and Quads lookupMap.UpdateDynamic(this); //quadManager.Update(this); for (int i = 0; i < gameObjectLists.Count; i++) { gameObjectLists[i].Update(this); } } // Attack Methods // public void Attack(int playerID, Particle.ParticleType type, Vector3 initialPosition, Vector3 direction, int particleMassValue, int particleThermalValue) { XmlNode particlesNode = null; // Set it's properties particle = new Particle(darkMatter[darkMatterIterator++]); particle.particleType = type; particle.mass.objectType = Mass.ObjectType.PARTICLE; particle.Load(particlesNode); particle.mass.AddForce(direction * XML.LevelSettings.DIRECT_ATTACK_FORCE); particle.mass.SetPosition(initialPosition + (XML.LevelSettings.PARTICLE_START_DISTANCE * direction), initialPosition + ((XML.LevelSettings.PARTICLE_START_DISTANCE + 10) * direction)); particle.mass.lastPosition = Vector3.Zero + initialPosition; particle._boundingSphere.Center = particle.mass.currentPosition; particle.ownerID = playerID; particle.distanceTravelled = 0.0f; particle.waveRadius = 1.0f; direction.Normalize(); particle.mass.normalVector = Vector3.Zero + direction; particle.mass.isMoving = true; particle.hasCollided = -1; particle.hurtOwner = false; //Start the timer by which it starts hurting its owner particle.hurtOwnerTimer = Stopwatch.StartNew(); particle.hasBeenShot = true; // Shift from 0 to 100 to -1 to 1 particle.mass.energy = ((float)particleThermalValue * 2 - 75) / 75; if (particle.mass.energy != 0.0f) { particle.mass.isChanging = true; } // Shift and Apply DPad Values to Particle // particleMassValue is between 1 and 75 float massRatio =(particleMassValue / 75.0f); particle.mass.scale = massRatio * 30.0f + 3;//old way: particleMassValue * 0.50f; switch (type) { case Particle.ParticleType.Air: particle.mass.mass = AirProperties.WIND_MASS * massRatio + 1; break; case Particle.ParticleType.Earth: particle.mass.mass = EarthProperties.EARTH_MASS * massRatio + 1; break; case Particle.ParticleType.Water: particle.mass.mass = WaterProperties.WATER_MASS * massRatio + 1; break; } //if (particle.mass.mass < 1.5f) //{ // particle.mass.mass = 1.5f; //} particle._boundingSphere.Radius = particle.mass.scale; gameObjectLists[0].AddNewObject(particle); lookupMap.SetPosition(particle.mass); // Move it to the dynamic list lookupMap.AddDynamic(particle.mass); Vector4 gpu_particleType = new Vector4(0); if (particle.particleType == Particle.ParticleType.Earth) { gpu_particleType.Y = 0.0f; } // Earth = x0xx if (particle.particleType == Particle.ParticleType.Water) { gpu_particleType.Y = 1.0f; } // Water = x1xx if (particle.particleType == Particle.ParticleType.Air) { gpu_particleType.Y = 2.0f; } // Gas = x2xx gpu_particleType.Z = (particle.mass.energy / 2.0f) + 0.5f; // Fire = xxNx gpu_particleType.W = particle.waveRadius; particle.objectValues = new VertexFogBinormalTangentWeightTess(); Matrix matrix = Matrix.CreateScale(particle.mass.scale) * Matrix.CreateFromQuaternion(particle.mass.currentRotation) * Matrix.CreateTranslation(particle.mass.currentPosition); particle.objectValues.Color = new Vector4(matrix.M11, matrix.M12, matrix.M13, matrix.M14); // Store the first row particle.objectValues.Binormal = new Vector4(matrix.M21, matrix.M22, matrix.M23, matrix.M24); // Store the second row particle.objectValues.Tangent = new Vector4(matrix.M31, matrix.M32, matrix.M33, matrix.M34); // Store the third row particle.objectValues.BlendWeight = new Vector4(matrix.M41, matrix.M42, matrix.M43, matrix.M44); // Store the fourth row particle.objectValues.Fog = new Vector4(0.0f, gpu_particleType.Y, gpu_particleType.Z, gpu_particleType.W); // Store the scale particle.dissipationTimer.Reset(); particle.dissipationTimer.Start(); } /* // Test Function to update energy distribution public void UpdateHeatDissipation(ObjectLibrary objectLibrary, float dt) { List newParticlesToAddToList = new List(); foreach (Particle particle in particles) { particle.mass.UpdatePosition(dt); } // Iterate through dynamic particles for (int i = 0; i < particles.Count; i++) { Particle particle = particles[i]; // List to store the pointers to neighboring particles List neighboringParticleList = new List(); // Used to calculate the average value of all neighboring particles float averageEnergy = particle.mass.energy; // Get the list of neighboring particle pointers neighboringParticleList = GetSurroundingParticles(particle.mass.currentPosition, objectLibrary); // Calculate their total energy foreach (Particle neigborParticle in neighboringParticleList) { averageEnergy += neigborParticle.mass.energy; } // Find the average averageEnergy /= neighboringParticleList.Count + 1; // If the average value is not equal to zero then we have some heat dissipation to do if (averageEnergy != particle.mass.energy && neighboringParticleList.Count != 0) { // Iterate through neighboring particles foreach (Particle neigborParticle in neighboringParticleList) { // If their value is not equal to the average set it and set the flag if (neigborParticle.mass.energy != averageEnergy) { neigborParticle.mass.SetEnergy(averageEnergy); if (!neigborParticle.mass.isChanging) { neigborParticle.mass.isChanging = true; newParticlesToAddToList.Add(neigborParticle); } } } // Set the starting particle's energy to average value as well particle.mass.SetEnergy(averageEnergy); } else if (particle.mass.energy != 0.0f) { DissipateHeat(particle); } else { // The particle and it's neighbors are in equilibrium so remove it from the list particle.mass.isChanging = false; if (!particle.mass.isMoving) { // Particle needs to be put back into the static list MoveParticle(particles, particles, particle); } else { particles.Remove(particle); } i--; } } foreach (Particle newParticle in newParticlesToAddToList) { if (particles.Contains(newParticle)) { continue; } if (newParticle.mass.isMoving) { CopyParticle(particles, particles, newParticle); } else { MoveParticle(particles, particles, newParticle); } } } public void StateChange(ObjectLibrary objectLibrary, float elementUse, GameObject gameObject) { Particle particle = (Particle)gameObject; gameObject.mass.ChangeEnergy(elementUse / 2.0f); if (gameObject.mass.isChanging) { return; } else if (gameObject.mass.isMoving) { // Particle is in the dynamic list so we need to copy it to the Thermal list switch (particle.particleType) { case Particle.ParticleType.Air: { objectLibrary.particleManager.air.CopyParticle(objectLibrary.particleManager.air.dynamicParticles, objectLibrary.particleManager.air.thermalParticles, particle); break; } case Particle.ParticleType.Water: { objectLibrary.particleManager.water.CopyParticle(objectLibrary.particleManager.water.dynamicParticles, objectLibrary.particleManager.water.thermalParticles, particle); break; } case Particle.ParticleType.Earth: { objectLibrary.particleManager.earth.CopyParticle(objectLibrary.particleManager.earth.dynamicParticles, objectLibrary.particleManager.earth.thermalParticles, particle); break; } } gameObject.mass.isChanging = true; } else { // It's in the static list, so move the particle to the dynamic list switch (particle.particleType) { case Particle.ParticleType.Air: { objectLibrary.particleManager.air.MoveParticle(objectLibrary.particleManager.air.staticParticles, objectLibrary.particleManager.air.thermalParticles, particle); break; } case Particle.ParticleType.Water: { objectLibrary.particleManager.water.MoveParticle(objectLibrary.particleManager.water.staticParticles, objectLibrary.particleManager.water.thermalParticles, particle); break; } case Particle.ParticleType.Earth: { objectLibrary.particleManager.earth.MoveParticle(objectLibrary.particleManager.earth.staticParticles, objectLibrary.particleManager.earth.thermalParticles, particle); break; } } gameObject.mass.isChanging = true; } } public void UpdateLightPosition() { // Light goes 180 degrees back and forth (never below) //if (Math.Abs(lightMoveAngle1) > Math.PI / 2.0f) //{ // LIGHT_MOVE_SPEED1 = -LIGHT_MOVE_SPEED1; //} // Light goes full 360 degrees // Update light source position if (lightMoveAngle1 < 0) { //reset to 2PI lightMoveAngle1 = Math.PI * 2.0f; } else if (lightMoveAngle1 > Math.PI * 2.0f) { //reset to zero lightMoveAngle1 = 0.0f; } // Update the angle of the light lightMoveAngle1 += LIGHT_MOVE_SPEED1; //Calculate the X and Y based on the angle float dx = (float)(lightDistance1 * Math.Sin(lightMoveAngle1)); float dz = (float)(lightDistance1 * Math.Cos(lightMoveAngle1)); lightInfo1.M11 = dx + (Terrain.collisionMapSize / 2.0f); lightInfo1.M13 = dz +(Terrain.collisionMapSize / 2.0f); } */ } }