1.向判定效果IInteraction中增强, 支持Hold类型判定, 这将是除Tap以外唯二的判定模式\n2.GameController现在能够打开带有Helper的项目根目录
This commit is contained in:
@@ -302,6 +302,11 @@ namespace Demo.Editor
|
||||
}
|
||||
}
|
||||
|
||||
//[Header("PersistentDataPath")]
|
||||
public string PersistentDataPath => PlatformIndicator.PersistentDataPath;
|
||||
public string PersistentProjectPath => Path.Combine(PersistentDataPath, "Projects/");
|
||||
public string PersistentHelperPath => Path.Combine(PersistentDataPath, "Helper/");
|
||||
|
||||
private void OpenGameScene(string ProjectName, bool IsCreateNewProject)
|
||||
{
|
||||
if (GameContent.instance == null)
|
||||
@@ -309,7 +314,7 @@ namespace Demo.Editor
|
||||
new GameObject("GameContent").AddComponent<GameContent>();
|
||||
}
|
||||
var content = GameContent.instance;
|
||||
content.RootSourceDir = Path.Combine(PlatformIndicator.PersistentDataPath, ProjectName) + "/";
|
||||
content.RootSourceDir = Path.Combine(PersistentProjectPath, ProjectName) + "/";
|
||||
content.IsCreateNewProject = IsCreateNewProject;
|
||||
content.ScriptableObjectTypen = GetDefaultScriptableObjectTypen();
|
||||
content.IsAutoPlay = true;
|
||||
@@ -371,7 +376,7 @@ namespace Demo.Editor
|
||||
private void Start()
|
||||
{
|
||||
// Helper Files
|
||||
ToolFile helperHeaderDir = new ToolFile(PlatformIndicator.StreamingAssetsPath) | "Helper/";
|
||||
ToolFile helperHeaderDir = new ToolFile(PersistentHelperPath);
|
||||
if (helperHeaderDir.Exists() == false)
|
||||
{
|
||||
ProjectCreateHelper.CreateHelperFiles(helperHeaderDir, CurrentProjectDefaultFileStyle);
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Cinemachine;
|
||||
using Convention;
|
||||
using Convention.WindowsUI.Variant;
|
||||
using Unity.Profiling;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -27,7 +26,17 @@ namespace Demo.Game
|
||||
public Action<float> SetSongCurrentTime { get; private set; } = _ => { };
|
||||
public bool IsMain { get; set; } = false;
|
||||
public bool IsAutoPlay { get; private set; } = false;
|
||||
public string ScriptEditor { get; private set; } = "{0}";
|
||||
/// <summary>
|
||||
/// 使用形如<b>"E:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" {0}</b>来打开文件,
|
||||
/// {0}是必要的, 指代的是将要打开的文件
|
||||
/// </summary>
|
||||
public string WhichOpenScript { get; private set; } = "{0}";
|
||||
/// <summary>
|
||||
/// 使用形如<b>"E:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" {0}</b>来打开项目存贮目录,
|
||||
/// {0}是必要的, 指代的是Helper的父目录, 同时也应该是项目的父目录, 同时配备有全局项目配置, 用于提供注释内容,
|
||||
/// 值为null时不会在启动时打开
|
||||
/// </summary>
|
||||
public string WhichOpenProject { get; private set; } = null;
|
||||
public ProjectDefaultFileStyle CurrentProjectDefaultFileStyle = default;
|
||||
|
||||
public float SongOffset;
|
||||
@@ -117,55 +126,70 @@ namespace Demo.Game
|
||||
SetupSongDuration = GameContent.instance.SetupSongDuration;
|
||||
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
|
||||
SongOffset = GameContent.instance.SongOffset;
|
||||
}
|
||||
{
|
||||
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
|
||||
IsAutoPlay = GameContent.instance.IsAutoPlay;
|
||||
ScriptEditor = (string)MainConfig.FindItem(nameof(ScriptEditor), ScriptEditor);
|
||||
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
|
||||
MainConfig.SaveProperties();
|
||||
|
||||
// Load Root Object
|
||||
{
|
||||
while (MainConfig.Contains("root") == false)
|
||||
// Open Project
|
||||
WhichOpenProject = (string)MainConfig.FindItem(nameof(WhichOpenProject), WhichOpenProject);
|
||||
if (string.IsNullOrEmpty(WhichOpenProject) == false)
|
||||
{
|
||||
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
|
||||
string path = string.Format($"{WhichOpenProject}", $"\"{Editor.EditorController.instance.PersistentDataPath}\"") ;
|
||||
try
|
||||
{
|
||||
ProjectDefaultFileStyle.PY => ".py",
|
||||
_ => ".h"
|
||||
};
|
||||
if (content.IsCreateNewProject)
|
||||
{
|
||||
MainConfig["root"] = defaultRootPath;
|
||||
if (MainConfig.CreateFile(defaultRootPath))
|
||||
{
|
||||
MainConfig.SaveProperties();
|
||||
break;
|
||||
}
|
||||
System.Diagnostics.Process.Start(path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Cannt open {path}", this);
|
||||
Debug.LogException(ex, this);
|
||||
}
|
||||
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
|
||||
StartCoroutine(GameExit());
|
||||
yield break;
|
||||
}
|
||||
var rootFileName = (string)MainConfig.FindItem("root");
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
|
||||
try
|
||||
{
|
||||
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
|
||||
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
|
||||
IsAutoPlay = GameContent.instance.IsAutoPlay;
|
||||
WhichOpenScript = (string)MainConfig.FindItem(nameof(WhichOpenScript), WhichOpenScript);
|
||||
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
|
||||
}
|
||||
finally
|
||||
|
||||
yield return null;
|
||||
|
||||
MainConfig.SaveProperties();
|
||||
|
||||
// Load Root Object
|
||||
{
|
||||
MainObject = rootGameObject;
|
||||
while (MainConfig.Contains("root") == false)
|
||||
{
|
||||
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
|
||||
{
|
||||
ProjectDefaultFileStyle.PY => ".py",
|
||||
_ => ".h"
|
||||
};
|
||||
if (content.IsCreateNewProject)
|
||||
{
|
||||
MainConfig["root"] = defaultRootPath;
|
||||
if (MainConfig.CreateFile(defaultRootPath))
|
||||
{
|
||||
MainConfig.SaveProperties();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
|
||||
StartCoroutine(GameExit());
|
||||
yield break;
|
||||
}
|
||||
var rootFileName = (string)MainConfig.FindItem("root");
|
||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||
rootObject.MustExistsPath();
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
|
||||
try
|
||||
{
|
||||
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
|
||||
}
|
||||
finally
|
||||
{
|
||||
MainObject = rootGameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace Demo
|
||||
public static void OpenScriptFile(ScriptableObject so)
|
||||
{
|
||||
string path = so.ScriptPath;
|
||||
var ScriptEditor = so.GetRoot().RootGameController.ScriptEditor;
|
||||
var ScriptEditor = so.GetRoot().RootGameController.WhichOpenScript;
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start(string.Format($"{ScriptEditor}", $"\"{path}\""));
|
||||
|
||||
@@ -138,7 +138,16 @@ namespace Demo.Game
|
||||
return DurationStats.After;
|
||||
}
|
||||
|
||||
public abstract bool JudgementBehaviour(float timePoint);
|
||||
public enum JudgementLevel
|
||||
{
|
||||
None = -2,//No Judge
|
||||
Default = -1,
|
||||
BestLevel = 0,//Level0
|
||||
ScoreLevel = 1,//Level1
|
||||
Bad = 128,
|
||||
}
|
||||
|
||||
public abstract JudgementLevel JudgementBehaviour(float timePoint);
|
||||
|
||||
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Convention;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Game
|
||||
@@ -9,21 +10,62 @@ namespace Demo.Game
|
||||
return new GameObject().AddComponent<FullScreenInteraction>();
|
||||
}
|
||||
|
||||
public override bool JudgementBehaviour(float timePoint)
|
||||
[Content] public bool IsNeedTap = true;
|
||||
[Content, SerializeField] private bool IsJudgement = false;
|
||||
[Content, SerializeField] private bool IsReleaseJudgementEffect = false;
|
||||
|
||||
/// <summary>
|
||||
/// 设置为Hold模式, 即不需要点按即可判定的模式
|
||||
/// </summary>
|
||||
[ScriptableCall(@"设置为Hold模式, 即不需要点按即可判定的模式")]
|
||||
public void EnableHoldMode()
|
||||
{
|
||||
if (GetRoot().RootGameController.IsAutoPlay)
|
||||
return timePoint > GetBestJudgementTimePoint();
|
||||
var inputs = GetRoot().InputCatch;
|
||||
for (int i = 0, e = inputs.Count; i < e; i++)
|
||||
IsNeedTap = false;
|
||||
}
|
||||
|
||||
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
base.UpdateTicks(currentTime, deltaTime, tickType);
|
||||
if (tickType == TickType.Pause || tickType == TickType.Reset)
|
||||
{
|
||||
var current = inputs[i];
|
||||
if (IsInInteractiveDuration(current.TimePoint))
|
||||
IsJudgement = false;
|
||||
IsReleaseJudgementEffect = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override JudgementLevel JudgementBehaviour(float timePoint)
|
||||
{
|
||||
var stats = timePoint > GetBestJudgementTimePoint();
|
||||
if (IsJudgement)
|
||||
{
|
||||
if (IsNeedTap)
|
||||
return JudgementLevel.None;
|
||||
else if (stats && IsReleaseJudgementEffect == false)
|
||||
{
|
||||
inputs.RemoveAt(i);
|
||||
return true;
|
||||
IsReleaseJudgementEffect = true;
|
||||
return JudgementLevel.BestLevel;
|
||||
}
|
||||
else
|
||||
return JudgementLevel.None;
|
||||
}
|
||||
if (GetRoot().RootGameController.IsAutoPlay)
|
||||
return stats ? JudgementLevel.BestLevel: JudgementLevel.None;
|
||||
var inputs = GetRoot().InputCatch;
|
||||
var index = inputs.FindIndex(x => IsInInteractiveDuration(x.TimePoint));
|
||||
if (index != -1)
|
||||
{
|
||||
if (IsNeedTap)
|
||||
{
|
||||
inputs.RemoveAt(index);
|
||||
return JudgementLevel.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsJudgement = true;
|
||||
return JudgementLevel.None;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return JudgementLevel.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user