Exemplo n.º 1
0
 public SmartCop(PhysicsComponent2D phys, MovementAIComponent2D move, DrawComponent draw, SmartCopState pState)
 {
     detectRadius = 400;
     movement = move;
     physics = phys;
     this.draw = draw;
     behavior = SmartCopBehavior.DEFAULT;
     state = defaultState = pState;
     this.BoundingRectangle = new COMP476Proj.BoundingRectangle(phys.Position, 16, 6);
     draw.Play();
 }
Exemplo n.º 2
0
 private void transitionToState(SmartCopState pState)
 {
     if (state == pState)
     {
         return;
     }
     switch (pState)
     {
         case SmartCopState.STATIC:
             if (hasSeenTheStreaker)
             {
                 hasSeenTheStreaker = false;
                 --copsWhoSeeTheStreaker;
             }
             behavior = SmartCopBehavior.DEFAULT;
             state = SmartCopState.STATIC;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_static");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.WANDER:
             if (hasSeenTheStreaker)
             {
                 hasSeenTheStreaker = false;
                 --copsWhoSeeTheStreaker;
             }
             behavior = SmartCopBehavior.DEFAULT;
             state = SmartCopState.WANDER;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_walk");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.FALL:
             behavior = SmartCopBehavior.KNOCKEDUP;
             state = SmartCopState.FALL;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_fall");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.GET_UP:
             behavior = SmartCopBehavior.KNOCKEDUP;
             state = SmartCopState.GET_UP;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_getup");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.PATROL:
             if (hasSeenTheStreaker)
             {
                 hasSeenTheStreaker = false;
                 --copsWhoSeeTheStreaker;
             }
             state = SmartCopState.PATROL;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_walk");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.PATHFIND:
             state = SmartCopState.PATHFIND;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_walk");
             physics.SetSpeed(true);
             physics.SetAcceleration(true);
             draw.Reset();
             break;
         case SmartCopState.HIT:
             behavior = SmartCopBehavior.AWARE;
             state = SmartCopState.HIT;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_attack");
             physics.SetSpeed(false);
             physics.SetAcceleration(false);
             draw.Reset();
             break;
         case SmartCopState.PURSUE:
             if (!hasSeenTheStreaker)
             {
                 hasSeenTheStreaker = true;
                 ++copsWhoSeeTheStreaker;
                 if (!chasing)
                     DataManager.GetInstance().numberOfCopsChasing++;
                 chasing = true;
             }
             behavior = SmartCopBehavior.AWARE;
             state = SmartCopState.PURSUE;
             draw.animation = SpriteDatabase.GetAnimation("smartCop_walk");
             physics.SetSpeed(true);
             physics.SetAcceleration(true);
             draw.Reset();
             break;
     }
 }