Spawn a whole bunch of ships
This commit is contained in:
Binary file not shown.
@@ -49,7 +49,7 @@ namespace EvilSatellites
|
||||
public void Update(List<IGameObject> objects)
|
||||
{
|
||||
if (objects.Count < 1) return;
|
||||
float minDistance = 1000;
|
||||
float minDistance = 50000000;
|
||||
Target = null;
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
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*20; 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,15 +23,18 @@ namespace EvilSatellites.Screens
|
||||
private float Theta = 0;
|
||||
private Player _player;
|
||||
private Radar ObjectRadar;
|
||||
private SatelliteSpawner Spawner;
|
||||
public void Activate()
|
||||
{
|
||||
State = ScreenState.Active;
|
||||
Player player = new Player(this);
|
||||
Objects.Add(player);
|
||||
_player = player;
|
||||
Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000));
|
||||
Objects.Add(prop);
|
||||
// Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000));
|
||||
// Objects.Add(prop);
|
||||
ObjectRadar = new Radar(_player, this);
|
||||
Spawner = new SatelliteSpawner(this);
|
||||
Spawner.Spawn();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +86,7 @@ namespace EvilSatellites.Screens
|
||||
private void UpdateRadar()
|
||||
{
|
||||
var candidates = objtree.Find(_player.Position, new Vector3(1000, 1000, 1000));
|
||||
ObjectRadar.Update(candidates);
|
||||
ObjectRadar.Update(Objects);
|
||||
}
|
||||
|
||||
public void HandleInput(GameTime gameTime, KeyboardState inputs)
|
||||
@@ -176,6 +179,11 @@ namespace EvilSatellites.Screens
|
||||
Tolk.Output("Satellites");
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.IsJustPressed(Keys.O))
|
||||
{
|
||||
DavyKager.Tolk.Output(Objects.Count.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckCollisions()
|
||||
|
||||
Reference in New Issue
Block a user