Skip to content

Commit

Permalink
Add cop controller and spawner and add support for them getting hit b…
Browse files Browse the repository at this point in the history
…y the door
  • Loading branch information
zumpiez committed Apr 1, 2012
1 parent c2b7a88 commit 30f00d6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DemonDoor/DemonDoor/CivvieController.cs
Expand Up @@ -15,7 +15,7 @@ class CivvieController : IDrawableThing, ICollidable, IBrainyThing
CivvieSprite myCorpse = null;
Vector2 screen;

private Body _fsBody;
internal Body _fsBody;
private Shape _fsShape;
private Fixture _fsFixture;
private World _world;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void ProcessBehavior(GameTime time)
}
}

private void Die()
internal void Die()
{
this.behaviorState = BehaviorState.Dead;
myCorpse.SetAnimationState(CivvieSprite.AnimationState.Dead);
Expand Down
2 changes: 2 additions & 0 deletions DemonDoor/DemonDoor/DemonDoor.csproj
Expand Up @@ -118,6 +118,8 @@
<Compile Include="Coords.cs" />
<Compile Include="CivvieController.cs" />
<Compile Include="CopSprite.cs" />
<Compile Include="CopController.cs" />
<Compile Include="CopSpawner.cs" />
<Compile Include="DoorSprite.cs" />
<Compile Include="DemonController.cs" />
<Compile Include="GameOverScreen.cs" />
Expand Down
3 changes: 1 addition & 2 deletions DemonDoor/DemonDoor/DoorController.cs
Expand Up @@ -47,8 +47,7 @@ private bool PhysicsCollided(Fixture f1, Fixture f2, Contact contact)
other = f1;
}

if (other.UserData is CivvieController && !_alreadyShot.Contains(other)) {
CivvieController c = other.UserData as CivvieController;
if ((other.UserData is CivvieController || other.UserData is CopController) && !_alreadyShot.Contains(other)) {
//Console.WriteLine("collided with corpse {0}, kickin' it", c);

other.Body.ApplyLinearImpulse(Impulse);
Expand Down
3 changes: 2 additions & 1 deletion DemonDoor/DemonDoor/Game1.cs
Expand Up @@ -20,7 +20,7 @@ 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_civvie, im_title, im_door, im_stage, im_skybox, im_demon, im_gameover, im_cop;
public Texture2D[] im_clouds;
public SpriteFont ft_hud24;

Expand Down Expand Up @@ -82,6 +82,7 @@ internal void LoadLevel(string level)
im_skybox = Content.Load<Texture2D>( "art/skybox" );
im_demon = Content.Load<Texture2D>( "art/demon" );
im_gameover = Content.Load<Texture2D>("art/gameover");
im_cop = Content.Load<Texture2D>("art/police_01");

_engine = new AudioEngine("Content/music.xgs");
_sb = new SoundBank(_engine, "Content/Sound Bank.xsb");
Expand Down
7 changes: 7 additions & 0 deletions DemonDoor/DemonDoor/Level1Screen.cs
Expand Up @@ -54,6 +54,9 @@ internal override void Load()
SpriteBasis civSpriteBasis = new SpriteBasis(16, 16, 7, 7);
civSpriteBasis.image = game1.im_civvie;

SpriteBasis copSpriteBasis = new SpriteBasis(16, 16, 10, 10);
copSpriteBasis.image = game1.im_cop;

mcg = new McGrenderStack();
Game1.game.setMcGrender(mcg);

Expand Down Expand Up @@ -119,6 +122,10 @@ internal override void Load()
Vector2 spawnerR = Coords.Screen2Physics(new Vector2 { X = 325, Y = 218 });
var civvieSpawner = new CivvieSpawner(_world, l, spawnerR, TimeSpan.FromSeconds(1), civSpriteBasis, 1000);
l.AddNode(new McgNode(civvieSpawner, l, 80, 20));

//spawn cops
var copSpawner = new CopSpawner(_world, l, spawnerR, TimeSpan.FromSeconds(1), copSpriteBasis, 1000);
l.AddNode(new McgNode(copSpawner, l, 80, 20));
}

Vector2 _aimPoint = Vector2.UnitX;
Expand Down

0 comments on commit 30f00d6

Please sign in to comment.