public static Map.Map RegionSpawnPointTest(SlimDX.Direct3D9.Device device) { var m = Medium(device); var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { new Vector3(30, 30, 0), new Vector3(30, 40, 0), new Vector3(40, 40, 0), new Vector3(40, 30, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /*m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 10, * Region = "test", * SpawnType = "Grunt", * Period = 1, * Position = new Vector3(35, 35, 0) * });*/ return(m); }
protected override void StartPerform() { base.StartPerform(); Game.Instance.CameraController.LargeShake(); var forward = Vector3.Normalize(EndPosition - StartPosition); var right = Vector3.Normalize(Vector3.Cross(new Vector3(forward.X, forward.Y, 0), Vector3.UnitZ)); var tl = StartPosition + right * Width / 2f; var tr = StartPosition - right * Width / 2f; var bl = EndPosition + right * Width / 2f; var br = EndPosition - right * Width / 2f; region = new Common.Bounding.Region { Nodes = new Common.Bounding.RegionNode[] { new Common.Bounding.RegionNode(new Vector3[] { tl, tr, br }), new Common.Bounding.RegionNode(new Vector3[] { tl, br, bl }), } }; Game.Instance.Scene.Add(lavaDitch = new Props.LavaDitchWithEffects1 { Translation = StartPosition, Rotation = Quaternion.RotationAxis(Vector3.UnitZ, (float)Common.Math.AngleFromVector3XY(forward)) }); #if LAVA_DITCH_DISPLAY_ATTACK_AREA pebbles.Clear(); for (float y = Math.Min(StartPosition.Y, EndPosition.Y) - 10; y < Math.Max(StartPosition.Y, EndPosition.Y) + 10; y += 0.25f) { for (float x = Math.Min(StartPosition.X, EndPosition.X) - 10; x < Math.Max(StartPosition.Y, EndPosition.Y) + 10; x += 0.25f) { if (region.GetNodeAt(new Vector3(x, y, 0)) != null) { Props.Pebble1 p; Game.Instance.Scene.Add(p = new Props.Pebble1 { Translation = new Vector3(x, y, StartPosition.Z), Scale = new Vector3(1, 1, 10) }); pebbles.Add(p); } } } #endif effects.Clear(); }
public void Draw(Matrix world, Common.Bounding.Region bounding, Color color) { if (bounding.Nodes == null) { return; } var mesh = View.Content.Peek <SlimDX.Direct3D9.Mesh>(new Content.MeshConcretize { MeshDescription = new Software.Meshes.FromBoundingRegion { BoundingRegion = bounding }, Layout = Software.Vertex.PositionNormalTexcoord.Instance }); var text = View.Content.Peek <SlimDX.Direct3D9.Texture>(new Content.TextureConcretizer { TextureDescription = new Software.Textures.SingleColorTexture(color) }); View.Device9.SetTexture(0, text); View.Device9.SetTransform(TransformState.World, world); mesh.DrawSubset(0); }
public NavMesh() { BoundingRegion = new Common.Bounding.Region(); }
public static Map.Map ChallengeACleric(SlimDX.Direct3D9.Device device) { var m = Medium(device); var center = new Vector3(m.Settings.Size.Width / 2f, m.Settings.Size.Height / 2f, 0); m.MainCharacter.Translation = center + new Vector3(20, 20, 0); m.MainCharacter.PistolAmmo = 20; var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { center + new Vector3(-5, -5, 0), center + new Vector3(-5, +5, 0), center + new Vector3(5, 5, 0), center + new Vector3(5, -5, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /*m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 1, * Region = "test", * SpawnType = "Cleric", * Period = 0, * Translation = center + new Vector3(-15, -15, 0), * InitDelay = 5 * }); * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 20, * Region = "test", * SpawnType = "Grunt", * Period = 3, * Translation = center + new Vector3(10, -10, 0), * InitDelay = 0 * }); * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 20, * Region = "test", * SpawnType = "Grunt", * Period = 3, * Translation = center + new Vector3(10, 10, 0), * InitDelay = 0 * }); * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 20, * Region = "test", * SpawnType = "Grunt", * Period = 3, * Translation = center + new Vector3(-10, 10, 0), * InitDelay = 0 * });*/ for (int y = -3; y < 3; y++) { for (int x = -3; x < 3; x++) { m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = center + new SlimDX.Vector3(x * 3, y * 3, 0), State = Map.UnitState.RaisableCorpse }); } } return(m); }
public static Map.Map ChallengeSuddenlyMongrels(SlimDX.Direct3D9.Device device) { var m = Medium(device); m.MainCharacter.Translation = new Vector3(m.Settings.Size.Width / 2f, m.Settings.Size.Height / 2f, 0); m.MainCharacter.PistolAmmo = 20; m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation - new SlimDX.Vector3(5, 0, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation + new SlimDX.Vector3(5, 0, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation - new SlimDX.Vector3(0, 5, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation + new SlimDX.Vector3(0, 5, 0) }); var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { m.MainCharacter.Translation + new Vector3(-10, -10, 0), m.MainCharacter.Translation + new Vector3(-10, +10, 0), m.MainCharacter.Translation + new Vector3(10, 10, 0), m.MainCharacter.Translation + new Vector3(10, -10, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /* * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 2, * Region = "test", * SpawnType = "Mongrel", * Period = 1, * Translation = m.MainCharacter.Translation + new Vector3(15, -15, 0), * InitDelay = 1 * }); * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 2, * Region = "test", * SpawnType = "Mongrel", * Period = 1, * Translation = m.MainCharacter.Translation + new Vector3(-15, -15, 0), * InitDelay = 1 * }); * m.DynamicsRoot.AddChild(new Map.SpawningPoint * { * SpawnCount = 2, * Region = "test", * SpawnType = "Mongrel", * Period = 1, * Translation = m.MainCharacter.Translation + new Vector3(-15, 15, 0), * InitDelay = 1 * });*/ return(m); }
void Load(Common.Bounding.Region region) { Clear(); hasChanged = false; this.region = region; if (region == null || region.Nodes == null) return; Dictionary<Vector3, Vertex> posToVertex = new Dictionary<Vector3, Vertex>(); Dictionary<Common.Bounding.RegionNode, Face> nodeToFace = new Dictionary<Common.Bounding.RegionNode, Face>(); for (int i = 0; i < region.Nodes.Length; i++) { var node = region.Nodes[i]; foreach (Vector3 v in node.polygon) { if (!posToVertex.ContainsKey(v)) { Vertex ve = new Vertex(this) { Translation = v }; vertices.Add(ve); posToVertex.Add(v, ve); } } Face face = new Face(this) { Vertices = new Vertex[] { posToVertex[node.polygon[0]], posToVertex[node.polygon[1]], posToVertex[node.polygon[2]] }, Id = i }; posToVertex[node.polygon[0]].Faces.Add(face); posToVertex[node.polygon[1]].Faces.Add(face); posToVertex[node.polygon[2]].Faces.Add(face); faces.Add(face); nodeToFace.Add(node, face); } foreach (var node in region.Nodes) { foreach (Common.Bounding.RegionEdge edge in node.Edges.Values) { Face left = nodeToFace[edge.Left]; Face right = nodeToFace[edge.Right]; if (!left.ContainsEdgeTo(right) && !right.ContainsEdgeTo(left)) { int index = 0; while (left.Vertices[index].Translation != edge.PointA) index++; left.Edges.Add(new Edge { Left = left, Right = right, LeftIndex = index }); } } } }
private void Clear() { vertices.Clear(); faces.Clear(); region = null; }
public static Map.Map RegionSpawnPointTest(SlimDX.Direct3D9.Device device) { var m = Medium(device); var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { new Vector3(30, 30, 0), new Vector3(30, 40, 0), new Vector3(40, 40, 0), new Vector3(40, 30, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /*m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 10, Region = "test", SpawnType = "Grunt", Period = 1, Position = new Vector3(35, 35, 0) });*/ return m; }
public static Map.Map ChallengeSuddenlyMongrels(SlimDX.Direct3D9.Device device) { var m = Medium(device); m.MainCharacter.Translation = new Vector3(m.Settings.Size.Width/2f, m.Settings.Size.Height/2f, 0); m.MainCharacter.PistolAmmo = 20; m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation - new SlimDX.Vector3(5, 0, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation + new SlimDX.Vector3(5, 0, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation - new SlimDX.Vector3(0, 5, 0) }); m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = m.MainCharacter.Translation + new SlimDX.Vector3(0, 5, 0) }); var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { m.MainCharacter.Translation + new Vector3(-10, -10, 0), m.MainCharacter.Translation + new Vector3(-10, +10, 0), m.MainCharacter.Translation + new Vector3(10, 10, 0), m.MainCharacter.Translation + new Vector3(10, -10, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /* m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 2, Region = "test", SpawnType = "Mongrel", Period = 1, Translation = m.MainCharacter.Translation + new Vector3(15, -15, 0), InitDelay = 1 }); m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 2, Region = "test", SpawnType = "Mongrel", Period = 1, Translation = m.MainCharacter.Translation + new Vector3(-15, -15, 0), InitDelay = 1 }); m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 2, Region = "test", SpawnType = "Mongrel", Period = 1, Translation = m.MainCharacter.Translation + new Vector3(-15, 15, 0), InitDelay = 1 });*/ return m; }
public static Map.Map ChallengeACleric(SlimDX.Direct3D9.Device device) { var m = Medium(device); var center = new Vector3(m.Settings.Size.Width / 2f, m.Settings.Size.Height / 2f, 0); m.MainCharacter.Translation = center + new Vector3(20, 20, 0); m.MainCharacter.PistolAmmo = 20; var r = new Common.Bounding.Region(); r.Nodes = new Common.Bounding.RegionNode[1]; r.Nodes[0] = new Common.Bounding.RegionNode(new Vector3[] { center + new Vector3(-5, -5, 0), center + new Vector3(-5, +5, 0), center + new Vector3(5, 5, 0), center + new Vector3(5, -5, 0), }); m.Regions.Add(new Map.Region { Name = "test", BoundingRegion = r }); throw new NotImplementedException(); /*m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 1, Region = "test", SpawnType = "Cleric", Period = 0, Translation = center + new Vector3(-15, -15, 0), InitDelay = 5 }); m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 20, Region = "test", SpawnType = "Grunt", Period = 3, Translation = center + new Vector3(10, -10, 0), InitDelay = 0 }); m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 20, Region = "test", SpawnType = "Grunt", Period = 3, Translation = center + new Vector3(10, 10, 0), InitDelay = 0 }); m.DynamicsRoot.AddChild(new Map.SpawningPoint { SpawnCount = 20, Region = "test", SpawnType = "Grunt", Period = 3, Translation = center + new Vector3(-10, 10, 0), InitDelay = 0 });*/ for (int y = -3; y < 3; y++) for (int x = -3; x < 3; x++) m.DynamicsRoot.AddChild(new Map.Units.Grunt { Translation = center + new SlimDX.Vector3(x * 3, y * 3, 0), State = Map.UnitState.RaisableCorpse }); return m; }
protected override void StartPerform() { base.StartPerform(); Game.Instance.CameraController.LargeShake(); var forward = Vector3.Normalize(EndPosition - StartPosition); var right = Vector3.Normalize(Vector3.Cross(new Vector3(forward.X, forward.Y, 0), Vector3.UnitZ)); var tl = StartPosition + right * Width / 2f; var tr = StartPosition -right * Width / 2f; var bl = EndPosition + right * Width / 2f; var br = EndPosition -right * Width / 2f; region = new Common.Bounding.Region { Nodes = new Common.Bounding.RegionNode[] { new Common.Bounding.RegionNode(new Vector3[] { tl, tr, br }), new Common.Bounding.RegionNode(new Vector3[] { tl, br, bl }), } }; Game.Instance.Scene.Add(lavaDitch = new Props.LavaDitchWithEffects1 { Translation = StartPosition, Rotation = Quaternion.RotationAxis(Vector3.UnitZ, (float)Common.Math.AngleFromVector3XY(forward)) }); #if LAVA_DITCH_DISPLAY_ATTACK_AREA pebbles.Clear(); for (float y = Math.Min(StartPosition.Y, EndPosition.Y) - 10; y < Math.Max(StartPosition.Y, EndPosition.Y) + 10; y += 0.25f) for (float x = Math.Min(StartPosition.X, EndPosition.X) - 10; x < Math.Max(StartPosition.Y, EndPosition.Y) + 10; x += 0.25f) if (region.GetNodeAt(new Vector3(x, y, 0)) != null) { Props.Pebble1 p; Game.Instance.Scene.Add(p = new Props.Pebble1 { Translation = new Vector3(x, y, StartPosition.Z), Scale = new Vector3(1, 1, 10) }); pebbles.Add(p); } #endif effects.Clear(); }
void Load(Common.Bounding.Region region) { Clear(); hasChanged = false; this.region = region; if (region == null || region.Nodes == null) { return; } Dictionary <Vector3, Vertex> posToVertex = new Dictionary <Vector3, Vertex>(); Dictionary <Common.Bounding.RegionNode, Face> nodeToFace = new Dictionary <Common.Bounding.RegionNode, Face>(); for (int i = 0; i < region.Nodes.Length; i++) { var node = region.Nodes[i]; foreach (Vector3 v in node.polygon) { if (!posToVertex.ContainsKey(v)) { Vertex ve = new Vertex(this) { Translation = v }; vertices.Add(ve); posToVertex.Add(v, ve); } } Face face = new Face(this) { Vertices = new Vertex[] { posToVertex[node.polygon[0]], posToVertex[node.polygon[1]], posToVertex[node.polygon[2]] }, Id = i }; posToVertex[node.polygon[0]].Faces.Add(face); posToVertex[node.polygon[1]].Faces.Add(face); posToVertex[node.polygon[2]].Faces.Add(face); faces.Add(face); nodeToFace.Add(node, face); } foreach (var node in region.Nodes) { foreach (Common.Bounding.RegionEdge edge in node.Edges.Values) { Face left = nodeToFace[edge.Left]; Face right = nodeToFace[edge.Right]; if (!left.ContainsEdgeTo(right) && !right.ContainsEdgeTo(left)) { int index = 0; while (left.Vertices[index].Translation != edge.PointA) { index++; } left.Edges.Add(new Edge { Left = left, Right = right, LeftIndex = index }); } } } }