Example #1
0
    IEnumerator ProcessDigList()
    {
        while (true)
        {
            digList.RemoveAll(tile => tile.Opened);

            digList.ForEach(tile => {
                // Do we have surrounding tiles in Hell?
                List <LevelTile> surrounding = LevelHelpers.GetAdjacentTiles(LevelController.Instance.Model, tile.X, tile.Z);
                LevelTile found = surrounding.Find(obj => (obj.Opened && LevelHelpers.IsTileInHell(LevelController.Instance.Model, obj.X, obj.Z)));

                // If so, dig them with some minions
                if (found != null)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        GameObject minion = GetNearestNonBusyMinion(tile);

                        if (minion)
                        {
                            minion.GetComponent <ActionQueue>().InsertBeforeCurrent(new DigAction(minion, new Vector2(tile.X, tile.Z)));
                        }
                    }
                }
            });

            yield return(new WaitForSeconds(1));
        }
    }
Example #2
0
    private void FloodFill(int x, int z, LevelTile[,] tileList)
    {
        if (tileList[x, z] == null &&
            Tiles[x, z].Opened)
        {
            tileList[x, z] = Tiles[x, z];

            List <LevelTile> surroundingTiles = LevelHelpers.GetAdjacentTiles(this, x, z);

            surroundingTiles.ForEach(tile => FloodFill(tile.X, tile.Z, tileList));
        }
    }
Example #3
0
    public void UpdateContiguousTilesFrom(int x, int z)
    {
        List <LevelTile> surroundingTiles = LevelHelpers.GetAdjacentTiles(this, x, z);

        LevelTile foundHell = surroundingTiles.Find(tile => HellContiguousTiles[tile.X, tile.Z] != null);

        LevelTile foundHeaven = surroundingTiles.Find(tile => HeavenContiguousTiles[tile.X, tile.Z] != null);

        // if we're about to join, just copy everything to save a painful flood fill.
        if (foundHell != null &&
            foundHeaven != null)
        {
            for (int iz = 0; iz < Length; ++iz)
            {
                for (int ix = 0; ix < Width; ++ix)
                {
                    if (HellContiguousTiles[ix, iz] != null)
                    {
                        HeavenContiguousTiles[ix, iz] = HellContiguousTiles[ix, iz];
                    }
                    else if (HeavenContiguousTiles[ix, iz] != null)
                    {
                        HellContiguousTiles[ix, iz] = HeavenContiguousTiles[ix, iz];
                    }
                }
            }
        }

        if (foundHell != null)
        {
            FloodFill(x, z, HellContiguousTiles);
        }

        if (foundHeaven != null)
        {
            FloodFill(x, z, HeavenContiguousTiles);
        }
    }