public World() { gameObjects = new List<IGameObject>(); respawnPoints = new List<RespawnPoint>(); updateableObjects = new List<IUpdateable>(); temporaryObjects = new List<ITemporaryObject>(); players = new List<Player>(); assassinPlayers = new List<Player>(); knightPlayers = new List<Player>(); physicsSimulator = new RigidBodySimulator(); collisionDetector = physicsSimulator.CollisionDetector; collisionDetector.OnCollision += new CollisionHandler(this.OnCollision); physicsSimulator.Paused = true; physicsSimulator.DoAngularDrag = false; physicsSimulator.DoLinearDrag = false; physicsSimulator.DoGravity = false; if (_instance != null) { _instance.Close(); } _instance = this; }
public static void InitializeTest() { World world = new World(); CollisionMesh mesh = Resources.ResourceCache.Instance.GetCollisionMesh("castle.cm"); CollisionOctree tree = CollisionOctree.FromMesh(mesh, 0, 0, 0, 30, 2, 200); StaticMesh worldMesh = new StaticMesh(tree, CollisionDataType.CollisionOctree, Resources.ResourceCache.Instance.GetRenderingData("castle2.x"), new MyVector(0, 0, 0)); world.AddObject(worldMesh); }
public void Close() { this.gameObjects.Clear(); this.players.Clear(); this.respawnPoints.Clear(); this.temporaryObjects.Clear(); this.updateableObjects.Clear(); _instance = null; }
//public static World FromFile(string fileName) //{ // World world = new World(); // MapData data = MapData.FromFile(fileName); // world.gameObjects.AddRange(data.GameObjects); // foreach (GameObject obj in data.GameObjects) // { // world.AddObject(obj); // } // return world; //} public static void FromFileBkg(string fileName, ProgressReporter reporter) { World world = new World(); MapData.FromFileBkg(fileName, reporter); if (reporter.Data == null) throw new Exception("nie udao sie wczytac mapy!!"); //zle poszlo //reporter.Complete = false; foreach (IGameObject obj in ((MapData)reporter.Data).GameObjects) { //if (obj is RespawnPoint) //{ // world.respawnPoints.Add(obj as RespawnPoint); // //((RespawnPoint)obj). //} //else //{ world.AddObject(obj); //} //prawdopodobnie zbêdne //if (obj is IUpdateable) //{ // GM.AppWindow.AddUpdateableItem(obj as IUpdateable); //} } world.environment = Graphics.Environment.FromFile(fileName); reporter.Data = world; reporter.Complete = true; }