166 lines
5.6 KiB
C#
166 lines
5.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using Dreamteck.Splines;
|
|||
|
|
using Ichni.RhythmGame.Beatmap;
|
|||
|
|
using Lean.Pool;
|
|||
|
|
using Unity.VisualScripting;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Serialization;
|
|||
|
|
|
|||
|
|
namespace Ichni.RhythmGame
|
|||
|
|
{
|
|||
|
|
public partial class Stay : NoteBase
|
|||
|
|
{
|
|||
|
|
public NoteJudgeType preJudgeType;
|
|||
|
|
|
|||
|
|
public static Stay GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
|||
|
|
GameElement parentElement, float exactJudgeTime)
|
|||
|
|
{
|
|||
|
|
Stay stay = Instantiate(GameManager.instance.basePrefabs.stayNote, parentElement.transform).GetComponent<Stay>();
|
|||
|
|
|
|||
|
|
stay.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
|||
|
|
stay.exactJudgeTime = exactJudgeTime;
|
|||
|
|
stay.preJudgeType = NoteJudgeType.NotJudged;
|
|||
|
|
stay.judgeIntervals = new NoteJudgeIntervals(
|
|||
|
|
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, -0.15f),
|
|||
|
|
new TimeInterval(-0.15f, -0.15f), new TimeInterval(-0.15f, 0.1f),
|
|||
|
|
new TimeInterval(0.1f, 0.15f), new TimeInterval(0.15f, 0.15f), 0.15f);
|
|||
|
|
|
|||
|
|
if (parentElement.TryGetComponent(out Track track))
|
|||
|
|
{
|
|||
|
|
if (track.trackTimeSubmodule != null)
|
|||
|
|
{
|
|||
|
|
stay.track = track;
|
|||
|
|
stay.trackPositioner = stay.AddComponent<SplinePositioner>();
|
|||
|
|
stay.trackPositioner.spline = track.trackPathSubmodule.path;
|
|||
|
|
stay.isOnTrack = true;
|
|||
|
|
stay.UpdateNoteInTrack();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
throw new Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
stay.track = null;
|
|||
|
|
stay.isOnTrack = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return stay;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
protected override void Update()
|
|||
|
|
{
|
|||
|
|
float songTime = GameManager.instance.songTime;
|
|||
|
|
|
|||
|
|
if (!isFirstJudged &&
|
|||
|
|
songTime >= exactJudgeTime + judgeIntervals.beforeMiss.intervalStart &&
|
|||
|
|
!GameManager.instance.inputManager.checkingStayList.Contains(this))
|
|||
|
|
{
|
|||
|
|
GameManager.instance.inputManager.checkingStayList.Add(this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
DecideJudge(songTime);
|
|||
|
|
|
|||
|
|
base.Update();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override NoteJudgeType GetStartJudgeType(float timeDifference)
|
|||
|
|
{
|
|||
|
|
return judgeIntervals.GetNoteJudgeType(timeDifference);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void ExecuteStartJudge()
|
|||
|
|
{
|
|||
|
|
float triggerTime = GameManager.instance.songTime;
|
|||
|
|
float timeDifference = triggerTime - exactJudgeTime;
|
|||
|
|
|
|||
|
|
NoteJudgeType startJudgeType = GetStartJudgeType(timeDifference);
|
|||
|
|
preJudgeType = startJudgeType;
|
|||
|
|
|
|||
|
|
isFirstJudged = true;
|
|||
|
|
|
|||
|
|
if (GameManager.instance.inputManager.checkingStayList.Contains(this))
|
|||
|
|
{
|
|||
|
|
GameManager.instance.inputManager.checkingStayList.Remove(this);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void DecideJudge(float triggerTime)
|
|||
|
|
{
|
|||
|
|
if (isFirstJudged && preJudgeType != NoteJudgeType.NotJudged &&
|
|||
|
|
GameManager.instance.songTime >= exactJudgeTime)
|
|||
|
|
{
|
|||
|
|
if (preJudgeType == NoteJudgeType.Perfect)
|
|||
|
|
{
|
|||
|
|
Perfect(triggerTime);
|
|||
|
|
}
|
|||
|
|
else if (preJudgeType == NoteJudgeType.Good)
|
|||
|
|
{
|
|||
|
|
Good(triggerTime);
|
|||
|
|
}
|
|||
|
|
else if (preJudgeType == NoteJudgeType.Bad)
|
|||
|
|
{
|
|||
|
|
Bad(triggerTime);
|
|||
|
|
}
|
|||
|
|
else if (preJudgeType == NoteJudgeType.Miss)
|
|||
|
|
{
|
|||
|
|
Miss(triggerTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public partial class Stay
|
|||
|
|
{
|
|||
|
|
public override void SetDefaultSubmodules()
|
|||
|
|
{
|
|||
|
|
base.SetDefaultSubmodules();
|
|||
|
|
noteAudioSubmodule = new NoteAudioSubmodule(this, "DefaultStay");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void SaveBM()
|
|||
|
|
{
|
|||
|
|
matchedBM = new Stay_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public partial class Stay
|
|||
|
|
{
|
|||
|
|
public bool CheckJudgeAvailability(InputUnitSlide inputUnitSlide)
|
|||
|
|
{
|
|||
|
|
return noteJudgeSubmodule.judgeUnitList.All(judgeUnit => judgeUnit.CheckJudgeAvailability(inputUnitSlide));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
namespace Beatmap
|
|||
|
|
{
|
|||
|
|
public class Stay_BM : NoteBase_BM
|
|||
|
|
{
|
|||
|
|
public Stay_BM()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Stay_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement, float exactJudgeTime)
|
|||
|
|
: base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void ExecuteBM()
|
|||
|
|
{
|
|||
|
|
matchedElement = Stay.GenerateElement(elementName, elementGuid, tags, false,
|
|||
|
|
GetElement(attachedElementGuid), exactJudgeTime);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|||
|
|
{
|
|||
|
|
return Stay.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent, exactJudgeTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|