diff options
| author | Ben Beltran <ben@nsovocal.com> | 2013-11-22 06:53:08 -0600 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2013-11-22 06:53:08 -0600 |
| commit | 097781e6ad3f7bb1c13c16ff7b6bb7219764fb29 (patch) | |
| tree | 3ff629e90f2814d886ae2bbe484f64da824dbdf2 /Super Polarity/BasicGenerator.cs | |
| parent | 74c155708d85abfc2cf227c08de4f27003015b3f (diff) | |
Stuffffffff
Diffstat (limited to 'Super Polarity/BasicGenerator.cs')
| -rw-r--r-- | Super Polarity/BasicGenerator.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Super Polarity/BasicGenerator.cs b/Super Polarity/BasicGenerator.cs new file mode 100644 index 0000000..7cc4544 --- /dev/null +++ b/Super Polarity/BasicGenerator.cs @@ -0,0 +1,71 @@ +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; + } + + public void Update(GameTime gameTime) + { + 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) + { + ActorFactory.CreateShip(polarity, Position); + } + + if (ShipType == Ships.Scout) + { + ActorFactory.CreateScout(polarity, Position); + } + + if (ShipType == Ships.Battlecruiser) + { + ActorFactory.CreateCruiser(polarity, Position); + } + + } + } +} |