예제 #1
0
        MultiTile GetRandomMultiTile(Size size, MapVisualsSpecification spec)
        {
            int       terminator = 0;
            Tile      tile       = Global.instance.currentMap.board[Random.Range(spec.minDistanceToShortSide, Global.instance.currentMap.mapWidth - spec.minDistanceToShortSide), Random.Range(spec.minDistanceToLongSide, Global.instance.currentMap.mapHeight - spec.minDistanceToLongSide)];
            MultiTile position   = MultiTile.Create(tile, size);

            while (IsMultiTileLegal(position, spec) == false)
            {
                terminator++;
                tile     = Global.instance.currentMap.board[Random.Range(spec.minDistanceToShortSide, Global.instance.currentMap.mapWidth - spec.minDistanceToShortSide), Random.Range(spec.minDistanceToLongSide, Global.instance.currentMap.mapHeight - spec.minDistanceToLongSide)];
                position = MultiTile.Create(tile, size);
                if (terminator == 100)
                {
                    return(null);
                }
            }

            return(position);
        }
예제 #2
0
 bool IsMultiTileLegal(MultiTile position, MapVisualsSpecification spec)
 {
     return(position.IsEmpty() && (spec.needsExtraSpace == false || HasExtraSpace(position)));
 }