public void detectEnemy(PacManCharacter pacManCharcter, GhostCharacter ghostCharacter) //Detects collision betwen pacman and ghosts { if (pacManCharcter.Position.X == ghostCharacter.Position.X && pacManCharcter.Position.Y == ghostCharacter.Position.Y) { if (ghostCharacter.Scared) // If the ghost is vulnerable, it dies and pacMan wins points. { ghostDies(ghostCharacter); ghostEaten.Play(); score = score + 200; } else // otherwise, pacMan dies. { if (pacManCharacter.Life > 0) { pacmanDead.Play(); pacManCharacter.looseLife(); pacManCharacter.Moving = false; } } } }
public AnimatedGhost(Texture2D texture, Vector2 position, Vector2 size, GhostCharacter ghostCharacter) : base(texture, position, size) { this._ghostCharacter = ghostCharacter; }
public void ghostDies(GhostCharacter ghostCharacter) // Replaces the ghosts when they die. They aren't scared anymore { ghostCharacter.Position = ghostCharacter.InitialPosition; ghostCharacter.Scared = false; ghostCharacter.InHouse = true; }