基础内容11 - SAVE LOAD EXPORT
This commit is contained in:
@@ -21,12 +21,18 @@ namespace Ichni.RhythmGame
|
||||
/// <summary>
|
||||
/// 当物体被删除时执行的方法
|
||||
/// </summary>
|
||||
public void OnDelete();
|
||||
public void OnDelete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除物体,包括所有子物体
|
||||
/// </summary>
|
||||
public void Delete();
|
||||
public void Delete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
// public virtual void SetTimeDuration()
|
||||
@@ -41,70 +47,16 @@ namespace Ichni.RhythmGame
|
||||
// childElementList.Select(x => x.timeDurationSubmodule).ToList());
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 设置物体Transform的监听,顺序为Scale -> EulerAngles -> Position
|
||||
// /// 如果有一些特殊的物体(例如Camera,ElementFolder),需要自定义监听,可以重写这个方法
|
||||
// /// </summary>
|
||||
// public virtual void SetTransformObserver()
|
||||
// {
|
||||
// Observable.EveryUpdate().Subscribe(_ =>
|
||||
// {
|
||||
// if (transformSubmodule == null)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (transformSubmodule.scaleDirtyMark)
|
||||
// {
|
||||
// Vector3 offset = Vector3.zero;
|
||||
// foreach (Vector3 scaleOffset in transformSubmodule.scaleOffset)
|
||||
// {
|
||||
// offset += scaleOffset;
|
||||
// }
|
||||
//
|
||||
// transformSubmodule.currentScale = transformSubmodule.originalScale + offset;
|
||||
// transform.localScale = transformSubmodule.currentScale;
|
||||
// transformSubmodule.scaleDirtyMark = false;
|
||||
// }
|
||||
//
|
||||
// if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
// {
|
||||
// Vector3 offset = Vector3.zero;
|
||||
// foreach (Vector3 eulerOffset in transformSubmodule.eulerAnglesOffset)
|
||||
// {
|
||||
// offset += eulerOffset;
|
||||
// }
|
||||
//
|
||||
// transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
// transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
// transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
// }
|
||||
//
|
||||
// if (transformSubmodule.positionDirtyMark)
|
||||
// {
|
||||
// Vector3 offset = Vector3.zero;
|
||||
// foreach (Vector3 posOffset in transformSubmodule.positionOffset)
|
||||
// {
|
||||
// offset += posOffset;
|
||||
// }
|
||||
//
|
||||
// transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
// transform.localPosition = transformSubmodule.currentPosition;
|
||||
// transformSubmodule.positionDirtyMark = false;
|
||||
// }
|
||||
//
|
||||
// transformSubmodule.scaleOffset.Clear();
|
||||
// transformSubmodule.eulerAnglesOffset.Clear();
|
||||
// transformSubmodule.positionOffset.Clear();
|
||||
// }).AddTo(gameObject);
|
||||
// }
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public abstract class BaseElement_BM
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 从存档类中生成游戏物体
|
||||
/// </summary>
|
||||
public abstract void ExecuteBM();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,14 +106,16 @@ namespace Ichni.RhythmGame
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveColorSubmodule).colorSubmodule = new ColorSubmodule(attachedElement, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
(attachedElement as IHaveColorSubmodule).colorSubmodule = new ColorSubmodule(attachedElement,
|
||||
originalBaseColor, emissionEnabled, originalEmissionColor, originalEmissionIntensity);
|
||||
attachedElement.submoduleList.Add((attachedElement as IHaveColorSubmodule).colorSubmodule);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
(attachedElement as IHaveColorSubmodule).colorSubmodule = new ColorSubmodule(attached, originalBaseColor, emissionEnabled,
|
||||
originalEmissionColor, originalEmissionIntensity);
|
||||
(attached as IHaveColorSubmodule).colorSubmodule = new ColorSubmodule(attached,
|
||||
originalBaseColor, emissionEnabled, originalEmissionColor, originalEmissionIntensity);
|
||||
attached.submoduleList.Add((attached as IHaveColorSubmodule).colorSubmodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,12 +94,14 @@ namespace Ichni.RhythmGame
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attachedElement);
|
||||
(attachedElement as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attachedElement, effectCollection);
|
||||
attachedElement.submoduleList.Add((attachedElement as IHaveEffectSubmodule).effectSubmodule);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
(attached as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attached);
|
||||
(attached as IHaveEffectSubmodule).effectSubmodule = new EffectSubmodule(attached, effectCollection);
|
||||
attached.submoduleList.Add((attached as IHaveEffectSubmodule).effectSubmodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +52,6 @@ namespace Ichni.RhythmGame
|
||||
this.attachedElement = attachedElement;
|
||||
attachedElementGuid = attachedElement.elementGuid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从存档类中生成游戏物体
|
||||
/// </summary>
|
||||
public abstract void ExecuteBM();
|
||||
|
||||
/// <summary>
|
||||
/// 复制物体
|
||||
|
||||
@@ -110,14 +110,14 @@ namespace Ichni.RhythmGame
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveTimeDurationSubmodule).timeDurationSubmodule =
|
||||
new TimeDurationSubmodule(attachedElement, isOverridingDuration, startTime, endTime);
|
||||
(attachedElement as IHaveTimeDurationSubmodule).timeDurationSubmodule = new TimeDurationSubmodule(attachedElement, isOverridingDuration, startTime, endTime);
|
||||
attachedElement.submoduleList.Add((attachedElement as IHaveTimeDurationSubmodule).timeDurationSubmodule);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
(attachedElement as IHaveTimeDurationSubmodule).timeDurationSubmodule =
|
||||
new TimeDurationSubmodule(attached, isOverridingDuration, startTime, endTime);
|
||||
(attached as IHaveTimeDurationSubmodule).timeDurationSubmodule = new TimeDurationSubmodule(attached, isOverridingDuration, startTime, endTime);
|
||||
attached.submoduleList.Add((attached as IHaveTimeDurationSubmodule).timeDurationSubmodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,10 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
TransformSubmodule transformSubmodule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置物体Transform的监听,顺序为Scale -> EulerAngles -> Position
|
||||
/// 如果有一些特殊的物体(例如Camera,ElementFolder),需要自定义监听,可以重写这个方法
|
||||
/// </summary>
|
||||
public void SetTransformObserver()
|
||||
{
|
||||
GameElement attachedGameElement = transformSubmodule.attachedGameElement;
|
||||
@@ -169,14 +173,14 @@ namespace Ichni.RhythmGame
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
||||
(attachedElement as IHaveTransformSubmodule).transformSubmodule =
|
||||
new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
(attachedElement as IHaveTransformSubmodule).transformSubmodule = new TransformSubmodule(attachedElement, originalPosition, originalEulerAngles, originalScale);
|
||||
attachedElement.submoduleList.Add((attachedElement as IHaveTransformSubmodule).transformSubmodule);
|
||||
}
|
||||
|
||||
public override void DuplicateBM(GameElement attached)
|
||||
{
|
||||
(attached as IHaveTransformSubmodule).transformSubmodule =
|
||||
new TransformSubmodule(attached, originalPosition, originalEulerAngles, originalScale);
|
||||
(attached as IHaveTransformSubmodule).transformSubmodule = new TransformSubmodule(attached, originalPosition, originalEulerAngles, originalScale);
|
||||
attached.submoduleList.Add((attached as IHaveTransformSubmodule).transformSubmodule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,73 +14,84 @@ namespace Ichni
|
||||
public static EditorManager instance;
|
||||
|
||||
public SongModule songModule;
|
||||
|
||||
public ProjectManager projectManager;
|
||||
public EditorSettings editorSettings;
|
||||
|
||||
public ProjectInformation projectInformation;
|
||||
public SongInformation songInformation;
|
||||
public BeatmapContainer beatmapContainer;
|
||||
public CommandScripts commandScripts;
|
||||
|
||||
public NoteBase.NoteJudgeType currentJudgeType;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
public List<GameElement> elementList = new List<GameElement>();
|
||||
|
||||
public List<BaseElement_BM> elementList_BM = new List<BaseElement_BM>();
|
||||
public List<Submodule_BM> submoduleList_BM = new List<Submodule_BM>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
projectManager = new ProjectManager();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
//CreateNew();
|
||||
projectManager.loadManager.Load("TestProject");
|
||||
AudioSource.PlayClipAtPoint(songInformation.song, Vector3.zero);
|
||||
|
||||
//currentJudgeType = NoteBase.NoteJudgeType.Perfect;
|
||||
|
||||
var f0 = ElementFolder.GenerateElement("Folder", Guid.NewGuid(), new List<string>(), true, null);
|
||||
var dis0 = Displacement.GenerateElement("Displacement-0",Guid.NewGuid(), new List<string>(),true, f0,
|
||||
new FlexibleFloat(),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,10, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
var t0 = Track.GenerateElement("Track", Guid.NewGuid(), new List<string>(), true, f0);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear,
|
||||
Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.OutQuad);
|
||||
var pp0 = TrackPercentPoint.GenerateElement("TrackPercentPoint-0", Guid.NewGuid(), new List<string>(), true, t0,
|
||||
new FlexibleFloat(new List<AnimatedFloat>() { new(0, 2, 0, 1, AnimationCurveType.OutQuad) }));
|
||||
var tr0 = Trail.GenerateElement("Trail-0", Guid.NewGuid(), new List<string>(), true, pp0, 5);
|
||||
// t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p0.transformSubmodule = new TransformSubmodule(p0, new Vector3(-5, 5, 10), Vector3.forward, Vector3.one);
|
||||
p0.colorSubmodule = new ColorSubmodule(p0, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p1.transformSubmodule = new TransformSubmodule(p1, new Vector3(5, -5, 10), Vector3.forward, Vector3.one);
|
||||
p1.colorSubmodule = new ColorSubmodule(p1, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", Guid.NewGuid(), new List<string>(), true, t0, 1f);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", Guid.NewGuid(), new List<string>(), true, n0,
|
||||
"basic", "BasicNoteTap3D");
|
||||
|
||||
elementList.ForEach(e =>
|
||||
beatmapContainer.gameElementList.ForEach(gameElement =>
|
||||
{
|
||||
e.AfterInitialize();
|
||||
e.Refresh();
|
||||
if (gameElement is IHaveTransformSubmodule transformedElement)
|
||||
{
|
||||
transformedElement.SetTransformObserver();
|
||||
}
|
||||
|
||||
gameElement.AfterInitialize();
|
||||
gameElement.Refresh();
|
||||
});
|
||||
|
||||
elementList.ForEach(e =>
|
||||
{
|
||||
e.SaveBM();
|
||||
e.submoduleList.RemoveAll(s=>s == null);
|
||||
e.submoduleList.ForEach(s => s.SaveBM());
|
||||
});
|
||||
|
||||
//Save
|
||||
elementList.ForEach(x => elementList_BM.Add(x.matchedBM));
|
||||
elementList.ForEach(x => submoduleList_BM.AddRange(x.submoduleList.ConvertAll(s => s.matchedBM as Submodule_BM)));
|
||||
ES3.Save<List<Submodule_BM>>("submoduleList", submoduleList_BM);
|
||||
ES3.Save<List<BaseElement_BM>>("elementList", elementList_BM);
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
songModule.songTime += Time.deltaTime;
|
||||
}
|
||||
|
||||
private void CreateNew()
|
||||
{
|
||||
projectManager.GenerateProject("TestProject");
|
||||
|
||||
var f0 = ElementFolder.GenerateElement("Folder", Guid.NewGuid(), new List<string>(), true, null);
|
||||
var dis0 = Displacement.GenerateElement("Displacement-0",Guid.NewGuid(), new List<string>(),true, f0,
|
||||
new FlexibleFloat(),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,10, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
var t0 = Track.GenerateElement("Track", Guid.NewGuid(), new List<string>(), true, f0);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.submoduleList.Add(t0.trackPathSubmodule);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.OutQuad);
|
||||
t0.submoduleList.Add(t0.trackTimeSubmodule);
|
||||
var pp0 = TrackPercentPoint.GenerateElement("TrackPercentPoint-0", Guid.NewGuid(), new List<string>(), true, t0,
|
||||
new FlexibleFloat(new List<AnimatedFloat>() { new(0, 2, 0, 1, AnimationCurveType.OutQuad) }));
|
||||
var tr0 = Trail.GenerateElement("Trail-0", Guid.NewGuid(), new List<string>(), true, pp0, 5);
|
||||
// t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p0.transformSubmodule = new TransformSubmodule(p0, new Vector3(-5, 5, 10), Vector3.zero, Vector3.one);
|
||||
p0.colorSubmodule = new ColorSubmodule(p0, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", Guid.NewGuid(), new List<string>(), true, t0);
|
||||
p1.transformSubmodule = new TransformSubmodule(p1, new Vector3(5, -5, 10), Vector3.zero, Vector3.one);
|
||||
p1.colorSubmodule = new ColorSubmodule(p1, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", Guid.NewGuid(), new List<string>(), true, t0, 1f);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", Guid.NewGuid(), new List<string>(), true, n0,
|
||||
"basic", "BasicNoteTap3D");
|
||||
|
||||
beatmapContainer.gameElementList.ForEach(e =>
|
||||
{
|
||||
e.AfterInitialize();
|
||||
e.Refresh();
|
||||
});
|
||||
|
||||
projectManager.saveManager.Save();
|
||||
projectManager.exportManager.Export();
|
||||
}
|
||||
}
|
||||
|
||||
public class SongModule
|
||||
|
||||
173
Assets/Scripts/Base/Manager/ProjectManager.cs
Normal file
173
Assets/Scripts/Base/Manager/ProjectManager.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class ProjectManager
|
||||
{
|
||||
public static readonly ES3Settings SaveSettings = new ES3Settings
|
||||
{
|
||||
compressionType = ES3.CompressionType.None,
|
||||
encryptionType = ES3.EncryptionType.None,
|
||||
format = ES3.Format.JSON,
|
||||
};
|
||||
|
||||
public static readonly ES3Settings ExportSettings = new ES3Settings
|
||||
{
|
||||
compressionType = ES3.CompressionType.Gzip,
|
||||
encryptionType = ES3.EncryptionType.AES,
|
||||
encryptionPassword = "Soullies515",
|
||||
format = ES3.Format.JSON,
|
||||
};
|
||||
|
||||
public SaveManager saveManager;
|
||||
public LoadManager loadManager;
|
||||
public ExportManager exportManager;
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
saveManager = new SaveManager();
|
||||
loadManager = new LoadManager();
|
||||
exportManager = new ExportManager();
|
||||
}
|
||||
|
||||
public void GenerateProject(string projectName)
|
||||
{
|
||||
EditorManager.instance.projectInformation = new ProjectInformation(projectName, "Soullies",
|
||||
"2.0", "2025-02-08", "2025-02-08", new List<string>());
|
||||
EditorManager.instance.songInformation = new SongInformation("TestSong", 120, 0);
|
||||
EditorManager.instance.beatmapContainer = new BeatmapContainer();
|
||||
EditorManager.instance.commandScripts = new CommandScripts(new List<string>());
|
||||
|
||||
//Create project folder
|
||||
if (!System.IO.Directory.Exists(EditorManager.instance.projectInformation.projectPath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(EditorManager.instance.projectInformation.projectPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ExportManager
|
||||
{
|
||||
public void Export()
|
||||
{
|
||||
string exportPath = Application.streamingAssetsPath + "/Export/" +
|
||||
EditorManager.instance.projectInformation.projectName;
|
||||
string projectInfoPath = exportPath + "/ProjectInfo.bytes";
|
||||
string songInfoPath = exportPath + "/SongInfo.bytes";
|
||||
string beatmapPath = exportPath + "/BeatMap.bytes";
|
||||
string commandScriptsPath = exportPath + "/CommandScripts.bytes";
|
||||
|
||||
ExportProjectInfo(projectInfoPath);
|
||||
ExportSongInfo(songInfoPath);
|
||||
ExportBeatMap(beatmapPath);
|
||||
ExportCommandScripts(commandScriptsPath);
|
||||
}
|
||||
|
||||
private void ExportProjectInfo(string exportPath)
|
||||
{
|
||||
EditorManager.instance.projectInformation.SaveBM();
|
||||
ES3.Save("ProjectInformation", EditorManager.instance.projectInformation.matchedBM as ProjectInformation_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportSongInfo(string exportPath)
|
||||
{
|
||||
EditorManager.instance.songInformation.SaveBM();
|
||||
ES3.Save("SongInformation", EditorManager.instance.songInformation.matchedBM as SongInformation_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportBeatMap(string exportPath)
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("BeatMap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
|
||||
private void ExportCommandScripts(string exportPath)
|
||||
{
|
||||
EditorManager.instance.commandScripts.SaveBM();
|
||||
ES3.Save("CommandScripts", EditorManager.instance.commandScripts.matchedBM as CommandScripts_BM,
|
||||
exportPath, ProjectManager.ExportSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveManager
|
||||
{
|
||||
public void Save()
|
||||
{
|
||||
SaveProjectInfo();
|
||||
SaveSongInfo();
|
||||
SaveBeatMap();
|
||||
SaveCommandScripts();
|
||||
}
|
||||
|
||||
private void SaveProjectInfo()
|
||||
{
|
||||
EditorManager.instance.projectInformation.SaveBM();
|
||||
ES3.Save("ProjectInformation", EditorManager.instance.projectInformation.matchedBM as ProjectInformation_BM,
|
||||
EditorManager.instance.projectInformation.peojectInfoPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveSongInfo()
|
||||
{
|
||||
EditorManager.instance.songInformation.SaveBM();
|
||||
ES3.Save("SongInformation", EditorManager.instance.songInformation.matchedBM as SongInformation_BM,
|
||||
EditorManager.instance.projectInformation.songInfoPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveBeatMap()
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("BeatMap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
EditorManager.instance.projectInformation.beatmapPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private void SaveCommandScripts()
|
||||
{
|
||||
EditorManager.instance.commandScripts.SaveBM();
|
||||
ES3.Save("CommandScripts", EditorManager.instance.commandScripts.matchedBM as CommandScripts_BM,
|
||||
EditorManager.instance.projectInformation.CommandScriptsPath, ProjectManager.SaveSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public class LoadManager
|
||||
{
|
||||
public void Load(string projectName)
|
||||
{
|
||||
LoadProjectInfo(projectName);
|
||||
LoadSongInfo();
|
||||
LoadBeatMap();
|
||||
LoadCommandScripts();
|
||||
}
|
||||
|
||||
private void LoadProjectInfo(string projectName)
|
||||
{
|
||||
string projectInfoPath = Application.streamingAssetsPath + "/Projects/" + projectName + "/ProjectInfo.json";
|
||||
ES3.Load<ProjectInformation_BM>("ProjectInformation", projectInfoPath, ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadSongInfo()
|
||||
{
|
||||
ES3.Load<SongInformation_BM>("SongInformation", EditorManager.instance.projectInformation.songInfoPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadBeatMap()
|
||||
{
|
||||
ES3.Load<BeatmapContainer_BM>("BeatMap", EditorManager.instance.projectInformation.beatmapPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
|
||||
private void LoadCommandScripts()
|
||||
{
|
||||
ES3.Load<CommandScripts_BM>("CommandScripts", EditorManager.instance.projectInformation.CommandScriptsPath,
|
||||
ProjectManager.SaveSettings).ExecuteBM();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Base/Manager/ProjectManager.cs.meta
Normal file
11
Assets/Scripts/Base/Manager/ProjectManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaac9d0bf222646fc89d03493f9fca69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
public class BeatmapContainer : MonoBehaviour
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class BeatmapContainer : IBaseElement
|
||||
{
|
||||
public List<GameElement> gameElementList;
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
public BeatmapContainer()
|
||||
{
|
||||
gameElementList = new List<GameElement>();
|
||||
}
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
matchedBM = new BeatmapContainer_BM(gameElementList);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
namespace Beatmap
|
||||
{
|
||||
|
||||
public class BeatmapContainer_BM : BaseElement_BM
|
||||
{
|
||||
public List<BaseElement_BM> elementList;
|
||||
|
||||
public BeatmapContainer_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BeatmapContainer_BM(List<GameElement> gameElementList)
|
||||
{
|
||||
elementList = new List<BaseElement_BM>();
|
||||
|
||||
gameElementList.ForEach(e =>
|
||||
{
|
||||
e.SaveBM();
|
||||
e.submoduleList.RemoveAll(s=>s == null);
|
||||
e.submoduleList.ForEach(s => s.SaveBM());
|
||||
});
|
||||
|
||||
foreach (var gameElement in gameElementList)
|
||||
{
|
||||
elementList.Add(gameElement.matchedBM);
|
||||
elementList.AddRange(gameElement.submoduleList.ConvertAll(submodule => submodule.matchedBM));
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
EditorManager.instance.beatmapContainer = new BeatmapContainer();
|
||||
|
||||
elementList.ForEach(element =>
|
||||
{
|
||||
if (element is GameElement_BM gameElement)
|
||||
{
|
||||
GameElement_BM.identifier.Add(gameElement.elementGuid, gameElement);
|
||||
}
|
||||
|
||||
element.ExecuteBM();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CommandScriptContainer : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
47
Assets/Scripts/Base/ProjectFiles/CommandScripts.cs
Normal file
47
Assets/Scripts/Base/ProjectFiles/CommandScripts.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class CommandScripts : IBaseElement
|
||||
{
|
||||
List<string> commandList;
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
public CommandScripts(List<string> commandList)
|
||||
{
|
||||
this.commandList = commandList;
|
||||
}
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
matchedBM = new CommandScripts_BM(commandList);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class CommandScripts_BM : BaseElement_BM
|
||||
{
|
||||
public List<string> commandList;
|
||||
|
||||
public CommandScripts_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CommandScripts_BM(List<string> commandList)
|
||||
{
|
||||
this.commandList = commandList;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
EditorManager.instance.commandScripts = new CommandScripts(commandList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Scripts/Base/ProjectFiles/EditorSettings.cs
Normal file
13
Assets/Scripts/Base/ProjectFiles/EditorSettings.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class EditorSettings
|
||||
{
|
||||
public int autoSaveInterval = 300;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Base/ProjectFiles/EditorSettings.cs.meta
Normal file
11
Assets/Scripts/Base/ProjectFiles/EditorSettings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d388e457813547ca8a9e6282d72ae32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +1,80 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProjectInformation : MonoBehaviour
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class ProjectInformation : IBaseElement
|
||||
{
|
||||
public string projectName;
|
||||
public string creatorName;
|
||||
public string editorVersion;
|
||||
public string createTime;
|
||||
public string lastSaveTime;
|
||||
public List<string> selectedThemeBundleList;
|
||||
|
||||
public string projectPath;
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
public string peojectInfoPath => projectPath + "/ProjectInfo.json";
|
||||
public string songInfoPath => projectPath + "/SongInfo.json";
|
||||
public string songPath => projectPath + EditorManager.instance.songInformation.songName + ".wav";
|
||||
public string beatmapPath => projectPath + "/Beatmap.json";
|
||||
public string CommandScriptsPath => projectPath + "/CommandScripts.json";
|
||||
|
||||
public ProjectInformation(string projectName, string creatorName, string editorVersion,
|
||||
string createTime, string lastSaveTime, List<string> selectedThemeBundleList)
|
||||
{
|
||||
this.projectName = projectName;
|
||||
this.creatorName = creatorName;
|
||||
this.editorVersion = editorVersion;
|
||||
this.createTime = createTime;
|
||||
this.lastSaveTime = lastSaveTime;
|
||||
this.selectedThemeBundleList = selectedThemeBundleList;
|
||||
|
||||
projectPath = Application.streamingAssetsPath + "/Projects/" + projectName;
|
||||
}
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
matchedBM = new ProjectInformation_BM(projectName, creatorName, editorVersion,
|
||||
createTime, lastSaveTime, selectedThemeBundleList);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
namespace Beatmap
|
||||
{
|
||||
|
||||
public class ProjectInformation_BM : BaseElement_BM
|
||||
{
|
||||
public string projectName;
|
||||
public string creatorName;
|
||||
public string editorVersion;
|
||||
public string createTime;
|
||||
public string lastSaveTime;
|
||||
public List<string> selectedThemeBundleList;
|
||||
|
||||
public ProjectInformation_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ProjectInformation_BM(string projectName, string creatorName, string editorVersion,
|
||||
string createTime, string lastSaveTime, List<string> selectedThemeBundleList)
|
||||
{
|
||||
this.projectName = projectName;
|
||||
this.creatorName = creatorName;
|
||||
this.editorVersion = editorVersion;
|
||||
this.createTime = createTime;
|
||||
this.lastSaveTime = lastSaveTime;
|
||||
this.selectedThemeBundleList = selectedThemeBundleList;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
EditorManager.instance.projectInformation = new ProjectInformation(projectName,
|
||||
creatorName, editorVersion, createTime, lastSaveTime, selectedThemeBundleList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,60 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
public class SongInformation : MonoBehaviour
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class SongInformation : IBaseElement
|
||||
{
|
||||
public AudioClip song; //曲目
|
||||
public string songName;
|
||||
public string songLocation; //曲名
|
||||
public float bpm; //每分钟节拍数
|
||||
public float delay; //设定音乐和谱面延迟Delay秒后开始,在延迟中,SongPosition为负数。
|
||||
|
||||
public BaseElement_BM matchedBM { get; set; }
|
||||
|
||||
public SongInformation(string songName, float bpm, float delay)
|
||||
{
|
||||
this.songName = songName;
|
||||
this.bpm = bpm;
|
||||
this.delay = delay;
|
||||
songLocation = EditorManager.instance.projectInformation.projectPath + "/" + songName + ".wav";
|
||||
Debug.Log("Loading song from " + songLocation + " " + ES3.FileExists(songLocation));
|
||||
song = ES3.LoadAudio(songLocation, AudioType.WAV);
|
||||
}
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
matchedBM = new SongInformation_BM(songName, bpm, delay);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
namespace Beatmap
|
||||
{
|
||||
|
||||
public class SongInformation_BM : BaseElement_BM
|
||||
{
|
||||
public string songName;
|
||||
public float bpm;
|
||||
public float delay;
|
||||
|
||||
public SongInformation_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SongInformation_BM(string songName, float bpm, float delay)
|
||||
{
|
||||
this.songName = songName;
|
||||
this.bpm = bpm;
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
EditorManager.instance.songInformation = new SongInformation(songName, bpm, delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user