コード例 #1
0
ファイル: WorldManager.cs プロジェクト: MarkianovNikita/GGJ19
    private IEnumerator CreateZones()
    {
        _zones = new List <ZoneController>();

        int idCounter = 0;

        ZoneController zone = new ZoneController();

        zone.ZoneID = idCounter;
        _zones.Add(zone);

        for (int i = _worldSize / 2 - _homeSize / 2; i <= _worldSize / 2 + _homeSize / 2; i++)
        {
            for (int j = _worldSize / 2 - _homeSize / 2; j <= _worldSize / 2 + _homeSize / 2; j++)
            {
                _cellsArr[i, j].ZoneID = idCounter;
                _cellsArr[i, j].Empty  = false;

                zone.Cells.Add(_cellsArr[i, j]);
            }
        }

        idCounter++;

        for (int x = 0; x < _worldSize; x++)
        {
            for (int y = 0; y < _worldSize; y++)
            {
                CellController cell = _cellsArr[x, y];
                if (cell == null || cell.Empty || cell.ZoneID >= 0)
                {
                    continue;
                }

                zone        = new ZoneController();
                zone.ZoneID = idCounter;

                SetZone(idCounter, cell, zone, 0);

                zone.SetColor();

                _zones.Add(zone);

                idCounter++;

                yield return(new WaitForEndOfFrame());
            }
        }
    }