using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using EvilSatellites.Objects; using EvilSatellites.Screens; namespace EvilSatellites { public class SatelliteSpawner { public GameScreen Screen; private Random rnd = new Random(); private int Level; public SatelliteSpawner(GameScreen screen) { Screen = screen; Level = 1; } public void Spawn() { for (var i = 0; i < Level*2; i++) { var player = Screen.Objects.Where((x) => x.Type == ObjectType.Player).FirstOrDefault(); var x = player.Position.X-250f + (float)rnd.NextDouble() * 500; var y = player.Position.Y - 250f + (float)rnd.NextDouble() * 500; var z = player.Position.Z - 250f + (float)rnd.NextDouble() * 500; // DavyKager.Tolk.Speak("Spawning sat at " + x.ToString() + ", " + y.ToString() + ", " + z.ToString()); var sat = new Satellite(Screen, new Vector3(x, y, z)); Screen.AddObject(sat); } } public void Update() { var sats = Screen.Objects.Where((x) => x.Type == ObjectType.Satellite).ToList(); if (sats.Count < 1) { Level++; Spawn(); } } } }