示例#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));
        }
    }