Esempio n. 1
0
    /// <summary>
    /// Spawns a ghost given the type
    /// </summary>
    /// <param name="type">The type of ghost to spawn</param>
    void SpawnGhost(Ghost.Type type, bool aStar = false)
    {
        Node ghostHouseLeft  = currentLevel.GhostHouseLeft;
        Node ghostHouseRight = currentLevel.GhostHouseRight;

        switch (type)
        {
        case Ghost.Type.blinky:
            Ghost blinky = Instantiate(blinkyPrefab);
            blinky.Init(ghostHouseLeft, currentLevel.BlinkyHomeNode, currentLevel.GhostTimings, aStar);
            ghosts.Add(blinky);
            break;

        case Ghost.Type.pinky:
            Ghost pinky = Instantiate(pinkyPrefab);
            pinky.Init(ghostHouseRight, currentLevel.PinkyHomeNode, currentLevel.GhostTimings, aStar);
            ghosts.Add(pinky);
            break;

        case Ghost.Type.inky:
            Ghost inky = Instantiate(inkyPrefab);
            inky.Init(ghostHouseRight, currentLevel.InkyHomeNode, currentLevel.GhostTimings, aStar);
            ghosts.Add(inky);
            break;

        case Ghost.Type.clyde:
            Ghost clyde = Instantiate(clydePrefab);
            clyde.Init(ghostHouseLeft, currentLevel.ClydeHomeNode, currentLevel.GhostTimings, aStar);
            ghosts.Add(clyde);
            break;
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Gets a ghost given the type
 /// </summary>
 /// <param name="type">The type of the ghost to get</param>
 /// <returns>The ghost of the given type (or null if it doesnt exist)</returns>
 public Ghost GetGhost(Ghost.Type type)
 {
     for (int i = 0; i < ghosts.Count; i++)
     {
         if (ghosts[i].GhostType == type)
         {
             return(ghosts[i]);
         }
     }
     return(null);
 }