Exemple #1
0
        public AssetPtr AddToAssets(SerializedAssets.Transaction assets, Apk.Transaction apk, string levelID)
        {
            // var watch = System.Diagnostics.Stopwatch.StartNew();
            AudioClipAssetData audioClip    = CreateAudioAsset(apk, levelID);
            AssetPtr           audioClipPtr = assets.AppendAsset(audioClip);

            string             coverPath = Path.Combine(levelFolderPath, _coverImageFilename);
            Texture2DAssetData cover     = Texture2DAssetData.CoverFromImageFile(coverPath, levelID);
            AssetPtr           coverPtr  = assets.AppendAsset(cover);

            AssetPtr environment = new AssetPtr(20, 1); // default environment

            switch (_environmentName)
            {
            case "NiceEnvironment":
                environment = new AssetPtr(38, 3);
                break;

            case "TriangleEnvironment":
                environment = new AssetPtr(0, 252);
                break;

            case "BigMirrorEnvironment":
                environment = new AssetPtr(0, 249);
                break;
            }

            LevelBehaviorData level = new LevelBehaviorData()
            {
                levelID          = levelID,
                songName         = _songName,
                songSubName      = _songSubName,
                songAuthorName   = _songAuthorName,
                levelAuthorName  = _levelAuthorName,
                beatsPerMinute   = _beatsPerMinute,
                songTimeOffset   = _songTimeOffset,
                shuffle          = _shuffle,
                shufflePeriod    = _shufflePeriod,
                previewStartTime = _previewStartTime,
                previewDuration  = _previewDuration,

                audioClip   = audioClipPtr,
                coverImage  = coverPtr,
                environment = environment,

                difficultyBeatmapSets = _difficultyBeatmapSets.Select(s => s.ToAssets(assets, levelFolderPath, levelID)).Where(s => s != null).ToList(),
            };

            MonoBehaviorAssetData monob = new MonoBehaviorAssetData()
            {
                script = new AssetPtr(1, LevelBehaviorData.PathID),
                name   = level.levelID + "Level",
                data   = level,
            };

            // watch.Stop();
            // Console.WriteLine("song: " + watch.ElapsedMilliseconds);

            return(assets.AppendAsset(monob));
        }
Exemple #2
0
        public BeatmapDifficulty ToAssets(
            SerializedAssets.Transaction assets,
            string levelFolderPath,
            string levelID,
            Characteristic characteristic
            )
        {
            string beatmapFile          = Path.Combine(levelFolderPath, _beatmapFilename);
            var    beatmapData          = BeatmapDataBehaviorData.FromJsonFile(beatmapFile, assets.apkVersion);
            string characteristicPart   = ((characteristic == Characteristic.Standard) ? "" : characteristic.ToString());
            string assetName            = levelID + characteristicPart + _difficulty.ToString() + "BeatmapData";
            MonoBehaviorAssetData monob = new MonoBehaviorAssetData()
            {
                script = assets.scriptIDToScriptPtr[BeatmapDataBehaviorData.ScriptID],
                name   = assetName,
                data   = beatmapData,
            };
            AssetPtr assetPtr = assets.AppendAsset(monob);

            return(new BeatmapDifficulty()
            {
                difficulty = (int)_difficulty,
                difficultyRank = _difficultyRank,
                noteJumpMovementSpeed = _noteJumpMovementSpeed,
                noteJumpStartBeatOffset = _noteJumpStartBeatOffset,
                beatmapData = assetPtr,
            });
        }
Exemple #3
0
        public BeatmapDifficulty ToAssets(
            SerializedAssets.Transaction assets,
            string levelFolderPath,
            string levelID,
            Characteristic characteristic
            )
        {
            string          beatmapFile = Path.Combine(levelFolderPath, _beatmapFilename);
            string          jsonData    = File.ReadAllText(beatmapFile);
            BeatmapSaveData saveData    = JsonConvert.DeserializeObject <BeatmapSaveData>(jsonData);

            byte[] projectedData = saveData.SerializeToBinary();

            BeatmapDataBehaviorData beatmapData = new BeatmapDataBehaviorData()
            {
                jsonData      = "",
                signature     = new byte[128], // all zeros
                projectedData = projectedData,
            };
            string characteristicPart   = ((characteristic == Characteristic.Standard) ? "" : characteristic.ToString());
            string assetName            = levelID + characteristicPart + _difficulty.ToString() + "BeatmapData";
            MonoBehaviorAssetData monob = new MonoBehaviorAssetData()
            {
                script = new AssetPtr(1, BeatmapDataBehaviorData.PathID),
                name   = assetName,
                data   = beatmapData,
            };
            AssetPtr assetPtr = assets.AppendAsset(monob);

            return(new BeatmapDifficulty()
            {
                difficulty = (int)_difficulty,
                difficultyRank = _difficultyRank,
                noteJumpMovementSpeed = _noteJumpMovementSpeed,
                noteJumpStartBeatOffset = _noteJumpStartBeatOffset,
                beatmapData = assetPtr,
            });
        }