2021-04-19 19:49:13 +02:00
|
|
|
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()
|
|
|
|
|
{
|
2021-04-19 21:33:56 +02:00
|
|
|
for (var i = 0; i < Level*2; i++)
|
2021-04-19 19:49:13 +02:00
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
2021-04-20 16:45:20 +02:00
|
|
|
var sats = Screen.Objects.Where((x) => x.Type == ObjectType.Satellite).ToList();
|
|
|
|
|
if (sats.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
Level++;
|
|
|
|
|
Spawn();
|
|
|
|
|
}
|
2021-04-19 19:49:13 +02:00
|
|
|
}
|
2021-04-23 20:28:06 +02:00
|
|
|
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-19 19:49:13 +02:00
|
|
|
}
|
|
|
|
|
}
|