基础内容-4

Tap,Stay,Flick基础构造
This commit is contained in:
SoulliesOfficial
2025-01-28 11:58:39 -05:00
parent 70d06c6334
commit 552651efbc
14 changed files with 269 additions and 78 deletions

View File

@@ -13,7 +13,7 @@ namespace Ichni.RhythmGame
{
public float bloomTime;
public float bloomPeak;
[Button("Test Bloom Shake")]
public override void Adjust()
{

View File

@@ -1,18 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
public class Flick : MonoBehaviour
namespace Ichni.RhythmGame
{
// Start is called before the first frame update
void Start()
public class Flick : NoteBase
{
}
public List<Vector2> availableFlickDirections;
public static Flick GenerateElement(string elementName, float exactJudgeTime, BaseElement attach, List<Vector2> directions)
{
Flick flick = LeanPool.Spawn(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Flick>();
flick.NewInitialize(elementName, exactJudgeTime);
flick.availableFlickDirections = directions;
flick.SetParent(attach);
if (attach.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
flick.track = track;
flick.trackPositioner.spline = track.trackPathSubmodule.path;
flick.isOnTrack = true;
flick.UpdateNoteInTrack();
}
else
{
throw new System.Exception("如果Note要生成在Track上Track必须有TrackTimeSubmodule组件。");
}
}
else
{
}
// Update is called once per frame
void Update()
{
return flick;
}
public void NewInitialize(string elementName, float exactJudgeTime)
{
base.NewInitialize(elementName);
this.exactJudgeTime = exactJudgeTime;
this.track = null;
this.isOnTrack = false;
}
}
}
}

View File

@@ -2,17 +2,11 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FullScreenBalancedJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
namespace Ichni.RhythmGame
{
public class FullScreenBalancedJudgeSubmodule : NoteJudgeUnit
{
}
}
}

View File

@@ -2,17 +2,11 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FullScreenNearTimeJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
namespace Ichni.RhythmGame
{
public class FullScreenNearTimeJudgeSubmodule : NoteJudgeUnit
{
}
}
}

View File

@@ -1,18 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchAreaJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TouchAreaJudgeUnit : NoteJudgeUnit
{
}
}

View File

@@ -2,17 +2,11 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerConnectJudgeSubmodule : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
namespace Ichni.RhythmGame
{
public class TriggerConnectJudgeSubmodule : NoteJudgeUnit
{
}
}
}

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public class NoteBase : BaseElement
public abstract class NoteBase : BaseElement
{
[Title("Basic Info")]
public float exactJudgeTime;
@@ -40,5 +40,96 @@ namespace Ichni.RhythmGame
[Title("In-Game Info")]
public Vector2 noteScreenPosition;
public bool isJudged;
/// <summary>
/// 在MovableTrack上更新Note的位置注意HoldNote需要重写这个方法
/// </summary>
public virtual void UpdateNoteInMovableTrack()
{
trackPositioner.SetPercent((track.trackTimeSubmodule as TrackTimeSubmoduleMovable).GetTrackPercent(exactJudgeTime));
}
/// <summary>
/// 在StaticTrack上更新Note的位置注意HoldNote需要重写这个方法
/// </summary>
public virtual void UpdateNoteInStaticTrack()
{
float songTime = EditorManager.instance.songModule.songTime;
TrackTimeSubmoduleStatic trackTimeSubmoduleStatic = track.trackTimeSubmodule as TrackTimeSubmoduleStatic;
float startMove = exactJudgeTime - trackTimeSubmoduleStatic.trackTotalTime;
float percent = AnimationCurveEvaluator.Evaluate(trackTimeSubmoduleStatic.animationCurveType, (songTime - startMove) / trackTimeSubmoduleStatic.trackTotalTime);
percent = Mathf.Max(percent, 0);
percent = Mathf.Min(percent, 1);
trackPositioner.SetPercent(1 - percent);
}
public override void AfterInitialize()
{
generateEffects.effectList.ForEach(e => e.Recover());
generalJudgeEffects.effectList.ForEach(e => e.Recover());
perfectJudgeEffects.effectList.ForEach(e => e.Recover());
goodJudgeEffects.effectList.ForEach(e => e.Recover());
badJudgeEffects.effectList.ForEach(e => e.Recover());
missJudgeEffects.effectList.ForEach(e => e.Recover());
}
private void Update()
{
if (isOnTrack)
{
if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
{
UpdateNoteInStaticTrack();
}
}
float songTime = EditorManager.instance.songModule.songTime;
if (isJudged && songTime < exactJudgeTime)
{
isJudged = false;
}
if (!isJudged && songTime >= exactJudgeTime)
{
if (!isJudged)
{
AudioSource.PlayClipAtPoint(EditorManager.instance.basePrefabs.tapNoteSound, Camera.main.transform.position, 1f);
isJudged = true;
}
}
foreach (var effect in generateEffects.effectList)
{
effect.UpdateEffect();
}
foreach (var effect in perfectJudgeEffects.effectList)
{
effect.UpdateEffect();
}
}
public void ExecuteStartJudge()
{
}
public void UpdateNoteInTrack()
{
if (isOnTrack && track.trackTimeSubmodule != null)
{
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)
{
UpdateNoteInMovableTrack();
}
else if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
{
UpdateNoteInStaticTrack();
}
}
}
}
}

