]> git.r.bdr.sh - rbdr/super-polarity/blame_incremental - SuperPolarity/BasicGenerator.cs
Moves some files around!
[rbdr/super-polarity] / SuperPolarity / BasicGenerator.cs
... / ...
CommitLineData
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Microsoft.Xna.Framework;
6
7namespace SuperPolarity
8{
9 class BasicGenerator
10 {
11 public enum Ships : byte { Ship, Scout, Battlecruiser };
12
13 protected Ships ShipType;
14 protected SuperPolarity Game;
15 protected int ScoreThreshold;
16 protected int Rate;
17 protected int CurrentTime;
18 protected Random Randomizer;
19 protected Vector2 Position;
20
21 public void Initialize(SuperPolarity game, Vector2 position, Ships shipType, int rate, int scoreThreshold)
22 {
23 Game = game;
24 ShipType = shipType;
25 ScoreThreshold = scoreThreshold;
26 Rate = rate;
27 Randomizer = new Random();
28 Position = position;
29 CurrentTime = rate;
30 }
31
32 public void Update(GameTime gameTime)
33 {
34 if (ActorManager.CountBaddies() > 50)
35 {
36 return;
37 }
38
39 if (Game.Player.Score >= ScoreThreshold)
40 {
41 CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
42
43 if (CurrentTime >= Rate)
44 {
45 CurrentTime = 0;
46 Spawn();
47 }
48 }
49 }
50
51 protected void Spawn()
52 {
53 var polarity = Ship.Polarity.Positive;
54
55 if (Randomizer.Next(2) == 1)
56 {
57 polarity = Ship.Polarity.Negative;
58 }
59
60 if (ShipType == Ships.Ship)
61 {
62 Renderer.CheckIn(ActorFactory.CreateShip(polarity, Position));
63 }
64
65 if (ShipType == Ships.Scout)
66 {
67 Renderer.CheckIn(ActorFactory.CreateScout(polarity, Position));
68 }
69
70 if (ShipType == Ships.Battlecruiser)
71 {
72 Renderer.CheckIn(ActorFactory.CreateCruiser(polarity, Position));
73 }
74
75 }
76 }
77}