public override void OnInitialise() { SystemCore.CursorVisible = true; SystemCore.ActiveScene.SetUpBasicAmbientAndKey(); cameraObject = new GameObject(); //give it some random ID to keep it out the range of the doom objects cameraObject.ID = 990000; cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 0.25f, 1000.0f, false)); SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject); SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>()); cameraObject.Transform.AbsoluteTransform = Matrix.CreateWorld(new Vector3(0, -500, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)); var file = new FileInfo(filePath); using (var fs = file.OpenRead()) { var doomWad = DoomWad.FromFile(filePath); string desiredLevel = "E1M1"; int levelMarker = doomWad.Index.FindIndex(x => x.Name.Contains(desiredLevel)); for (int i = levelMarker + 1; i < doomWad.NumIndexEntries; i++) { var currentIndex = doomWad.Index[i]; if (currentIndex.Name.Contains("E1M2")) { break; } if (currentIndex.Name == ("SECTORS\0")) { sectors = currentIndex.Contents as DoomWad.Sectors; } if (currentIndex.Name.Contains("BLOCKMAP")) { blockMap = currentIndex.Contents as DoomWad.Blockmap; } if (currentIndex.Name.Contains("SIDEDEF")) { sideDefs = currentIndex.Contents as DoomWad.Sidedefs; } if (currentIndex.Name.Contains("VERTEX")) { vertices = currentIndex.Contents as DoomWad.Vertexes; } if (currentIndex.Name.Contains("THING")) { things = currentIndex.Contents as DoomWad.Things; } if (currentIndex.Name.Contains("LINEDEF")) { lineDefs = currentIndex.Contents as DoomWad.Linedefs; } } } worldObjects = new Dictionary <int, GameObject>(); apiHandler = new DoomAPIHandler(restHost, restPort); aStar = new AStar(); GenerateNavStructures(); base.OnInitialise(); }
public DoomCombatComponent(DoomMapHandler mapHandler, DoomAPIHandler apiHandler, Dictionary <int, GameObject> worldObjects) { this.mapHandler = mapHandler; this.apiHandler = apiHandler; this.worldObjects = worldObjects; }
public override void OnInitialise() { SystemCore.CursorVisible = true; SystemCore.ActiveScene.SetUpBasicAmbientAndKey(); cameraObject = new GameObject(); worldObjects = new Dictionary <int, GameObject>(); //give it some random ID to keep it out the range of the doom objects cameraObject.ID = 990000; cameraObject.AddComponent(new ComponentCamera(MathHelper.PiOver4, SystemCore.GraphicsDevice.Viewport.AspectRatio, 0.25f, 1000.0f, false)); SystemCore.GameObjectManager.AddAndInitialiseGameObject(cameraObject); SystemCore.SetActiveCamera(cameraObject.GetComponent <ComponentCamera>()); cameraObject.Transform.AbsoluteTransform = Matrix.CreateWorld(new Vector3(0, -500, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)); mapHandler = new DoomMapHandler(filePath, "E1M" + level.ToString(), "E1M" + (level + 1).ToString()); mapHandler.ParseWad(); mapHandler.InitialiseFloodFill(); apiHandler = new DoomAPIHandler(url, port); apiHandler.CreateRegularRequest(1000, new RestRequest("player"), x => { UpdatePlayer(x); }); apiHandler.CreateRegularRequest(4000, new RestRequest("world/objects"), x => { foreach (GameObject worldObject in worldObjects.Values) { SystemCore.GameObjectManager.RemoveObject(worldObject); } worldObjects.Clear(); IDictionary <string, object> jsonValues = Json.JsonParser.FromJson(x.Content); List <object> objectList = jsonValues["array0"] as List <object>; List <string> types = new List <string>(); foreach (object o in objectList) { double id, angle, health, distance, xpos, ypos; string type; ParseObjectData(o, out id, out type, out angle, out health, out distance, out xpos, out ypos); if (id == 0) { continue; } if (id == playerId) { continue; } GameObject worldObject; DoomComponent component; CreateLocalWorldObject(id, type, out worldObject, out component); UpdateObject(worldObject, angle, xpos, ypos, type, health, distance); types.Add(type); } }); pickUpTypes = new List <string>(); base.OnInitialise(); }
public DoomMovementComponent(DoomMapHandler mapHandler, DoomAPIHandler apiHandler) { this.mapHandler = mapHandler; this.apiHandler = apiHandler; }