diff options
| author | Ben Beltran <ben@nsovocal.com> | 2014-02-03 10:06:44 -0600 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2014-02-03 10:06:44 -0600 |
| commit | 4fc09567c557a1110180940cca40fd7144921026 (patch) | |
| tree | 5fb7b0b787b739a3f4a2785651c69219a8318ab0 /SuperPolarity/BasicGenerator.cs | |
| parent | 0cafec445af0a97d96feb1a1daefa1486142c73f (diff) | |
Removes spaces.
Diffstat (limited to 'SuperPolarity/BasicGenerator.cs')
| -rw-r--r-- | SuperPolarity/BasicGenerator.cs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/SuperPolarity/BasicGenerator.cs b/SuperPolarity/BasicGenerator.cs new file mode 100644 index 0000000..ba51742 --- /dev/null +++ b/SuperPolarity/BasicGenerator.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; + +namespace SuperPolarity +{ + class BasicGenerator + { + public enum Ships : byte { Ship, Scout, Battlecruiser }; + + protected Ships ShipType; + protected SuperPolarity Game; + protected int ScoreThreshold; + protected int Rate; + protected int CurrentTime; + protected Random Randomizer; + protected Vector2 Position; + + public void Initialize(SuperPolarity game, Vector2 position, Ships shipType, int rate, int scoreThreshold) + { + Game = game; + ShipType = shipType; + ScoreThreshold = scoreThreshold; + Rate = rate; + Randomizer = new Random(); + Position = position; + CurrentTime = rate; + } + + public void Update(GameTime gameTime) + { + if (ActorManager.CountBaddies() > 50) + { + return; + } + + if (Game.Player.Score >= ScoreThreshold) + { + CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds; + + if (CurrentTime >= Rate) + { + CurrentTime = 0; + Spawn(); + } + } + } + + protected void Spawn() + { + var polarity = Ship.Polarity.Positive; + + if (Randomizer.Next(2) == 1) + { + polarity = Ship.Polarity.Negative; + } + + if (ShipType == Ships.Ship) + { + Renderer.CheckIn(ActorFactory.CreateShip(polarity, Position)); + } + + if (ShipType == Ships.Scout) + { + Renderer.CheckIn(ActorFactory.CreateScout(polarity, Position)); + } + + if (ShipType == Ships.Battlecruiser) + { + Renderer.CheckIn(ActorFactory.CreateCruiser(polarity, Position)); + } + + } + } +} |