</Compile>
</ItemGroup>
<ItemGroup>
- <Folder Include="Fonts\" />
<Folder Include="Sound\" />
</ItemGroup>
<ItemGroup>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Fonts\SegoeUIMono14.spritefont">
+ <Name>SegoeUIMono14</Name>
+ <Importer>FontDescriptionImporter</Importer>
+ <Processor>FontDescriptionProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
mainShip.Initialize(Game.Content.Load<Texture2D>("Graphics\\main-ship"), position);
ActorManager.CheckIn(mainShip);
+ Renderer.CheckIn(mainShip);
return mainShip;
}
ship.SetPolarity(polarity);
ActorManager.CheckIn(ship);
+ Renderer.CheckIn(ship);
return ship;
}
bullet.Angle = angle;
ActorManager.CheckIn(bullet);
+ Renderer.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.5f;
+ ship.FleeVelocity = 6.5f;
+ ship.ChargeVelocity = 5.5f;
+ ship.Value = 3;
+ ship.HP = 0;
+ ship.AngleChangeProbability = 20;
+ ship.SetPolarity(polarity);
+
+ ActorManager.CheckIn(ship);
+ Renderer.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.MaxVelocity = 0.5f;
+ ship.FleeVelocity = 5;
+ ship.ChargeVelocity = 1;
+ ship.Value = 10;
+ ship.HP = 9;
+ ship.SetPolarity(polarity);
+
+ ActorManager.CheckIn(ship);
+ Renderer.CheckIn(ship);
+
+ return ship;
+ }
}
}
protected Vector2 Origin;
public bool Active;
public Rectangle Box;
- protected Vector4 BoxDimensions;
+ public Vector4 BoxDimensions;
protected Texture2D BoxTexture;
// Physical Properties
public float Angle;
// Constraints / Behavior
- protected float MaxVelocity;
+ public float MaxVelocity;
protected float AccelerationRate;
- protected int HP;
+ public int HP;
protected bool Immortal;
public bool Dying;
public int Value;
public Actor(SuperPolarity newGame)
{
game = newGame;
+ BoxDimensions.X = 20;
+ BoxDimensions.Y = 20;
+ BoxDimensions.W = 15;
+ BoxDimensions.Z = 15;
}
public virtual void Initialize(Texture2D texture, Vector2 position)
HP = 1;
Immortal = false;
- BoxDimensions.X = 20;
- BoxDimensions.Y = 20;
- BoxDimensions.W = 20;
- BoxDimensions.Z = 20;
Dying = false;
Value = 1;
protected void InitBox()
{
- Box = new Rectangle((int)(Position.X - BoxDimensions.X), (int)(Position.Y - BoxDimensions.X), (int)(BoxDimensions.X + BoxDimensions.W), (int)(BoxDimensions.Y + BoxDimensions.Z));
+ Box = new Rectangle((int)(Position.X - BoxDimensions.X), (int)(Position.Y - BoxDimensions.X), (int)(BoxDimensions.X + BoxDimensions.X + BoxDimensions.W), (int)(BoxDimensions.Y + BoxDimensions.Y + BoxDimensions.Z));
}
public void AutoDeccelerate(GameTime gameTime)
public void ChangeAngle()
{
+ if (Math.Abs(Velocity.Y) <= 0.1 && Math.Abs(Velocity.X) <= 0.1)
+ {
+ return;
+ }
Angle = (float)Math.Atan2(Velocity.Y, Velocity.X);
}
BoxDimensions.Y = 10;
BoxDimensions.W = 10;
BoxDimensions.Z = 10;
+ MaxVelocity = 8;
InitBox();
particleEngine = ParticleEffectFactory.CreateBullet(position);
}
protected override void Die()
{
ActorManager.CheckOut(this);
+ Renderer.CheckOut(this);
Parent.Children.Remove(this);
}
}
public Polarity CurrentPolarity;
public uint MagneticRadius;
- protected float FleeVelocity;
- protected float ActVelocity;
- protected float ChargeVelocity;
+ public float FleeVelocity;
+ public float ActVelocity;
+ public float ChargeVelocity;
protected int RepelRadius;
protected bool Magnetizing;
MagneticRadius = 250;
RepelRadius = 100;
- HP = 5;
+ HP = 2;
FleeVelocity = 5;
- ActVelocity = 2;
- ChargeVelocity = 1.5f;
+ ActVelocity = 1;
+ ChargeVelocity = 2.5f;
CurrentPolarity = Polarity.Neutral;
Magnetizing = false;
}
class StandardShip : Ship
{
+ protected bool Flashing;
protected int ChangeRate;
protected int CurrentTime;
- protected int AngleChangeProbability;
+ public int AngleChangeProbability;
protected int BouncePadding;
protected float RotationFactor;
protected Random Random;
ChangeRate = 50;
AngleChangeProbability = 50;
BouncePadding = 0;
- MaxVelocity = 1;
+ MaxVelocity = 2;
CurrentTime = 0;
RotationFactor = (float) (3 * Math.PI / 180);
Random = new Random(BitConverter.ToInt32(cryptoResult, 0));
AddingAngle = true;
-
- HP = 5;
}
public override void Magnetize(Ship ship, float distance, float angle)
Position += Velocity;
UpdateBox();
Magnetizing = false;
+
+ if (Flashing)
+ {
+ Color = new Color(255, 255, 255, 128);
+ Flashing = false;
+ }
+ else
+ {
+ Color = Color.White;
+ }
}
protected void AutoMove()
{
var theBullet = (Bullet)other;
TakeDamage(theBullet.Power);
+ Flashing = true;
}
}
--- /dev/null
+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);
+ }
+
+ }
+ }
+}
{
public GameScreen(SuperPolarity newGame) : base(newGame) {}
+ private BasicGenerator generatorTest;
+
public override void Initialize()
{
InputController.RegisterEventForButton("changePolarity", Buttons.A);
public override void LoadContent()
{
+
+ generatorTest = new BasicGenerator();
+ generatorTest.Initialize(Game, new Vector2(100, 600), BasicGenerator.Ships.Scout, 3000, 10);
+
Vector2 playerPosition = new Vector2(Game.GraphicsDevice.Viewport.TitleSafeArea.X, Game.GraphicsDevice.Viewport.TitleSafeArea.Y + Game.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
- Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
- Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200)));
- Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200)));
+ ActorFactory.CreateMainShip(playerPosition);
+ ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200));
+ ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200));
+ ActorFactory.CreateScout(Ship.Polarity.Negative, new Vector2(500, 500));
+ ActorFactory.CreateCruiser(Ship.Polarity.Positive, new Vector2(40, 40));
}
public override void Update(GameTime gameTime)
{
InputController.UpdateInput();
ActorManager.Update(gameTime);
+ generatorTest.Update(gameTime);
}
public override void Draw(SpriteBatch spriteBatch)
<Compile Include="ActorManager.cs" />
<Compile Include="Actors\StandardShip.cs" />
<Compile Include="Actors\Bullet.cs" />
+ <Compile Include="BasicGenerator.cs" />
<Compile Include="GameScreen.cs" />
<Compile Include="InputController.cs" />
<Compile Include="Actors\MainShip.cs" />
<None Include="Content\Graphics\neutral-ship.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
- <None Include="Content\Graphics\neutral-supercruiser.xnb">
+ <None Include="neutral-supercruiser.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\Graphics\positive-cruiser.xnb">
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\neutral-destroyer.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\neutral-scout.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\neutral-ship.xnb
-C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\neutral-supercruiser.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\positive-cruiser.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\positive-destroyer.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\positive-scout.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\negative-ship.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\square.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Fonts\SegoeUIMono14.xnb
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\neutral-supercruiser.xnb