//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {License Information: Creative Commons} //--------------------------------------------------------------------------------------------------------------------------------------------------- namespace ElementalGame { #region Using Statements using System; using System.Collections.Generic; using System.Diagnostics; 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.Threading; #endregion class UpdatePositionThreads { Thread thread1; Thread thread2; Thread thread3; Thread thread4; public UpdatePositionThreads() { } public void StartThreads(ObjectLibrary.UpdateThreadStruct updateThreadStruct) { thread1 = new Thread(new ParameterizedThreadStart(ThreadedUpdatePositions1)); //thread2 = new Thread(new ParameterizedThreadStart(ThreadedUpdatePositions2)); //thread3 = new Thread(new ParameterizedThreadStart(ThreadedUpdatePositions3)); //thread4 = new Thread(new ParameterizedThreadStart(ThreadedUpdatePositions4)); thread1.Priority = ThreadPriority.AboveNormal; //thread2.Priority = ThreadPriority.AboveNormal; //thread3.Priority = ThreadPriority.AboveNormal; //thread4.Priority = ThreadPriority.AboveNormal; thread1.Start(updateThreadStruct); //thread2.Start(updateThreadStruct); //thread3.Start(updateThreadStruct); //thread4.Start(updateThreadStruct); } public bool ThreadsFinished() { if (thread1.IsAlive) { return false; } return true; } public void ThreadedUpdatePositions1(object obj) { ObjectLibrary.UpdateThreadStruct terrainStruct = (ObjectLibrary.UpdateThreadStruct)obj; if (terrainStruct == null) { return; } else { terrainStruct.objectLibrary.terrain.Update(terrainStruct.objectLibrary, terrainStruct.dt); // } //} //public void ThreadedUpdatePositions2(object obj) //{ // ObjectLibrary.UpdateThreadStruct propStruct = (ObjectLibrary.UpdateThreadStruct)obj; // if (propStruct == null) // { // return; // } // else // { terrainStruct.objectLibrary.propManager.Update(terrainStruct.objectLibrary, terrainStruct.dt); // } //} //public void ThreadedUpdatePositions3(object obj) //{ // ObjectLibrary.UpdateThreadStruct particleStruct = (ObjectLibrary.UpdateThreadStruct)obj; // if (particleStruct == null) // { // return; // } // else // { terrainStruct.objectLibrary.particleManager.UpdatePosition(terrainStruct.objectLibrary, terrainStruct.dt); // } //} //public void ThreadedUpdatePositions4(object obj) //{ // ObjectLibrary.UpdateThreadStruct othersStruct = (ObjectLibrary.UpdateThreadStruct)obj; // if (othersStruct == null) // { // return; // } // else // { terrainStruct.objectLibrary.skySphere.Update(terrainStruct.objectLibrary, terrainStruct.dt); // Update Human positions foreach (Human player in terrainStruct.objectLibrary.humans) { player.Update(terrainStruct.objectLibrary, terrainStruct.dt); } // Update AI positions foreach (AI player in terrainStruct.objectLibrary.bots) { player.Update(terrainStruct.objectLibrary, terrainStruct.dt); } } } } }