Permalink
Browse files

Civilian spawning is now cycly

  • Loading branch information...
mcgrue committed Apr 1, 2012
1 parent e3dc879 commit ea3c080c0531f0c1c7389f08e96f23a3c87c9897
@@ -14,16 +14,16 @@ class CivvieSpawner : IDrawableThing, IBrainyThing
private McgLayer layer;
private World world;
private Vector2 location;
- private SpriteBasis civvieSpriteBasis;
+ private SpriteBasis[] civvieSpriteBasisList;
private int spawnRateFuzzMillis;
- public CivvieSpawner(World world, McgLayer layer, Vector2 location, TimeSpan spawnRate, SpriteBasis civvieSpriteBasis, int spawnRateFuzzMillis = 0)
+ public CivvieSpawner(World world, McgLayer layer, Vector2 location, TimeSpan spawnRate, SpriteBasis[] civvieSpriteBasis, int spawnRateFuzzMillis = 0)
{
this.layer = layer;
this.world = world;
this.spawnRate = spawnRate;
this.location = location;
- this.civvieSpriteBasis = civvieSpriteBasis;
+ this.civvieSpriteBasisList = civvieSpriteBasis;
this.spawnRateFuzzMillis = spawnRateFuzzMillis;
}
@@ -42,12 +42,21 @@ public RenderDelegate GetDrawDelegate()
return (x, y) => { };
}
+ private static int nextIdx = 0;
+ public int getnextCivvieIdx() {
+ nextIdx++;
+ if( nextIdx >= civvieSpriteBasisList.Length ) {
+ nextIdx = 0;
+ }
+ return nextIdx;
+ }
+
public void ProcessBehavior(Microsoft.Xna.Framework.GameTime time)
{
spawnTimeAccumulator += time.ElapsedGameTime;
if (spawnTimeAccumulator > spawnRate)
{
- layer.AddNode(new McgNode(new CivvieController(world, new Vector2(location.X, location.Y), new CivvieSprite(civvieSpriteBasis)), layer,
+ layer.AddNode(new McgNode(new CivvieController(world, new Vector2(location.X, location.Y), new CivvieSprite(civvieSpriteBasisList[getnextCivvieIdx()])), layer,
(int)location.X, (int)location.Y));
spawnTimeAccumulator = TimeSpan.FromMilliseconds(VERGEGame.rand.Next(-spawnRateFuzzMillis, 0));
}
@@ -19,6 +19,12 @@ Content\art\cloud_08.xnb
Content\art\cloud_09.xnb
Content\art\demon.xnb
Content\art\gameover.xnb
+Content\art\civilian_02.xnb
+Content\art\civilian_03.xnb
+Content\art\civilian_04.xnb
+Content\art\civilian_05.xnb
+Content\art\civilian_06.xnb
+Content\art\civilian_07.xnb
Content\music.xgs
Content\Wave Bank.xwb
Content\Sound Bank.xsb
@@ -20,7 +20,8 @@ public class Game1 : VERGEGame {
public McGrenderStack mcg;
- public Texture2D im_civvie, im_title, im_door, im_stage, im_skybox, im_demon, im_gameover;
+ public Texture2D im_title, im_door, im_stage, im_skybox, im_demon, im_gameover;
+ public Texture2D[] im_civvies;
public Texture2D[] im_clouds;
public SpriteFont ft_hud24;
@@ -74,8 +75,7 @@ internal void LoadLevel(string level)
game = this;
_activeCues = new List<Cue>();
- // TODO: Add your initialization logic here
- im_civvie = Content.Load<Texture2D>( "art/civilian_01" );
+ // TODO: Add your initialization logic here
im_title = Content.Load<Texture2D>( "art/title" );
im_door = Content.Load<Texture2D>( "art/door" );
im_stage = Content.Load<Texture2D>( "art/stage" );
@@ -93,6 +93,12 @@ internal void LoadLevel(string level)
}
im_clouds = tmpLst.ToArray();
+ tmpLst = new List<Texture2D>();
+ for( int i = 1; i < 8; i++ ) {
+ tmpLst.Add( Content.Load<Texture2D>( "art/civilian_0" + i ) );
+ }
+ im_civvies = tmpLst.ToArray();
+
ft_hud24 = Content.Load<SpriteFont>( "HUD24" );
LoadLevel("title");
@@ -51,8 +51,13 @@ internal override void Load()
Wall _wall1 = new Wall(_world, verts);
//Wall _wall1 = new Wall(_world, _666pos.X, -1);
- SpriteBasis civSpriteBasis = new SpriteBasis(16, 16, 7, 7);
- civSpriteBasis.image = game1.im_civvie;
+ List<SpriteBasis> civilianList = new List<SpriteBasis>();
+
+ for( int i = 0; i < game1.im_civvies.Length; i++ ) {
+ SpriteBasis civSpriteBasis = new SpriteBasis( 16, 16, 7, 7 );
+ civSpriteBasis.image = game1.im_civvies[i];
+ civilianList.Add( civSpriteBasis );
+ }
mcg = new McGrenderStack();
Game1.game.setMcGrender(mcg);
@@ -117,7 +122,7 @@ internal override void Load()
//spawn guys
Vector2 spawnerR = Coords.Screen2Physics(new Vector2 { X = 325, Y = 218 });
- var civvieSpawner = new CivvieSpawner(_world, l, spawnerR, TimeSpan.FromSeconds(1), civSpriteBasis, 1000);
+ var civvieSpawner = new CivvieSpawner( _world, l, spawnerR, TimeSpan.FromSeconds( 1 ), civilianList.ToArray(), 1000 );
l.AddNode(new McgNode(civvieSpawner, l, 80, 20));
}
@@ -176,6 +176,38 @@
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="art\civilian_02.png">
+ <Name>civilian_02</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="art\civilian_03.png">
+ <Name>civilian_03</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="art\civilian_04.png">
+ <Name>civilian_04</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="art\civilian_05.png">
+ <Name>civilian_05</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="art\civilian_06.png">
+ <Name>civilian_06</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ <Compile Include="art\civilian_07.png">
+ <Name>civilian_07</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</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.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -35,7 +35,7 @@
<Processor>TextureProcessor</Processor>
<Options>None</Options>
<Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\stage.xnb</Output>
- <Time>2012-04-01T12:52:06.312-07:00</Time>
+ <Time>2012-04-01T15:31:05.972-07:00</Time>
</Item>
<Item>
<Source>art\title.png</Source>
@@ -190,6 +190,60 @@
<Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\gameover.xnb</Output>
<Time>2012-04-01T14:03:32.347-07:00</Time>
</Item>
+ <Item>
+ <Source>art\civilian_02.png</Source>
+ <Name>art\civilian_02</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_02.xnb</Output>
+ <Time>2012-04-01T14:37:10.054-07:00</Time>
+ </Item>
+ <Item>
+ <Source>art\civilian_03.png</Source>
+ <Name>art\civilian_03</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_03.xnb</Output>
+ <Time>2012-04-01T14:37:51.097-07:00</Time>
+ </Item>
+ <Item>
+ <Source>art\civilian_04.png</Source>
+ <Name>art\civilian_04</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_04.xnb</Output>
+ <Time>2012-04-01T14:41:54.036-07:00</Time>
+ </Item>
+ <Item>
+ <Source>art\civilian_05.png</Source>
+ <Name>art\civilian_05</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_05.xnb</Output>
+ <Time>2012-04-01T14:44:41.666-07:00</Time>
+ </Item>
+ <Item>
+ <Source>art\civilian_06.png</Source>
+ <Name>art\civilian_06</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_06.xnb</Output>
+ <Time>2012-04-01T14:45:03.87-07:00</Time>
+ </Item>
+ <Item>
+ <Source>art\civilian_07.png</Source>
+ <Name>art\civilian_07</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ <Options>None</Options>
+ <Output>C:\grue\demon_door\DemonDoor\DemonDoor\bin\x86\Debug\Content\art\civilian_07.xnb</Output>
+ <Time>2012-04-01T14:45:40.096-07:00</Time>
+ </Item>
<BuildSuccessful>true</BuildSuccessful>
<Settings>
<TargetPlatform>Windows</TargetPlatform>

0 comments on commit ea3c080

Please sign in to comment.