private void Generate() { //Walls //for (var i = 0; i < 1; i++) //{ // var x = m_map.Random.Next(0, m_map.ZoneSize.X); // var y = m_map.Random.Next(0, m_map.ZoneSize.Y); // var width = m_map.Random.Next(10, 100); // var height = m_map.Random.Next(10, 100); // //var x = m_map.ZoneSize.X / 2 + 50; // //var y = m_map.ZoneSize.Y / 2 + 50; // //var width = 50; // //var height = 50; // var p1 = new Vector2(x, y); // var p2 = new Vector2(x + width, y); // var p3 = new Vector2(x + width, y + height); // var p4 = new Vector2(x, y + height); // Walls.Add( // new Wall( // new List<Segment>() // { // new Segment(p1, p2), // new Segment(p2, p3), // new Segment(p3, p4), // new Segment(p4, p1) // } // ) // ); //} //Trees for (var i = 0; i < 3; i++) { var x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); var y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t1 = new Tree1(); t1.SetPosition(new Vector2(x, y)); AddTree(t1); y -= (int)(t1.Box.Y / 3f); var p1 = new Vector2(x - t1.Box.X / 6, y); var p2 = new Vector2(x + t1.Box.X / 6, y); var p3 = new Vector2(x, y - t1.Box.Y / 6); var p4 = new Vector2(x, y + t1.Box.Y / 6); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t2 = new Tree2(); t2.SetPosition(new Vector2(x, y)); AddTree(t2); y -= (int)(t2.Box.Y / 3f); p1 = new Vector2(x - t2.Box.X / 6, y); p2 = new Vector2(x + t2.Box.X / 6, y); p3 = new Vector2(x, y - t2.Box.Y / 6); p4 = new Vector2(x, y + t2.Box.Y / 6); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); x = m_map.Random.Next(0 + 50, m_map.ZoneSize.X - 50); y = m_map.Random.Next(0 + 50, m_map.ZoneSize.Y - 50); var t3 = new Tree3(); t3.SetPosition(new Vector2(x, y)); AddTree(t3); y -= (int)(t3.Box.Y / 4f); p1 = new Vector2(x - t3.Box.X / 4, y); p2 = new Vector2(x + t3.Box.X / 4, y); p3 = new Vector2(x, y - t3.Box.Y / 4); p4 = new Vector2(x, y + t3.Box.Y / 4); Walls.Add( new Wall( new List <Segment>() { new Segment(p1, p2), new Segment(p3, p4) } ) ); } //Fire //var peX = m_map.Random.Next((int)(m_map.ZoneSize.X * 0.1f), (int)(m_map.ZoneSize.X * 0.9f)); //var peY = m_map.Random.Next((int)(m_map.ZoneSize.Y * 0.1f), (int)(m_map.ZoneSize.Y * 0.9f)); //ParticleEngine = new ParticleEngine(new List<Texture2D>(), // new Vector2(peX, peY), // new Vector2(0, 20), // 150, // 0.2f); var peX = m_map.Random.Next((int)(m_map.ZoneSize.X * 0.1f), (int)(m_map.ZoneSize.X * 0.9f)); var peY = m_map.Random.Next((int)(m_map.ZoneSize.Y * 0.1f), (int)(m_map.ZoneSize.Y * 0.9f)); var firePosition = new Vector2(peX, peY); FireCamp = new FireCamp(); FireCamp.SetPosition(firePosition); //Lights for (var i = 0; i < 1; i++) { //var x = m_map.Random.Next(0, m_map.ZoneSize.X); //var y = m_map.Random.Next(0, m_map.ZoneSize.Y); //var x = m_map.ZoneSize.X / 2; //var y = m_map.ZoneSize.Y / 2; var radius = 200 + m_map.Random.Next(0, 10); Lights.Add( new Light( new Vector2(firePosition.X, firePosition.Y - FireCamp.Box.Y / 4), radius, new Color4ub(255, 255, 255, 255), new Color4ub(0, 0, 0, 255)) ); } var segments = Walls.SelectMany(x => x.Walls).ToList(); Parallel.ForEach(segments, segment => { foreach (var light in Lights) { light.Cone.Add(segment.P1, segment.P2); } //m_wallRenderer.AddSegment(segment); }); foreach (var light in Lights) { var points = light.Cone.GetPath(); foreach (var point in points) { m_lightRenderer.AddVertex(point.Point, point.Color); } } }