void CreatePath() { Vector2 vec; for (int i = 0; i < 22; i++) { vec = new Vector2(20, 30 * i); path.AddPoint(vec); vecArr[i] = vec; } vec = new Vector2(100, 30 * 20); path.AddPoint(vec); vecArr[22] = vec; }
public Level(GraphicsDevice graphics) { path = new SimplePath(graphics); path.Clean(); path.AddPoint(new Vector2(225, -64)); path.AddPoint(new Vector2(190, 535)); path.AddPoint(new Vector2(240, 700)); path.AddPoint(new Vector2(350, 760)); path.AddPoint(new Vector2(555, 745)); path.AddPoint(new Vector2(635, 645)); path.AddPoint(new Vector2(620, 470)); path.AddPoint(new Vector2(605, 290)); path.AddPoint(new Vector2(655, 200)); path.AddPoint(new Vector2(780, 155)); path.AddPoint(new Vector2(935, 195)); path.AddPoint(new Vector2(990, 345)); path.AddPoint(new Vector2(960, 984)); creepManager = new CreepManager(ref path); towerManager = new TowerManager(ref creepManager, graphics); }
public void Spline() //Borde kunna göras på ett snyggare sett.. mycket kod upprepas men det funkar! { while (roadRectList.Any()) { foreach (Rectangle roadRect in roadRectList) { if (roadRect.Contains(new Vector2(activeSplineX, activeSplineY + 50)) && !movingUp) { movingDown = true; movingRight = false; movingLeft = false; activeSplineY += 50; path.AddPoint(new Vector2(activeSplineX, activeSplineY)); roadRectList.Remove(roadRect); break; } else { movingDown = false; } if (roadRect.Contains(new Vector2(activeSplineX + 50, activeSplineY)) && !movingLeft) { movingRight = true; movingUp = false; movingDown = false; activeSplineX += 50; path.AddPoint(new Vector2(activeSplineX, activeSplineY)); roadRectList.Remove(roadRect); break; } else { movingLeft = false; } if (roadRect.Contains(new Vector2(activeSplineX, activeSplineY - 50)) && !movingDown) { movingUp = true; movingLeft = false; movingRight = false; activeSplineY -= 50; path.AddPoint(new Vector2(activeSplineX, activeSplineY)); roadRectList.Remove(roadRect); break; } else { movingDown = false; } if (roadRect.Contains(new Vector2(activeSplineX - 50, activeSplineY)) && !movingRight) { movingLeft = true; movingUp = false; movingDown = false; activeSplineX -= 50; path.AddPoint(new Vector2(activeSplineX, activeSplineY)); roadRectList.Remove(roadRect); break; } else { movingRight = false; } } } }
private void Create_level() { //Creates lists enemies = new List<Enemy>(); menu_towers = new List<Tower>(); interactive_towers = new List<Tower>(); //Sets int and float values enemy_amount = 0; tower_placed_amount = 0; enemy_interval = 100; //Creates instances menu_tower1 = new Tower(sheet_tex, new Vector2(1080, 50), new Rectangle(0, 0, 45, 70)); menu_tower2 = new Tower(sheet_tex, new Vector2(1123, 50), new Rectangle(45, 0, 45, 70)); menu_tower3 = new Tower(sheet_tex, new Vector2(1167, 50), new Rectangle(90, 0, 45, 70)); path = new SimplePath(graphics); layer = new RenderTarget2D(graphics, 1220, 720); menu_towers.Add(menu_tower1); menu_towers.Add(menu_tower2); menu_towers.Add(menu_tower3); //Creates steamreader sr = new StreamReader("Level1.txt"); path.Clean(); //Reads and creates spline points from text file while (!sr.EndOfStream) { string s = sr.ReadLine(); int x = int.Parse(s.Split(',')[0]); int y = int.Parse(s.Split(',')[1]); path.AddPoint(new Vector2(x, y)); } Draw_rendertarget(); }