X hits on this document

284 views

0 shares

0 downloads

0 comments

82 / 102

       && enemy.Catapult.CurrentState != CatapultState.Hit

       && enemy.Catapult.CurrentState != CatapultState.Reset)

   {

       AudioManager.PlaySound("catapultExplosion");

       // Launch enemy hit animaton

       enemy.Catapult.Hit();

       self.Score++;

       bRes = true;

       currentState = CatapultState.Reset;

   }

   return bRes;

}

Note: Compare this version with the previous one, focusing on the code near the “TODO” marker comments in order to see the changes best.

177.

Replace the Catapult class’s Hit method with the following:

C#

public void Hit()

{

   AnimationRunning = true;

   animations["Destroyed"].PlayFromFrameIndex(0);

   animations["hitSmoke"].PlayFromFrameIndex(0);

   currentState = CatapultState.Hit;

}

178.

Add an additional reference to the CatapultGame project. The reference is for the Microsoft.Phone assembly.

179.

Replace the Catapult class’s Update method with the following:

C#

public override void Update(GameTime gameTime)

{

   bool isGroundHit;

   bool startStall;

   CatapultState postUpdateStateChange = 0;

   if (gameTime == null)

       throw new ArgumentNullException("gameTime");

   switch (currentState)

   {

       case CatapultState.Idle:

           // Nothing to do

           break;

       case CatapultState.Aiming:

           if (lastUpdateState != CatapultState.Aiming)

Page | 82

Document info
Document views284
Page views284
Page last viewedFri Dec 09 19:42:00 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments