示例#1
0
    public LevelMeta GenerateLevelMeta()
    {
        var meta = new LevelMeta();

        meta.schema_version     = 2;
        meta.version            = Version;
        meta.id                 = Uid;
        meta.title              = Title;
        meta.title_localized    = Metadata.LocalizedTitle;
        meta.artist             = Metadata.Artist?.Name;
        meta.artist_localized   = Metadata.Artist?.LocalizedName;
        meta.artist_source      = Metadata.Artist?.Url;
        meta.illustrator        = Metadata.Illustrator?.Name;
        meta.illustrator_source = Metadata.Illustrator?.Url;
        meta.charter            = Metadata.Charter?.Name;
        meta.charts             = Charts.Select(onlineChart => new LevelMeta.ChartSection
        {
            type = onlineChart.Type, name = onlineChart.Name, difficulty = onlineChart.Difficulty
        }).ToList();
        meta.background = new LevelMeta.BackgroundSection {
            path = Bundle?.BackgroundUrl ?? Cover.CoverUrl
        };
        meta.music = new LevelMeta.MusicSection {
            path = Bundle?.MusicUrl ?? MusicUrl
        };
        meta.music_preview = new LevelMeta.MusicSection {
            path = Bundle?.MusicPreviewUrl ?? MusicPreviewUrl
        };
        meta.SortCharts();
        return(meta);
    }
示例#2
0
    public void LoadLevel(int level)
    {
        Debug.Log("Load level: " + level);

        levelMetaVar = FindObjectOfType <LevelMeta>();
        if (levelMetaVar != null)
        {
            Destroy(levelMetaVar.gameObject);
        }

        if (level >= levels.Length)
        {
            gameScore.gameResult = true;
            scenesLoader.LoadNextLevel();
        }



        Instantiate(levels[level], Vector3.zero, Quaternion.identity);

        levelMetaVar = FindObjectOfType <LevelMeta>();
        blocksLeft   = levelMetaVar.levelItems;

        ballVar = FindObjectOfType <Ball>();
        ballVar.SetBall(startPlatformPosX, ballStartPosY, false, false, true, true); //устанавливаем шарик в начальное положение и делаем его незапущенным


        platformVar = FindObjectOfType <Platform>();
        platformVar.SetPlatform(startPlatformPosX, startPlatfromPosY); //устанавливаем платформу в началаьное положение
    }
示例#3
0
文件: Level.cs 项目: zipfried/Cytoid
 public void CopyFrom(Level other)
 {
     Type        = other.Type;
     IsLocal     = other.IsLocal;
     OnlineLevel = other.OnlineLevel;
     Meta        = other.Meta;
     Record      = other.Record;
     Path        = other.Path;
 }
示例#4
0
文件: Level.cs 项目: zipfried/Cytoid
 public static Level FromRemote(LevelType type, LevelMeta meta, LiteDatabase db = null)
 {
     return(new Level {
         Type = type,
         IsLocal = false,
         Meta = meta,
         Record = (db ?? Context.Database).GetLevelRecord(meta.id) ?? new LevelRecord {
             LevelId = meta.id
         }
     });
 }
示例#5
0
文件: Level.cs 项目: zipfried/Cytoid
 public static Level FromLocal(string path, LevelType type, LevelMeta meta, LiteDatabase database = null)
 {
     return(new Level {
         Type = type,
         IsLocal = true,
         Path = path,
         Meta = meta,
         Record = (database ?? Context.Database).GetLevelRecord(meta.id) ?? new LevelRecord {
             LevelId = meta.id
         }
     });
 }
