private void QueueTest() { //create Queue of Ghosts MonogameGhost redGhost = new MonogameGhost(this); MonogameGhost purpleGhost = new MonogameGhost(this); purpleGhost.strGhostTexture = "PurpleGhost"; MonogameGhost tealGhost = new MonogameGhost(this); tealGhost.strGhostTexture = "TealGhost"; Queue <GameComponent> ghostQueue = new Queue <GameComponent>(); ghostQueue.Enqueue(redGhost); ghostQueue.Enqueue(purpleGhost); ghostQueue.Enqueue(tealGhost); List <GameComponent> ghostList = new List <GameComponent>(); ghostList.Add(redGhost); ghostList.Add(purpleGhost); ghostList.Add(tealGhost); System.Console.WriteLine(redGhost is GameComponent); }
public void DeleteGhost(MonogameGhost ghostToDelete) { if (ghosts.Contains(ghostToDelete)) { ghosts.Remove(ghostToDelete); ghostToDelete.Dispose(); } }
/// <summary> /// check if a ghost collides with any other ghosts /// </summary> /// <param name="ghost"></param> /// <returns></returns> public bool CheckCollision(MonogameGhost ghost) { bool output = false; foreach (MonogameGhost g in ghosts) { if (g != ghost) { if (ghost.Intersects(g)) { output = true; break; } } } return(output); }
public void SpawnGhost(MonogameGhost ghostToSpawn) { MonogameGhost newghost = ghostToSpawn; newghost.Initialize(); newghost.ghostTexture = ghostTextures[nextTextureIndex]; nextTextureIndex++; if (nextTextureIndex >= ghostTextures.Count) { nextTextureIndex = 0; } newghost.Location = newghost.GetRandLocation(); while (CheckCollision(newghost)) { newghost.Location = newghost.GetRandLocation(); } this.AddGhost(newghost); }
void AddGhost(MonogameGhost newGhost) { ghosts.Add(newGhost); }