Beispiel #1
0
 //is called only for new collisions
 private void OnCollisionEnter(Enemy other)
 {
     if (other._state == EnemyState.hit)
     {
         other._state = EnemyState.walk;
         if (other.directionHit == PlayerDirection.left)
         {
             while (HitTest(other))
             {
                 x -= 10;
             }
         }
         else if (other.directionHit == PlayerDirection.right)
         {
             while (HitTest(other))
             {
                 x += 10;
             }
         }
         else if (other.directionHit == PlayerDirection.up)
         {
             while (HitTest(other))
             {
                 y -= 10;
             }
         }
         else if (other.directionHit == PlayerDirection.down)
         {
             while (HitTest(other))
             {
                 y += 10;
             }
         }
     }
     other._state = EnemyState.walk;
     other.TurnAround();
 }
Beispiel #2
0
 //read a single Tiled Object
 private void interpretObject(TiledObject tiledObject)
 {
     //create an enemy
     Enemy enemy = new Enemy(tiledObject);
     AddChild(enemy);
 }