示例#6
0
    private bool UpdateLevelMeta(Level level, LevelMeta meta)
    {
        var local  = level.Meta;
        var remote = meta;

        var updated = false;

        if (local.version > remote.version)
        {
            Debug.Log($"Local version {local.version} > {remote.version}");
            return(false);
        }

        if (local.schema_version != remote.schema_version)
        {
            local.schema_version = remote.schema_version;
            updated = true;
        }

        if (remote.title != null && local.title != remote.title)
        {
            local.title = remote.title;
            updated     = true;
        }

        if (remote.title_localized != null && local.title_localized != remote.title_localized)
        {
            local.title_localized = remote.title_localized;
            updated = true;
        }

        if (remote.artist != null && local.artist != remote.artist)
        {
            local.artist = remote.artist;
            updated      = true;
        }

        if (remote.artist_localized != null && local.artist_localized != remote.artist_localized)
        {
            local.artist_localized = remote.artist_localized;
            updated = true;
        }

        if (remote.artist_source != null && local.artist_source != remote.artist_source)
        {
            local.artist_source = remote.artist_source;
            updated             = true;
        }

        if (remote.illustrator != null && local.illustrator != remote.illustrator)
        {
            local.illustrator = remote.illustrator;
            updated           = true;
        }

        if (remote.illustrator_source != null && local.illustrator_source != remote.illustrator_source)
        {
            local.illustrator_source = remote.illustrator_source;
            updated = true;
        }

        if (remote.charter != null && local.charter != remote.charter)
        {
            local.charter = remote.charter;
            updated       = true;
        }

        foreach (var type in new List <string> {
            LevelMeta.Easy, LevelMeta.Hard, LevelMeta.Extreme
        })
        {
            if (remote.GetChartSection(type) != null && local.GetChartSection(type) != null &&
                local.GetChartSection(type).difficulty != remote.GetChartSection(type).difficulty)
            {
                local.GetChartSection(type).difficulty = remote.GetChartSection(type).difficulty;
                updated = true;
            }
        }

        if (updated)
        {
            File.WriteAllText($"{level.Path.Replace("file://", "")}/level.json", JsonConvert.SerializeObject(local));
        }

        return(updated);
    }
示例#7
0
 public void SetTargetLevel(LevelMeta _level, int _seasonId)
 {
     targetLevel    = _level;
     seasonId       = _seasonId;
     levelName.text = targetLevel.title;
 }
示例#8
0
        public LevelMap(MiMapManager miMapManager, MiMapLevelConfig config)
        {
            MiMapManager = miMapManager;
            Config       = config;
            Meta         = new LevelMeta()
            {
                Id         = config.LevelId,
                Name       = string.IsNullOrEmpty(config.Label) ? config.LevelId : config.Label,
                MinZoom    = config.MinZoom,
                MaxZoom    = config.MaxZoom,
                TileSize   = new Size(config.TileSize, config.TileSize),
                Size       = new Size(),
                Bounds     = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0)),
                LastUpdate = DateTime.MinValue
            };

            BlockBounds = new BlockBounds(new BlockPosition(0, 0), new BlockPosition(0, 0));

            TilesDirectory = Path.Combine(MiMapManager.Config.TilesDirectory, config.LevelId);
            _metaPath      = Path.Combine(TilesDirectory, "meta.json");

#if DEBUG
            if (Directory.Exists(TilesDirectory))
            {
                try
                {
                    Directory.Delete(TilesDirectory, true);
                }
                catch
                {
                }
            }
#endif

            Directory.CreateDirectory(TilesDirectory);

            _layers = new MapLayer[config.Layers.Length + 1];
            var baseLayer = new MapLayer(this, new MiMapLevelLayerConfig()
            {
                LayerId   = "base",
                BlendMode = BlendMode.Normal,
                Default   = config.Enabled,
                Enabled   = config.Enabled,
                Label     = config.Label,
                Renderer  = config.Renderer
            });

            baseLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e);
            var i = 0;
            _layers[i] = baseLayer;
            i++;

            foreach (var layer in config.Layers)
            {
                //Log.InfoFormat("Loading Overlay layer {0} {1}/{2}", layer, i, _layers.Length);
                var overlayerLayer = new MapLayer(this, layer);
                overlayerLayer.OnTileUpdated += (s, e) => OnTileUpdated?.Invoke(s, e);
                _layers[i] = overlayerLayer;
                i++;
            }

            _timer = new Timer(SaveLayers);
        }
 public void Save(DirectoryInfo gamedataFolder, LevelMeta levelMeta)
 {
     throw new System.NotImplementedException();
 }
示例#10
0
 // Start is called before the first frame update
 void Awake()
 {
     levelMeta = FindObjectOfType <LevelMeta>();
     levelMeta.AddBlockCount();
 }