Exemplo n.º 1
0
    private void generateNextSpawnPoints(int spawnCount)
    {
        //int i = 0;
        //while (i++ < spawnCount)
        //{
        //    Color currentColor = getRandomColor();
        //    Tile currentTile = getRandomUnoccupiedTile();
        //    GameObject atomObject = GameObject.Instantiate(
        //        ghostAtomTypes[currentColor], currentTile.getGameObject().transform);
        //    GhostAtom newGhostAtom = new GhostAtom(currentTile, currentColor, atomObject);
        //    board.addGhostAtom(ref newGhostAtom);
        //}

        HashSet <Tile> candidateSet    = getSpawnPointsCandidates();
        List <Tile>    spawnPointsList = new List <Tile>(candidateSet);

        System.Random randomizer = new System.Random();
        for (int i = 0; i < spawnCount; i++)
        {
            int   randomIndex  = randomizer.Next(spawnPointsList.Count);
            Color currentColor = getRandomColor();
            Tile  currentTile  = spawnPointsList[randomIndex];
            spawnPointsList.Remove(currentTile);

            GameObject atomObject = GameObject.Instantiate(
                ghostAtomTypes[currentColor], currentTile.getGameObject().transform);
            GhostAtom newGhostAtom = new GhostAtom(currentTile, currentColor, atomObject);
            board.addGhostAtom(ref newGhostAtom);
        }
    }
Exemplo n.º 2
0
 internal void addGhostAtom(ref GhostAtom ghostAtom)
 {
     if (!tiles.Contains(ghostAtom.getTile()))
     {
         throw new Exception("Tile to add ghost to doesnt exist here!");
     }
     ghostAtoms.Add(ghostAtom);
     ghostOccupiedTiles.Add(ghostAtom.getTile(), ghostAtom);
 }