示例#1
0
        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);
        }
示例#2
0
 public void DeleteGhost(MonogameGhost ghostToDelete)
 {
     if (ghosts.Contains(ghostToDelete))
     {
         ghosts.Remove(ghostToDelete);
         ghostToDelete.Dispose();
     }
 }
示例#3
0
        /// <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);
        }
示例#4
0
        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);
        }
示例#5
0
 void AddGhost(MonogameGhost newGhost)
 {
     ghosts.Add(newGhost);
 }