aboutsummaryrefslogtreecommitdiff
path: root/SuperPolarityMac
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2014-02-11 01:15:19 -0600
committerBen Beltran <ben@nsovocal.com>2014-02-11 01:15:19 -0600
commitd7a43ae2d3d4702bd199fa5d8ca84c7c6e78ed36 (patch)
tree28be1c08e360ad3122042243a326f1352797d802 /SuperPolarityMac
parent6fceaa7b34f4d6efc497cda51679b37e530a61aa (diff)
Consolidate with mac project.
Diffstat (limited to 'SuperPolarityMac')
-rw-r--r--SuperPolarityMac/ActorFactory.cs144
-rw-r--r--SuperPolarityMac/ActorManager.cs160
-rw-r--r--SuperPolarityMac/BasicGenerator.cs77
-rw-r--r--SuperPolarityMac/GameScreen.cs209
-rw-r--r--SuperPolarityMac/Icon.icobin32038 -> 0 bytes
-rw-r--r--SuperPolarityMac/InputController.cs248
-rw-r--r--SuperPolarityMac/LetterChooseWidget.cs84
-rw-r--r--SuperPolarityMac/MenuItem.cs11
-rw-r--r--SuperPolarityMac/MenuWidget.cs11
-rw-r--r--SuperPolarityMac/NameChooserWidget.cs99
-rw-r--r--SuperPolarityMac/Particle.cs51
-rw-r--r--SuperPolarityMac/ParticleEffectFactory.cs66
-rw-r--r--SuperPolarityMac/ParticleEngine.cs86
-rw-r--r--SuperPolarityMac/Player.cs81
-rw-r--r--SuperPolarityMac/Renderer.cs42
-rw-r--r--SuperPolarityMac/ScoreScreen.cs108
-rw-r--r--SuperPolarityMac/Screen.cs40
-rw-r--r--SuperPolarityMac/ScreenManager.cs55
-rw-r--r--SuperPolarityMac/SuperPolarity.cs161
-rw-r--r--SuperPolarityMac/SuperPolarityMac.csproj44
-rw-r--r--SuperPolarityMac/SuperPolarityMac.userprefs4
-rw-r--r--SuperPolarityMac/TitleScreen.cs50
-rw-r--r--SuperPolarityMac/Widget.cs92
-rw-r--r--SuperPolarityMac/neutral-supercruiser.xnbbin72187 -> 0 bytes
24 files changed, 32 insertions, 1891 deletions
diff --git a/SuperPolarityMac/ActorFactory.cs b/SuperPolarityMac/ActorFactory.cs
deleted file mode 100644
index f9c7697..0000000
--- a/SuperPolarityMac/ActorFactory.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Content;
-
-namespace SuperPolarity
-{
- static class ActorFactory
- {
- static internal SuperPolarity Game;
-
- static public MainShip CreateMainShip(Vector2 position)
- {
- MainShip mainShip = new MainShip(Game);
- mainShip.Initialize(Game.Content.Load<Texture2D>("Graphics\\main-ship"), position);
-
- ActorManager.CheckIn(mainShip);
-
- return mainShip;
- }
-
- static public StandardShip CreateShip(Ship.Polarity polarity, Vector2 position)
- {
- StandardShip ship = new StandardShip(Game);
- Texture2D texture;
-
- if (polarity == Ship.Polarity.Positive)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\positive-ship");
- }
- else if (polarity == Ship.Polarity.Negative)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\negative-ship");
- }
- else
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
- }
-
- ship.Initialize(texture, position);
- ship.SetPolarity(polarity);
-
- ActorManager.CheckIn(ship);
-
- return ship;
- }
-
- internal static void SetGame(SuperPolarity game)
- {
- ActorFactory.Game = game;
- }
-
- internal static Bullet CreateBullet(Vector2 position, float angle)
- {
- Bullet bullet = new Bullet(Game);
-
- bullet.Initialize(Game.Content.Load<Texture2D>("Graphics\\square"), position);
-
- bullet.Angle = angle;
-
- ActorManager.CheckIn(bullet);
-
- return bullet;
- }
-
- static public StandardShip CreateScout(Ship.Polarity polarity, Vector2 position)
- {
- StandardShip ship = new StandardShip(Game);
- Texture2D texture;
-
- if (polarity == Ship.Polarity.Positive)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\positive-scout");
- }
- else if (polarity == Ship.Polarity.Negative)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\negative-scout");
- }
- else
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\neutral-scout");
- }
-
- ship.BoxDimensions.X = 10;
- ship.BoxDimensions.Y = 10;
- ship.BoxDimensions.W = 10;
- ship.BoxDimensions.Z = 10;
-
- ship.Initialize(texture, position);
- ship.MaxVelocity = 5.2f;
- ship.FleeVelocity = 6.5f;
- ship.ChargeVelocity = 5.5f;
- ship.Value = 3;
- ship.HP = 0;
- ship.AngleChangeProbability = 20;
- ship.SetPolarity(polarity);
-
- ActorManager.CheckIn(ship);
-
- return ship;
- }
-
- static public StandardShip CreateCruiser(Ship.Polarity polarity, Vector2 position)
- {
- StandardShip ship = new StandardShip(Game);
- Texture2D texture;
-
- if (polarity == Ship.Polarity.Positive)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\positive-cruiser");
- }
- else if (polarity == Ship.Polarity.Negative)
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\negative-cruiser");
- }
- else
- {
- texture = Game.Content.Load<Texture2D>("Graphics\\neutral-cruiser");
- }
-
- ship.BoxDimensions.X = 40;
- ship.BoxDimensions.Y = 40;
- ship.BoxDimensions.W = 40;
- ship.BoxDimensions.Z = 40;
-
- ship.Initialize(texture, position);
- ship.MagneticRadius = 1000;
- ship.RepelRadius = 200;
- ship.MaxVelocity = 0.5f;
- ship.FleeVelocity = 5;
- ship.ChargeVelocity = 1;
- ship.Value = 10;
- ship.HP = 29;
- ship.SetPolarity(polarity);
-
- ActorManager.CheckIn(ship);
-
- return ship;
- }
- }
-}
diff --git a/SuperPolarityMac/ActorManager.cs b/SuperPolarityMac/ActorManager.cs
deleted file mode 100644
index f5587b9..0000000
--- a/SuperPolarityMac/ActorManager.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- static class ActorManager
- {
-
- static SuperPolarity Game;
- static int OutlierBounds;
- static IList<Actor> Actors;
-
- static ActorManager()
- {
- OutlierBounds = 100;
- Actors = new List<Actor>();
- }
-
- static public void CheckIn(Actor actor)
- {
- Actors.Add(actor);
- }
-
- static public void CheckOut(Actor actor)
- {
- actor.CleanUp();
- Actors.Remove(actor);
- actor = null;
- }
-
- static public void Update(GameTime gameTime)
- {
- CheckActors();
- CheckOutliers();
- foreach (Actor actor in Actors)
- {
- actor.Update(gameTime);
- }
- }
-
- static public void Draw(SpriteBatch spriteBatch)
- {
- foreach (Actor actor in Actors)
- {
- actor.Draw(spriteBatch);
- }
- }
-
- static void CheckActors()
- {
- for (var i = Actors.Count - 1; i >= 0; i--)
- {
- if (i >= Actors.Count) {
- i = Actors.Count - 1;
- }
-
- if (Actors.Count == 0)
- {
- return;
- }
-
- Actor actor = Actors[i];
- for (var j = i - 1; j >= 0; j--)
- {
- Actor other = Actors[j];
-
- CheckCollision(actor, other);
-
- if (actor.GetType().IsSubclassOf(typeof(Ship)) && other.GetType().IsSubclassOf(typeof(Ship)))
- {
- CheckMagnetism((Ship)actor, (Ship)other);
- }
- }
- }
- }
-
- static void CheckCollision(Actor actor, Actor other)
- {
- var collision = Rectangle.Intersect(actor.Box, other.Box);
- var inverseCollision = Rectangle.Intersect(other.Box, actor.Box);
- if (!collision.IsEmpty && !actor.Dying && !other.Dying)
- {
- actor.Collide(other, collision);
- other.Collide(actor, inverseCollision);
- }
-
- }
-
- static void CheckMagnetism(Ship actor, Ship other)
- {
- if (actor.CurrentPolarity != Ship.Polarity.Neutral && other.CurrentPolarity != Ship.Polarity.Neutral)
- {
- var dy = other.Position.Y - actor.Position.Y;
- var dx = other.Position.X - actor.Position.X;
- var linearDistance = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));
- var angle = (float) Math.Atan2(dy, dx);
- var otherAngle = (float)Math.Atan2(-dy, -dx);
-
- if (linearDistance < actor.MagneticRadius || linearDistance < other.MagneticRadius)
- {
- actor.Magnetize(other, (float)linearDistance, angle);
- other.Magnetize(actor, (float)linearDistance, otherAngle);
- }
- }
- }
-
- static void CheckOutliers()
- {
- for (var i = Actors.Count; i > 0; i--)
- {
- var actor = Actors[i-1];
- if (actor.Position.X < -OutlierBounds || actor.Position.Y < -OutlierBounds ||
- actor.Position.X > Game.GraphicsDevice.Viewport.Width + OutlierBounds ||
- actor.Position.Y > Game.GraphicsDevice.Viewport.Height + OutlierBounds)
- {
- CheckOut(actor);
- if (actor.Parent != null)
- {
- actor.Parent.Children.Remove(actor);
- }
- }
- }
- }
-
- static public void Empty()
- {
- foreach (Actor actor in Actors) {
- actor.CleanUp();
- }
- Actors.Clear();
- }
-
- internal static void SetGame(SuperPolarity game)
- {
- Game = game;
- }
-
- public static void Bomb()
- {
- for (var i = Actors.Count - 1; i >= 0; i--)
- {
- var actor = Actors[i];
- if (actor.GetType() == typeof(StandardShip))
- {
- CheckOut(actor);
- Renderer.CheckOut(actor);
- }
- }
- }
-
- public static int CountBaddies()
- {
- return Actors.Where(a => a.GetType() == typeof(StandardShip)).Count();
- }
- }
-}
diff --git a/SuperPolarityMac/BasicGenerator.cs b/SuperPolarityMac/BasicGenerator.cs
deleted file mode 100644
index ba51742..0000000
--- a/SuperPolarityMac/BasicGenerator.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-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));
- }
-
- }
- }
-}
diff --git a/SuperPolarityMac/GameScreen.cs b/SuperPolarityMac/GameScreen.cs
deleted file mode 100644
index 783e3c1..0000000
--- a/SuperPolarityMac/GameScreen.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Audio;
-using Microsoft.Xna.Framework.Media;
-using Microsoft.Xna.Framework.Input;
-
-namespace SuperPolarity
-{
- class GameScreen : Screen
- {
- public GameScreen(SuperPolarity newGame) : base(newGame) {}
-
- protected List<BasicGenerator> Generators;
-
- protected int LivesRate;
- protected int CurrentLivesRate;
- protected int BombRate;
- protected int CurrentBombRate;
- protected SoundEffect BombSound;
- protected SoundEffect LifeSound;
-
- protected bool Flashing;
-
- protected bool IsPaused;
- protected Texture2D PauseScreen;
-
- public override void Initialize()
- {
- Generators = new List<BasicGenerator>();
-
- CurrentBombRate = 1;
- BombRate = 6000;
-
- LivesRate = 10000;
- CurrentLivesRate = 1;
-
- InputController.RegisterEventForButton("changePolarity", Buttons.A);
- InputController.RegisterEventForKey("changePolarity", Keys.Z);
-
- InputController.RegisterEventForButton("shoot", Buttons.X);
- InputController.RegisterEventForKey("shoot", Keys.X);
-
- InputController.Bind("pause", HandlePause);
-
- PauseScreen = Game.Content.Load<Texture2D>("Graphics\\pause-screen");
- }
-
- protected void HandlePause(float value)
- {
- Console.WriteLine("Paused");
- IsPaused = !IsPaused;
-
- if (IsPaused)
- {
- MediaPlayer.Volume = 0.05f;
- }
- else
- {
- MediaPlayer.Volume = 1;
- }
- }
-
- public override void LoadContent()
- {
- CreateGenerators();
-
- Vector2 playerPosition = new Vector2(Game.GraphicsDevice.Viewport.TitleSafeArea.X + Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.TitleSafeArea.Y + Game.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
-
- BombSound = Game.Content.Load<SoundEffect>("Sound\\bomb");
- LifeSound = Game.Content.Load<SoundEffect>("Sound\\life");
-
- Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
-
- Game.PlaySong("game");
- }
-
- protected void CalculateBomb()
- {
- if (Game.Player.Score >= BombRate * CurrentBombRate)
- {
- ActorManager.Bomb();
- Flashing = true;
- BombSound.Play();
- CurrentBombRate = CurrentBombRate + 1;
- }
- }
-
- protected void CalculateLife()
- {
- if (Game.Player.Score >= LivesRate * CurrentLivesRate)
- {
- Game.Player.Lives = Game.Player.Lives + 1;
- LifeSound.Play();
- CurrentLivesRate = CurrentLivesRate + 1;
- }
- }
-
- public override void Update(GameTime gameTime)
- {
- CalculateBomb();
- CalculateLife();
- InputController.UpdateInput(IsPaused);
- if (IsPaused)
- {
- return;
- }
- ActorManager.Update(gameTime);
-
- foreach (BasicGenerator generator in Generators)
- {
- generator.Update(gameTime);
- }
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- Renderer.Draw(spriteBatch);
- Game.Player.Draw(spriteBatch);
-
- if (IsPaused)
- {
- spriteBatch.Draw(PauseScreen, new Vector2(0, 0), Color.White);
- }
-
- if (Flashing)
- {
- Game.GraphicsDevice.Clear(Color.Black);
- Flashing = false;
- }
- }
-
- protected void CreateGenerators()
- {
- // The basic ship generators.
- var gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(-50, -50), BasicGenerator.Ships.Ship, 3000, 0);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 0);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, -50), BasicGenerator.Ships.Ship, 3000, 0);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 0);
- Generators.Add(gen);
-
- // After 1.5k liberate some sporadic Scouts, and add two more ship generators.
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Ship, 3000, 1500);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 1500);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Scout, 6000, 1500);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Scout, 6000, 1500);
- Generators.Add(gen);
-
-
- // After 3k add more scouts.
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Scout, 3000, 3000);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Scout, 3000, 5000);
- Generators.Add(gen);
-
- // After 5k release more ships and a cruiser.
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Ship, 1500, 5000);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 1500, 5000);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Battlecruiser, 10000, 5000);
- Generators.Add(gen);
-
- gen = new BasicGenerator();
- gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Battlecruiser, 10000, 5000);
- Generators.Add(gen);
- }
-
- public override void CleanUp()
- {
- base.CleanUp();
- Generators.Clear();
- InputController.Unbind("pause", HandlePause);
- Renderer.Empty();
- ActorManager.Empty();
- }
- }
-}
diff --git a/SuperPolarityMac/Icon.ico b/SuperPolarityMac/Icon.ico
deleted file mode 100644
index 13be62a..0000000
--- a/SuperPolarityMac/Icon.ico
+++ /dev/null
Binary files differ
diff --git a/SuperPolarityMac/InputController.cs b/SuperPolarityMac/InputController.cs
deleted file mode 100644
index c92bb9c..0000000
--- a/SuperPolarityMac/InputController.cs
+++ /dev/null
@@ -1,248 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework.Input;
-
-namespace SuperPolarity
-{
- static class InputController
- {
- static Dictionary<string, List<Action<float>>> Listeners;
- static Dictionary<string, List<Keys>> RegisteredKeys;
- static Dictionary<string, List<Buttons>> RegisteredButtons;
- static List<string> BlockedKeys;
- static List<string> BlockedButtons;
-
- static GamePadState InputGamePadState;
- static KeyboardState InputKeyboardState;
-
- /*
- * Registered Events.
- *
- * You register: name of the event (ie. attack) and a key associated with it.
- * or button... Left Stick /always/ dispatches move event.
- */
-
- static InputController()
- {
- Listeners = new Dictionary<string,List<Action<float>>>();
- RegisteredButtons = new Dictionary<string, List<Buttons>>();
- RegisteredKeys = new Dictionary<string, List<Keys>>();
- BlockedKeys = new List<string>();
- BlockedButtons = new List<string>();
- InputKeyboardState = new KeyboardState();
- InputGamePadState = new GamePadState();
- }
-
- public static void UpdateInput()
- {
- DispatchMoveEvents();
- DispatchRegisteredEvents();
- }
-
- public static void UpdateInput(bool highPriorityOnly)
- {
- Poll();
- DispatchPauseEvent();
- if (!highPriorityOnly)
- {
- UpdateInput();
- }
- }
-
- public static void DispatchPauseEvent()
- {
- // OK THIS IS ALL KINDS OF WRONG. THIS IS A PLACEHOLDER BECAUSE DEMO!
- var keyPressed = false;
- if ((InputKeyboardState.IsKeyDown(Keys.Enter) || InputGamePadState.IsButtonDown(Buttons.Start))) {
- keyPressed = true;
- if(!BlockedButtons.Contains("pause") && !BlockedKeys.Contains("pause"))
- {
- BlockedButtons.Add("pause");
- BlockedKeys.Add("pause");
- Console.WriteLine("Dispatch");
- Dispatch("pause", 0);
- }
- }
-
- if (!keyPressed)
- {
- BlockedButtons.Remove("pause");
- BlockedKeys.Remove("pause");
- }
- }
-
- private static void Poll()
- {
- InputGamePadState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
- InputKeyboardState = Keyboard.GetState();
- }
-
- public static void RegisterEventForKey(string eventName, Keys key)
- {
- List<Keys> newKeyList;
- if (!RegisteredKeys.ContainsKey(eventName))
- {
- newKeyList = new List<Keys>();
- RegisteredKeys.Add(eventName, newKeyList);
- }
-
- RegisteredKeys.TryGetValue(eventName, out newKeyList);
-
- newKeyList.Add(key);
- }
-
- public static void RegisterEventForButton(string eventName, Buttons button)
- {
- List<Buttons> newButtonList;
- if (!RegisteredButtons.ContainsKey(eventName))
- {
- newButtonList = new List<Buttons>();
- RegisteredButtons.Add(eventName, newButtonList);
- }
-
- RegisteredButtons.TryGetValue(eventName, out newButtonList);
-
- newButtonList.Add(button);
- }
-
- private static void DispatchRegisteredEvents()
- {
- var keyFired = false;
-
- foreach (KeyValuePair<string,List<Keys>> entry in RegisteredKeys) {
- keyFired = false;
- foreach (Keys key in entry.Value)
- {
- if (InputKeyboardState.IsKeyDown(key))
- {
- if (!BlockedKeys.Contains(entry.Key))
- {
- BlockedKeys.Add(entry.Key);
- Dispatch(entry.Key, 1);
- }
- keyFired = true;
- break;
- }
- }
-
- if (!keyFired)
- {
- BlockedKeys.Remove(entry.Key);
- }
- }
-
- foreach (KeyValuePair<string, List<Buttons>> entry in RegisteredButtons)
- {
- keyFired = false;
- foreach (Buttons button in entry.Value)
- {
- if (InputGamePadState.IsButtonDown(button))
- {
- if (!BlockedButtons.Contains(entry.Key))
- {
- BlockedButtons.Add(entry.Key);
- Dispatch(entry.Key, 1);
- }
- keyFired = true;
- break;
- };
- }
-
- if (!keyFired)
- {
- BlockedButtons.Remove(entry.Key);
- }
- }
- }
-
- private static void DispatchMoveEvents()
- {
- float xMovement = 0.0f;
- float yMovement = 0.0f;
- // Dispatch the moveX / MoveY events every frame.
-
- xMovement = InputGamePadState.ThumbSticks.Left.X;
- yMovement = -InputGamePadState.ThumbSticks.Left.Y;
-
- if (InputKeyboardState.IsKeyDown(Keys.Left))
- {
- xMovement = -1.0f;
- }
-
- if (InputKeyboardState.IsKeyDown(Keys.Right))
- {
- xMovement = 1.0f;
- }
-
- if (InputKeyboardState.IsKeyDown(Keys.Up))
- {
- yMovement = -1.0f;
- }
-
- if (InputKeyboardState.IsKeyDown(Keys.Down))
- {
- yMovement = 1.0f;
- }
-
- Dispatch("moveX", xMovement);
- Dispatch("moveY", yMovement);
- }
-
- public static void Bind(string eventName, Action<float> listener)
- {
- List<Action<float>> newListenerList;
- List<Action<float>> listenerList;
- bool foundListeners;
-
- if (!Listeners.ContainsKey(eventName)) {
- newListenerList = new List<Action<float>>();
- Listeners.Add(eventName, newListenerList);
- }
-
- foundListeners = Listeners.TryGetValue(eventName, out listenerList);
-
- listenerList.Add(listener);
- }
-
- public static void Unbind(string eventName, Action<float> listener)
- {
- List<Action<float>> listenerList;
- bool foundListeners;
-
- if (!Listeners.ContainsKey(eventName))
- {
- return;
- }
-
- foundListeners = Listeners.TryGetValue(eventName, out listenerList);
-
- listenerList.Remove(listener);
- }
-
- public static void Dispatch(string eventName, float value)
- {
- List<Action<float>> listenerList;
- bool foundListeners;
-
- foundListeners = Listeners.TryGetValue(eventName, out listenerList);
-
- if (!foundListeners)
- {
- return;
- }
-
- for (var i = listenerList.Count - 1; i >= 0; i--)
- {
- listenerList[i](value);
- }
- }
-
- public static void Unlock(string eventName)
- {
- BlockedButtons.Remove(eventName);
- BlockedKeys.Remove(eventName);
- }
- }
-}
diff --git a/SuperPolarityMac/LetterChooseWidget.cs b/SuperPolarityMac/LetterChooseWidget.cs
deleted file mode 100644
index e52733f..0000000
--- a/SuperPolarityMac/LetterChooseWidget.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class LetterChooseWidget : Widget
- {
- int CurrentChar;
- bool Locked;
- int LockRate;
- int CurrentTime;
-
- SpriteFont Font;
-
- public LetterChooseWidget(SuperPolarity game, Vector2 position) : base(game, position)
- {
- Active = false;
- CurrentChar = 65;
- Font = game.Content.Load<SpriteFont>("Fonts\\bigfont");
- LockRate = 300;
- CurrentTime = 0;
-
- InputController.Bind("moveY", HandleMovement);
- }
-
- public void HandleMovement(float value)
- {
- if (!Active) { return; }
-
- if (value > 0.8 && !Locked) {
- CurrentChar = CurrentChar + 1;
-
- if (CurrentChar > 90)
- {
- CurrentChar = 32;
- }
-
- Locked = true;
- }
-
- if (value < -0.8 && !Locked) {
- CurrentChar = CurrentChar - 1;
-
- if (CurrentChar < 32)
- {
- CurrentChar = 90;
- }
-
- Locked = true;
- }
- }
-
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
-
- CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
- if (CurrentTime > LockRate)
- {
- CurrentTime = 0;
- Locked = false;
- }
- }
-
- public string Value()
- {
- return char.ConvertFromUtf32(CurrentChar);
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- var color = new Color(0, 0, 0, 128);
- if (Active)
- {
- color = new Color(201, 0, 68, 255);
- }
- spriteBatch.DrawString(Font, Value(), Position, color);
- }
- }
-}
diff --git a/SuperPolarityMac/MenuItem.cs b/SuperPolarityMac/MenuItem.cs
deleted file mode 100644
index 8e24c97..0000000
--- a/SuperPolarityMac/MenuItem.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace SuperPolarity
-{
- class MenuItem
- {
- }
-}
diff --git a/SuperPolarityMac/MenuWidget.cs b/SuperPolarityMac/MenuWidget.cs
deleted file mode 100644
index 992ef43..0000000
--- a/SuperPolarityMac/MenuWidget.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace SuperPolarity
-{
- class MenuWidget
- {
- }
-}
diff --git a/SuperPolarityMac/NameChooserWidget.cs b/SuperPolarityMac/NameChooserWidget.cs
deleted file mode 100644
index ce7c149..0000000
--- a/SuperPolarityMac/NameChooserWidget.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class NameChooserWidget : Widget
- {
- int CurrentIndex;
- bool Lock;
- int LockRate;
- int CurrentTime;
-
- public NameChooserWidget(SuperPolarity game, Vector2 position)
- : base(game, position)
- {
- AppendChild(new LetterChooseWidget(game, new Vector2(position.X, position.Y)));
- AppendChild(new LetterChooseWidget(game, new Vector2(position.X + 32, position.Y)));
- AppendChild(new LetterChooseWidget(game, new Vector2(position.X + 64, position.Y)));
- CurrentIndex = 0;
- Children[CurrentIndex].Activate();
- LockRate = 300;
- CurrentTime = 0;
-
- InputController.Bind("moveX", HandleMovement);
- }
-
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
-
- CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
- if (CurrentTime > LockRate)
- {
- CurrentTime = 0;
- Lock = false;
- }
-
- foreach (LetterChooseWidget widget in Children)
- {
- widget.Update(gameTime);
- }
- }
-
- public void HandleMovement(float value)
- {
- if (value > 0.8 && !Lock)
- {
- Children[CurrentIndex].Deactivate();
- CurrentIndex = CurrentIndex + 1;
-
- if (CurrentIndex > Children.Count - 1)
- {
- CurrentIndex = 0;
- }
-
- Lock = true;
- }
-
- if (value < -0.8 && !Lock)
- {
- Children[CurrentIndex].Deactivate();
- CurrentIndex = CurrentIndex - 1;
-
- if (CurrentIndex < 0)
- {
- CurrentIndex = Children.Count - 1;
- }
-
- Lock = true;
- }
-
- Children[CurrentIndex].Activate();
- }
-
- public string Value()
- {
- var name = "";
-
- foreach (LetterChooseWidget letter in Children)
- {
- name = name + letter.Value();
- }
-
- return name;
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- foreach (LetterChooseWidget widget in Children)
- {
- widget.Draw(spriteBatch);
- }
- }
- }
-}
diff --git a/SuperPolarityMac/Particle.cs b/SuperPolarityMac/Particle.cs
deleted file mode 100644
index d65bac6..0000000
--- a/SuperPolarityMac/Particle.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class Particle
- {
- public Texture2D Texture { get; set; }
- public Vector2 Position { get; set; }
- public Vector2 Velocity { get; set; }
- public float Angle { get; set; }
- public float AngularVelocity { get; set; }
- public Color Color { get; set; }
- public float Size { get; set; }
- public int TTL { get; set; }
-
- public Particle(Texture2D texture, Vector2 position, Vector2 velocity,
- float angle, float angularVelocity, Color color, float size, int ttl)
- {
- Texture = texture;
- Position = position;
- Velocity = velocity;
- Angle = angle;
- AngularVelocity = angularVelocity;
- Color = color;
- Size = size;
- TTL = ttl;
- }
-
- public void Update()
- {
- TTL--;
- Position += Velocity;
- Angle += AngularVelocity;
- }
-
- public void Draw(SpriteBatch spriteBatch)
- {
- Rectangle sourceRectangle = new Rectangle(0, 0, Texture.Width, Texture.Height);
- Vector2 origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
-
- spriteBatch.Draw(Texture, Position, sourceRectangle, Color,
- Angle, origin, Size, SpriteEffects.None, 0f);
- }
-
- }
-}
diff --git a/SuperPolarityMac/ParticleEffectFactory.cs b/SuperPolarityMac/ParticleEffectFactory.cs
deleted file mode 100644
index 0cd9ed3..0000000
--- a/SuperPolarityMac/ParticleEffectFactory.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- static class ParticleEffectFactory
- {
- static Game Game;
- static Random random;
-
- static ParticleEffectFactory()
- {
- random = new Random();
- }
-
- public static ParticleEngine CreatePolarCircle(Vector2 location)
- {
- List<Texture2D> texturesList = new List<Texture2D>();
-
- //texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\circle"));
- texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\diamond"));
- texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\square"));
-
- ParticleEngine particleEngine = new ParticleEngine(texturesList, location);
-
- particleEngine.Color = new Color(239, 203, 204);
- particleEngine.TTL = 10;
- particleEngine.TTLRandomFactor = 5;
- particleEngine.ScatterFactor = 40;
- particleEngine.ParticleCount = 50;
- particleEngine.StretchFactor = 2.8f;
-
-
- return particleEngine;
- }
-
- public static ParticleEngine CreateBullet(Vector2 location)
- {
- List<Texture2D> texturesList = new List<Texture2D>();
-
- texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\circle"));
- //texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\diamond"));
- texturesList.Add(Game.Content.Load<Texture2D>("Graphics\\square"));
-
- ParticleEngine particleEngine = new ParticleEngine(texturesList, location);
-
- particleEngine.Color = Color.Gray;
- particleEngine.TTL = 5;
- particleEngine.TTLRandomFactor = 5;
- particleEngine.ScatterFactor = 5;
- particleEngine.ParticleCount = 10;
- particleEngine.StretchFactor = 1;
-
- return particleEngine;
- }
-
- internal static void SetGame(Game game)
- {
- ParticleEffectFactory.Game = game;
- }
- }
-}
diff --git a/SuperPolarityMac/ParticleEngine.cs b/SuperPolarityMac/ParticleEngine.cs
deleted file mode 100644
index 51188ae..0000000
--- a/SuperPolarityMac/ParticleEngine.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class ParticleEngine
- {
- private Random random;
- public Vector2 EmitterLocation { get; set; }
- public Color Color; //TODO: Color list for random colors.
- public int TTL;
- public int TTLRandomFactor;
- public int ScatterFactor;
- public int ParticleCount;
- public float StretchFactor;
- private List<Particle> particles;
- private List<Texture2D> textures;
-
- public ParticleEngine(List<Texture2D> textures, Vector2 location)
- {
- EmitterLocation = location;
- this.textures = textures;
- this.particles = new List<Particle>();
- random = new Random();
- Color = Color.Red;
- TTL = 20;
- TTLRandomFactor = 40;
- StretchFactor = 1;
- }
-
- private Particle GenerateNewParticle()
- {
- Texture2D texture = textures[random.Next(textures.Count)];
- Vector2 position = EmitterLocation;
- Vector2 velocity = new Vector2(
- 1f * (float)(random.NextDouble() * 2 - 1),
- 1f * (float)(random.NextDouble() * 2 - 1));
-
- float angle = 0;
- float angularVelocity = 0.1f * (float)(random.NextDouble() * 2 - 1);
- Color color = Color;
- float size = (float)random.NextDouble() * StretchFactor;
-
- position.X += random.Next(-ScatterFactor, ScatterFactor);
- position.Y += random.Next(-ScatterFactor, ScatterFactor);
-
- int ttl = TTL + random.Next(TTLRandomFactor);
-
- return new Particle(texture, position, velocity, angle, angularVelocity, color, size, ttl);
- }
-
- public void Update()
- {
- int total = 10;
-
- for (int i = 0; i < total; i++)
- {
- particles.Add(GenerateNewParticle());
- }
-
- for (int particle = 0; particle < particles.Count; particle++)
- {
- particles[particle].Update();
- if (particles[particle].TTL <= 0)
- {
- particles.RemoveAt(particle);
- particle--;
- }
- }
- }
-
- public void Draw(SpriteBatch spriteBatch)
- {
- //spriteBatch.Begin();
- for (int index = 0; index < particles.Count; index++)
- {
- particles[index].Draw(spriteBatch);
- }
- //spriteBatch.End();
- }
- }
-}
diff --git a/SuperPolarityMac/Player.cs b/SuperPolarityMac/Player.cs
deleted file mode 100644
index 184abdd..0000000
--- a/SuperPolarityMac/Player.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- public class Player
- {
- public int Score;
- public int Multiplier;
- public int Lives;
-
-
- SpriteFont DebugFont;
- SuperPolarity Game;
-
- Texture2D LifeSprite;
-
- public Player(SuperPolarity game)
- {
- Score = 0;
- Multiplier = 1;
- Lives = 3;
- Game = game;
- DebugFont = Game.Content.Load<SpriteFont>("Fonts\\bigfont");
- LifeSprite = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
- }
-
- public void AddScore(int value)
- {
- Score = Score + (value * Multiplier);
- }
-
- public void AddMultiplier(int value)
- {
- Multiplier = Multiplier + 1;
- }
-
- public void ResetMultiplier()
- {
- Multiplier = 1;
- }
-
- public void Draw(SpriteBatch spriteBatch)
- {
- var UiColor = new Color(0, 0, 0, 200);
- var lightColor = new Color(0, 0, 0, 128);
- spriteBatch.DrawString(DebugFont, Score.ToString(), new Vector2(40, 30), UiColor);
- spriteBatch.DrawString(DebugFont, "x" + Multiplier.ToString(), new Vector2(40, 50), lightColor);
-
- var lifePosition = new Vector2(Game.GraphicsDevice.Viewport.Width - 140, 30);
- if (Lives > 4)
- {
- spriteBatch.Draw(LifeSprite, lifePosition, null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
- spriteBatch.DrawString(DebugFont, "x " + Lives.ToString(), new Vector2(lifePosition.X + 8, lifePosition.Y + 5), UiColor);
- }
- else
- {
- for (var i = 0; i < Lives; i++)
- {
- spriteBatch.Draw(LifeSprite, new Vector2(lifePosition.X + (i * 28), lifePosition.Y), null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
- }
- }
- }
-
- public void Update()
- {
-
- }
-
- public void Reset()
- {
- Score = 0;
- Multiplier = 1;
- Lives = 3;
- }
- }
-}
diff --git a/SuperPolarityMac/Renderer.cs b/SuperPolarityMac/Renderer.cs
deleted file mode 100644
index 7ca8158..0000000
--- a/SuperPolarityMac/Renderer.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class Renderer
- {
-
- static List<Actor> Actors;
-
- static Renderer()
- {
- Actors = new List<Actor>();
- }
-
- static public void CheckIn(Actor actor)
- {
- Actors.Add(actor);
- }
-
- static public void CheckOut(Actor actor)
- {
- Actors.Remove(actor);
- }
-
- static public void Draw(SpriteBatch spriteBatch)
- {
- foreach (Actor actor in Actors)
- {
- actor.Draw(spriteBatch);
- }
- }
-
- static public void Empty()
- {
- Actors.Clear();
- }
- }
-}
diff --git a/SuperPolarityMac/ScoreScreen.cs b/SuperPolarityMac/ScoreScreen.cs
deleted file mode 100644
index bf43275..0000000
--- a/SuperPolarityMac/ScoreScreen.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
-
-namespace SuperPolarity
-{
- class ScoreScreen : Screen
- {
- protected SpriteFont Font;
- protected NameChooserWidget nameChooser;
- protected Dictionary<string, int> Scores;
-
- public ScoreScreen(SuperPolarity newGame) : base(newGame) { }
-
- public override void Initialize()
- {
- base.Initialize();
- nameChooser = new NameChooserWidget(Game, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 4));
- InputController.RegisterEventForButton("OK", Buttons.A);
- InputController.RegisterEventForKey("OK", Keys.Z);
- Scores = new Dictionary<string, int>();
- ReadScore();
- }
-
- public override void LoadContent()
- {
- base.LoadContent();
- Font = Game.Content.Load<SpriteFont>("Fonts\\bigfont");
- InputController.Bind("OK", HandleNext);
- }
-
- public void HandleNext(float value)
- {
- if (!Active) { return; }
- WriteScore();
- ScreenManager.Pop();
- }
-
- public void WriteScore()
- {
- using (StreamWriter swriter = new StreamWriter("scores.txt", true))
- {
- swriter.WriteLine(nameChooser.Value() + "," + Game.Player.Score.ToString());
- }
- }
-
- public void ReadScore()
- {
- try
- {
- using (StreamReader sreader = new StreamReader("scores.txt"))
- {
- string line = null;
- while ((line = sreader.ReadLine()) != null)
- {
- string[] parts = line.Split(',');
- Scores.Add(parts[0], int.Parse(parts[1]));
- }
- }
- }
- catch (FileNotFoundException)
- {
- }
- }
-
- public override void CleanUp()
- {
- base.CleanUp();
- Font = null;
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- base.Draw(spriteBatch);
- spriteBatch.DrawString(Font, "YOUR SCORE WAS: " + Game.Player.Score.ToString(), new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2), Color.Black);
- spriteBatch.DrawString(Font, "Use Left Stick or Arrows to Choose Name Press A when done", new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 40), new Color(0, 0, 0, 128));
- nameChooser.Draw(spriteBatch);
- DrawScores(spriteBatch);
- }
-
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
- InputController.UpdateInput(false);
- nameChooser.Update(gameTime);
- }
-
- protected void DrawScores(SpriteBatch spriteBatch)
- {
- var sortedDict = (from entry in Scores orderby entry.Value descending select entry)
- .Take(5)
- .ToDictionary(pair => pair.Key, pair => pair.Value);
-
- var i = 0;
-
- foreach (KeyValuePair<string, int> entry in sortedDict) {
- i++;
- spriteBatch.DrawString(Font, entry.Key + " " + entry.Value, new Vector2(40, Game.GraphicsDevice.Viewport.Height / 2 + 100 + (32 * i)), new Color(0, 0, 0, 64));
- }
-
- }
- }
-}
diff --git a/SuperPolarityMac/Screen.cs b/SuperPolarityMac/Screen.cs
deleted file mode 100644
index 006b047..0000000
--- a/SuperPolarityMac/Screen.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class Screen
- {
- protected SuperPolarity Game;
- public bool Active;
- public Screen(SuperPolarity game)
- {
- Active = false;
- Game = game;
- }
-
- public virtual void Update(GameTime gameTime)
- {
- }
-
- public virtual void Draw(SpriteBatch spriteBatch)
- {
- }
-
- public virtual void LoadContent()
- {
- }
-
- public virtual void Initialize()
- {
- }
-
- public virtual void CleanUp()
- {
- }
- }
-}
diff --git a/SuperPolarityMac/ScreenManager.cs b/SuperPolarityMac/ScreenManager.cs
deleted file mode 100644
index b88741b..0000000
--- a/SuperPolarityMac/ScreenManager.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- static class ScreenManager
- {
- static Stack<Screen> Screens;
- static SuperPolarity Game;
-
- static ScreenManager()
- {
- Screens = new Stack<Screen>();
- }
-
- static public void Push(Screen screen)
- {
- if (Screens.Count > 0)
- {
- Screens.Peek().Active = false;
- }
-
- screen.LoadContent();
- screen.Active = true;
- Screens.Push(screen);
- }
-
- static public void Pop()
- {
- var screen = Screens.Pop();
- screen.Active = false;
- screen.CleanUp();
- Screens.Peek().Active = true;
- }
-
- static public void Update(GameTime gameTime)
- {
- Screens.Peek().Update(gameTime);
- }
-
- static public void Draw(SpriteBatch spriteBatch)
- {
- Screens.Peek().Draw(spriteBatch);
- }
-
- internal static void SetGame(SuperPolarity game)
- {
- Game = game;
- }
- }
-}
diff --git a/SuperPolarityMac/SuperPolarity.cs b/SuperPolarityMac/SuperPolarity.cs
deleted file mode 100644
index 9311d53..0000000
--- a/SuperPolarityMac/SuperPolarity.cs
+++ /dev/null
@@ -1,161 +0,0 @@
-#region Using Statements
-using System;
-using System.Collections.Generic;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-using Microsoft.Xna.Framework.Input;
-using Microsoft.Xna.Framework.Storage;
-using Microsoft.Xna.Framework.GamerServices;
-using Microsoft.Xna.Framework.Media;
-using Microsoft.Xna.Framework.Audio;
-using SuperPolarity;
-#endregion
-
-namespace SuperPolarity
-{
- /// <summary>
- /// This is the main type for your game
- /// </summary>
- public class SuperPolarity : Game
- {
- public GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
-
- public static int OutlierBounds;
-
- public Player Player;
-
- Screen EntryScreen;
-
- protected Song TitleSong;
- protected Song GameSong;
- protected SoundEffect GameOverSound;
-
- public SuperPolarity()
- : base()
- {
- graphics = new GraphicsDeviceManager(this);
- Components.Add(new GamerServicesComponent(this));
-
- graphics.PreferMultiSampling = true;
- graphics.PreferredBackBufferWidth = 1280;
- graphics.PreferredBackBufferHeight = 720;
- graphics.ToggleFullScreen();
-
- Content.RootDirectory = "Content";
- ActorFactory.SetGame(this);
- ParticleEffectFactory.SetGame(this);
- ActorManager.SetGame(this);
- ScreenManager.SetGame(this);
-
- EntryScreen = (Screen)new TitleScreen(this);
- }
-
- /// <summary>
- /// Allows the game to perform any initialization it needs to before starting to run.
- /// This is where it can query for any required services and load any non-graphic
- /// related content. Calling base.Initialize will enumerate through any components
- /// and initialize them as well.
- /// </summary>
- protected override void Initialize()
- {
- base.Initialize();
-
- InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
- InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
-
- EntryScreen.Initialize();
-
- OutlierBounds = 100;
- }
-
- protected void HandleFullScreenToggle(float value)
- {
- graphics.ToggleFullScreen();
- graphics.ApplyChanges();
- }
-
- /// <summary>
- /// LoadContent will be called once per game and is the place to load
- /// all of your content.
- /// </summary>
- protected override void LoadContent()
- {
-
- MediaPlayer.IsRepeating = true;
- GameSong = Content.Load<Song>("Sound\\polaritytheme.wav");
- GameOverSound = Content.Load<SoundEffect>("Sound\\gameover");
-
- // Create a new SpriteBatch, which can be used to draw textures.
- spriteBatch = new SpriteBatch(GraphicsDevice);
-
- ScreenManager.Push(EntryScreen);
-
- Player = new Player(this);
- }
-
- /// <summary>
- /// UnloadContent will be called once per game and is the place to unload
- /// all content.
- /// </summary>
- protected override void UnloadContent()
- {
- // TODO: Unload any non ContentManager content here
- }
-
- /// <summary>
- /// Allows the game to run logic such as updating the world,
- /// checking for collisions, gathering input, and playing audio.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
-
- ScreenManager.Update(gameTime);
-
- Player.Update();
-
- base.Update(gameTime);
- }
-
- /// <summary>
- /// This is called when the game should draw itself.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.White);
-
- spriteBatch.Begin();
-
- ScreenManager.Draw(spriteBatch);
-
- spriteBatch.End();
-
- base.Draw(gameTime);
- }
-
- public void PlaySong(string songName)
- {
- // temp stuff before media manager is in
- if (songName == "game")
- {
- MediaPlayer.Play(GameSong);
- }
- }
-
- public void GameOver()
- {
- var scoreScreen = new ScoreScreen(this);
- scoreScreen.Initialize();
-
- MediaPlayer.Stop();
- GameOverSound.Play();
- ScreenManager.Pop();
- ScreenManager.Push(scoreScreen);
- }
- }
-}
diff --git a/SuperPolarityMac/SuperPolarityMac.csproj b/SuperPolarityMac/SuperPolarityMac.csproj
index ded94e3..24da987 100644
--- a/SuperPolarityMac/SuperPolarityMac.csproj
+++ b/SuperPolarityMac/SuperPolarityMac.csproj
@@ -173,6 +173,7 @@
<Folder Include="Actors\" />
<Folder Include="Content\" />
<Folder Include="Properties\" />
+ <Folder Include="Content\Sound\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="..\SuperPolarity\Content\Graphics\circle.xnb">
@@ -251,26 +252,41 @@
<Link>Content\Fonts\smallfont.xnb</Link>
</BundleResource>
<BundleResource Include="Info.plist" />
- <BundleResource Include="..\SuperPolarity\Content\Sound\bomb.m4a">
- <Link>Content\Sound\bomb.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\bomb.xnb">
+ <Link>Content\Sound\bomb.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\bullet.m4a">
- <Link>Content\Sound\bullet.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\bullet.xnb">
+ <Link>Content\Sound\bullet.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\gameover.m4a">
- <Link>Content\Sound\gameover.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\gameover.xnb">
+ <Link>Content\Sound\gameover.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\hit.m4a">
- <Link>Content\Sound\hit.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\hit.xnb">
+ <Link>Content\Sound\hit.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\life.m4a">
- <Link>Content\Sound\life.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\life.xnb">
+ <Link>Content\Sound\life.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\polaritychange.m4a">
- <Link>Content\Sound\polaritychange.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\polaritychange.xnb">
+ <Link>Content\Sound\polaritychange.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
- <BundleResource Include="..\SuperPolarity\Content\Sound\polaritytheme.m4a">
- <Link>Content\Sound\polaritytheme.m4a</Link>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\polaritytheme.wav">
+ <Link>Content\Sound\polaritytheme.wav</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </BundleResource>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\polaritytheme.wma">
+ <Link>Content\Sound\polaritytheme.wma</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </BundleResource>
+ <BundleResource Include="..\SuperPolarity\Content\Sound\polaritytheme.xnb">
+ <Link>Content\Sound\polaritytheme.xnb</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</BundleResource>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/SuperPolarityMac/SuperPolarityMac.userprefs b/SuperPolarityMac/SuperPolarityMac.userprefs
index 4e3269b..7adb6cb 100644
--- a/SuperPolarityMac/SuperPolarityMac.userprefs
+++ b/SuperPolarityMac/SuperPolarityMac.userprefs
@@ -1,8 +1,8 @@
-<Properties MonoDevelop.MonoMac.LastXamMacNagTime="2/8/2014 5:55:19 PM">
+<Properties MonoDevelop.MonoMac.LastXamMacNagTime="2/11/2014 7:09:49 AM">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="../SuperPolarity/SuperPolarity.cs">
<Files>
- <File FileName="../SuperPolarity/SuperPolarity.cs" Line="75" Column="3" />
+ <File FileName="../SuperPolarity/SuperPolarity.cs" Line="88" Column="64" />
<File FileName="../SuperPolarity/GameScreen.cs" Line="1" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
diff --git a/SuperPolarityMac/TitleScreen.cs b/SuperPolarityMac/TitleScreen.cs
deleted file mode 100644
index a953f27..0000000
--- a/SuperPolarityMac/TitleScreen.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class TitleScreen : Screen
- {
- protected Texture2D TitleImage;
-
- public TitleScreen(SuperPolarity newGame) : base(newGame) {}
-
- public override void LoadContent()
- {
- base.LoadContent();
- TitleImage = Game.Content.Load<Texture2D>("Graphics\\polaritydemotitle");
- InputController.Bind("pause", HandleStart);
- }
-
- public void HandleStart(float value)
- {
- if (!Active) { return; }
- Game.Player.Reset();
- var gameScreen = new GameScreen(Game);
- gameScreen.Initialize();
- ScreenManager.Push(gameScreen);
- }
-
- public override void CleanUp()
- {
- base.CleanUp();
- TitleImage = null;
- }
-
- public override void Draw(SpriteBatch spriteBatch)
- {
- base.Draw(spriteBatch);
- spriteBatch.Draw(TitleImage, new Vector2(0, 0), Color.White);
- }
-
- public override void Update(GameTime gameTime)
- {
- base.Update(gameTime);
- InputController.UpdateInput(false);
- }
- }
-}
diff --git a/SuperPolarityMac/Widget.cs b/SuperPolarityMac/Widget.cs
deleted file mode 100644
index ea92cfd..0000000
--- a/SuperPolarityMac/Widget.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
- class Widget
- {
- public List<Widget> Children;
- public Dictionary<string, List<Action<float>>> Listeners;
-
- public Vector2 Position;
- public SuperPolarity Game;
-
- protected bool Active;
-
- public Widget(SuperPolarity game, Vector2 position)
- {
- Game = game;
- Position = position;
- Active = false;
- Children = new List<Widget>();
- Listeners = new Dictionary<string, List<Action<float>>>();
- }
-
- public void Activate()
- {
- Active = true;
- }
-
- public void Deactivate()
- {
- Active = false;
- }
-
- public virtual void AppendChild(Widget widget)
- {
- Children.Add(widget);
- }
-
- public virtual void Bind(string eventName, Action<float> eventListener)
- {
- List<Action<float>> newListenerList;
- List<Action<float>> listenerList;
- bool foundListeners;
-
- if (!Listeners.ContainsKey(eventName))
- {
- newListenerList = new List<Action<float>>();
- Listeners.Add(eventName, newListenerList);
- }
-
- foundListeners = Listeners.TryGetValue(eventName, out listenerList);
-
- listenerList.Add(eventListener);
- }
-
- public virtual void Unbind(string eventName, Action<float> eventListener)
- {
- // NOT YET IMPLEMENTED;
- }
-
- public virtual void Dispatch(string eventName, float value)
- {
- List<Action<float>> listenerList;
- bool foundListeners;
-
- foundListeners = Listeners.TryGetValue(eventName, out listenerList);
-
- if (!foundListeners)
- {
- return;
- }
-
- foreach (Action<float> method in listenerList)
- {
- method(value);
- }
- }
-
- public virtual void Update(GameTime gameTime)
- {
- }
-
- public virtual void Draw(SpriteBatch spriteBatch)
- {
- }
- }
-}
diff --git a/SuperPolarityMac/neutral-supercruiser.xnb b/SuperPolarityMac/neutral-supercruiser.xnb
deleted file mode 100644
index 1389842..0000000
--- a/SuperPolarityMac/neutral-supercruiser.xnb
+++ /dev/null
Binary files differ