基础内容-4
Tap,Stay,Flick基础构造
This commit is contained in:
@@ -46,6 +46,32 @@ namespace Ichni.RhythmGame
|
||||
this.nowEffectState = EffectState.Before;
|
||||
}
|
||||
|
||||
public virtual void UpdateEffect()
|
||||
{
|
||||
EffectState state = CheckEffectState();
|
||||
|
||||
if (state == EffectState.Before && nowEffectState != EffectState.Before)
|
||||
{
|
||||
nowEffectState = EffectState.Before;
|
||||
Recover();
|
||||
}
|
||||
else if (state == EffectState.Middle)
|
||||
{
|
||||
nowEffectState = EffectState.Middle;
|
||||
Execute();
|
||||
}
|
||||
else if (state == EffectState.After && nowEffectState != EffectState.After)
|
||||
{
|
||||
nowEffectState = EffectState.After;
|
||||
Adjust();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual EffectState CheckEffectState()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在效果的持续时间内,触发这个方法
|
||||
/// </summary>
|
||||
|
||||
@@ -15,6 +15,19 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
public GameObject pathNode;
|
||||
public Material defaultTrackMaterial;
|
||||
|
||||
[Title("Note 相关")]
|
||||
public GameObject tapNote;
|
||||
public GameObject stayNote;
|
||||
public GameObject holdNote;
|
||||
public GameObject flickNote;
|
||||
public AudioClip tapNoteSound;
|
||||
public AudioClip stayNoteSound;
|
||||
public AudioClip holdNoteStartSound;
|
||||
public AudioClip holdNoteLoopSound;
|
||||
public AudioClip holdNoteEndSound;
|
||||
public AudioClip flickNoteSound;
|
||||
|
||||
|
||||
[Title("Effect相关")]
|
||||
public GameObject bloomShake;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FullScreenBalancedJudgeSubmodule : MonoBehaviour
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public class FullScreenBalancedJudgeSubmodule : NoteJudgeUnit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -2,16 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class FullScreenNearTimeJudgeSubmodule : MonoBehaviour
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public class FullScreenNearTimeJudgeSubmodule : NoteJudgeUnit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TouchAreaJudgeUnit : NoteJudgeUnit
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerConnectJudgeSubmodule : MonoBehaviour
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public class TriggerConnectJudgeSubmodule : NoteJudgeUnit
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user