Beispiel #1
0
 private void DoGhostStuff()
 {
     // check to see if player is dead
     foreach (Ghost ghost in ghosts)
     {
         if (!player.invincible && player.IsEncountering(ghost))
         {
             player.ghostEncounters--;
             Remove(ghost);
             if (player.ghostEncounters == 0)
             {
                 mainPage.EndGame();
                 PrepareForNewGame();
                 return;
             }
             player.invincible = true;
         }
     }
     // add a ghost sometimes
     double next = random.NextDouble();
     if (ghosts.Count < maxGhosts && next > generateGhost)
     {
         Ghost ghost = new Ghost(this);
         gameObjects.Add(ghost);
         ghosts.Add(ghost);
     }
 }
Beispiel #2
0
 public Boolean IsEncountering(Ghost ghost)
 {
     if (pos.X > ghost.pos.X && pos.X < ghost.pos.X + ghost.size &&
         pos.Z > ghost.pos.Z && pos.Z < ghost.pos.Z + ghost.size)
     {
         return true;
     }
     return false;
 }