View File

@@ -1,18 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
public class Stay : MonoBehaviour
namespace Ichni.RhythmGame
{
// Start is called before the first frame update
void Start()
public class Stay : NoteBase
{
}
public static Stay GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
{
Stay stay = LeanPool.Spawn(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Stay>();
stay.NewInitialize(elementName, exactJudgeTime);
stay.SetParent(attach);
if (attach.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
stay.track = track;
stay.trackPositioner.spline = track.trackPathSubmodule.path;
stay.isOnTrack = true;
stay.UpdateNoteInTrack();
}
else
{
throw new System.Exception("如果Note要生成在Track上Track必须有TrackTimeSubmodule组件。");
}
}
else
{
}
// Update is called once per frame
void Update()
{
return stay;
}
public void NewInitialize(string elementName, float exactJudgeTime)
{
base.NewInitialize(elementName);
this.exactJudgeTime = exactJudgeTime;
this.track = null;
this.isOnTrack = false;
}
}
}
}

View File

@@ -1,18 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using Lean.Pool;
using UnityEngine;
public class Tap : MonoBehaviour
namespace Ichni.RhythmGame
{
// Start is called before the first frame update
void Start()
public class Tap : NoteBase
{
}
public static Tap GenerateElement(string elementName, float exactJudgeTime, BaseElement attach)
{
Tap tap = LeanPool.Spawn(EditorManager.instance.basePrefabs.tapNote, attach.transform).GetComponent<Tap>();
tap.NewInitialize(elementName, exactJudgeTime);
tap.SetParent(attach);
if (attach.TryGetComponent(out Track track))
{
if (track.trackTimeSubmodule != null)
{
tap.track = track;
tap.trackPositioner.spline = track.trackPathSubmodule.path;
tap.isOnTrack = true;
tap.UpdateNoteInTrack();
}
else
{
throw new System.Exception("如果Note要生成在Track上Track必须有TrackTimeSubmodule组件。");
}
}
else
{
}
// Update is called once per frame
void Update()
{
return tap;
}
public void NewInitialize(string elementName, float exactJudgeTime)
{
base.NewInitialize(elementName);
this.exactJudgeTime = exactJudgeTime;
this.track = null;
this.isOnTrack = false;
}
}
}
}

View File

@@ -45,7 +45,7 @@ namespace Ichni.RhythmGame
}
}
private float GetTrackPercent(float songTimeInTime)
public float GetTrackPercent(float songTimeInTime)
{
float per = AnimationCurveEvaluator.Evaluate(animationCurveType, (songTimeInTime - trackStartTime) / trackTotalTime);
return Mathf.Clamp01(per);