Ejemplo n.º 1
0
    void executePlague(int id)
    {
        plagueHappening  = true;
        activePlague     = pm.getPlague(id);
        plagueInitialDay = tm.getCurrentDay();
        remainingChunks  = 0;

        WorldTerrain wt            = WorldTerrain.GetInstance();
        int          tilesPerChunk = wt.getTotalTilesInAChunk();

        visitedChunk = new bool[wt.getNumberOfChunks()];
        for (int i = 0; i < wt.getNumberOfChunks(); i++)
        {
            visitedChunk [i] = true;
        }
        for (int i = 0; i < wt.getNumberOfChunks(); i++)
        {
            int rnd = Random.Range(1, 3);
            if ((rnd < 3 || remainingChunks == 0) && wt.isChunkPlanted(i))
            {
                visitedChunk[i] = false;
                remainingChunks++;
                uint randomTile = (uint)((UnityEngine.Random.value) * (float)(tilesPerChunk - 1));
                wt.updatePlagueStateInTile(i, (int)randomTile, plagueType(activePlague.getID()));
            }
        }
        if (remainingChunks == 0)
        {
            cleanPlague();
        }
        else
        {
            activePlague.setActive(true);
        }
    }
Ejemplo n.º 2
0
    public void ClearOneChunk(int id)
    {
        if (visitedChunk != null && visitedChunk.Length > id)
        {
            //TO DO: CAREFUL SOMETIMES THIS IS NULL IDK WHY
            if (!visitedChunk [id])
            {
                remainingChunks--;
                visitedChunk [id] = true;

                if (activePlague.getID() == 1)
                {
                    CoopManager.GetInstance().loseEcologyPlageControlPoint();
                }

                if (remainingChunks == 0)
                {
                    cleanPlague();
                }
            }
        }
    }