TransformSubmodule生成进行一次赋值
This commit is contained in:
@@ -75,6 +75,10 @@ namespace Ichni.RhythmGame
|
||||
scaleDirtyMark = true;
|
||||
|
||||
eulerAnglesOffsetLock = false;
|
||||
|
||||
attachedGameElement.transform.localScale = currentScale;
|
||||
attachedGameElement.transform.localEulerAngles = currentEulerAngles;
|
||||
attachedGameElement.transform.localPosition = currentPosition;
|
||||
|
||||
(attachedGameElement as IHaveTransformSubmodule).transformSubmodule = this;
|
||||
(attachedGameElement as IHaveTransformSubmodule).SetTransformObserver();
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void UpdateJudge()
|
||||
{
|
||||
if(note.isJudged) return;
|
||||
if(note.isFirstJudged) return;
|
||||
Vector2 noteScreenPosition = note.noteScreenPosition;
|
||||
RectTransform canvasRect = EditorManager.instance.judgeHintCanvas.GetComponent<RectTransform>();
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, noteScreenPosition, null, out Vector2 uiPosition))
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void UpdateJudge()
|
||||
{
|
||||
if(note.isJudged) return;
|
||||
if(note.isFirstJudged) return;
|
||||
Vector2 noteScreenPosition = note.noteScreenPosition;
|
||||
RectTransform canvasRect = EditorManager.instance.judgeHintCanvas.GetComponent<RectTransform>();
|
||||
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, noteScreenPosition, null, out Vector2 uiPosition))
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using Unity.VisualScripting;
|
||||
@@ -54,6 +55,18 @@ namespace Ichni.RhythmGame
|
||||
matchedBM = new Flick_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
||||
exactJudgeTime, availableFlickDirections);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Flick");
|
||||
var generateNoteVisualButton = inspector.GenerateButton(this, container, "Generate Note Visual", () =>
|
||||
{
|
||||
TemporaryObject.GenerateElement("New Note Visual", Guid.NewGuid(), new List<string>(), true, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
|
||||
@@ -1,18 +1,186 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class Hold : MonoBehaviour
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public partial class Hold : NoteBase
|
||||
{
|
||||
public float holdEndTime;
|
||||
public bool isHolding;
|
||||
|
||||
public static Hold GenerateElement(string elementName, Guid id, List<string> tags, bool isFirstGenerated,
|
||||
GameElement parentElement, float exactJudgeTime, float holdEndTime)
|
||||
{
|
||||
Hold hold = Instantiate(EditorManager.instance.basePrefabs.tapNote, parentElement.transform)
|
||||
.GetComponent<Hold>();
|
||||
hold.Initialize(elementName, id, tags, isFirstGenerated, parentElement);
|
||||
hold.exactJudgeTime = exactJudgeTime;
|
||||
hold.holdEndTime = holdEndTime;
|
||||
|
||||
if (parentElement.TryGetComponent(out Track track))
|
||||
{
|
||||
if (track.trackTimeSubmodule != null)
|
||||
{
|
||||
hold.track = track;
|
||||
//hold.trackPositioner = hold.AddComponent<SplinePositioner>();
|
||||
hold.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
hold.isOnTrack = true;
|
||||
hold.UpdateNoteInTrack();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hold.track = null;
|
||||
hold.isOnTrack = false;
|
||||
}
|
||||
|
||||
return hold;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Hold
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Hold_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, exactJudgeTime, holdEndTime);
|
||||
}
|
||||
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Hold");
|
||||
var holdEndTimeInputField = inspector.GenerateInputField(this, container, "holdEndTime", nameof(holdEndTime));
|
||||
var generateNoteVisualButton = inspector.GenerateButton(this, container, "Generate Note Visual", () =>
|
||||
{
|
||||
TemporaryObject.GenerateElement("New Note Visual", Guid.NewGuid(), new List<string>(), true, this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
public partial class Hold
|
||||
{
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if(holdEndTime < exactJudgeTime)
|
||||
{
|
||||
LogWindow.Log("Hold end time is earlier than exact judge time.", Color.red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOnTrack)
|
||||
{
|
||||
if (track.trackTimeSubmodule is TrackTimeSubmoduleStatic)
|
||||
{
|
||||
UpdateNoteInStaticTrack();
|
||||
}
|
||||
}
|
||||
|
||||
float songTime = EditorManager.instance.songInformation.songTime;
|
||||
|
||||
if (isFirstJudged && songTime < exactJudgeTime)
|
||||
{
|
||||
isFirstJudged = false;
|
||||
isHolding = false;
|
||||
}
|
||||
|
||||
if (isHolding && songTime > holdEndTime)
|
||||
{
|
||||
isHolding = false;
|
||||
}
|
||||
|
||||
if (!isFirstJudged && songTime >= exactJudgeTime)
|
||||
{
|
||||
if (!isFirstJudged)
|
||||
{
|
||||
//AudioSource.PlayClipAtPoint(EditorManager.instance.basePrefabs.tapNoteSound, Camera.main.transform.position, 1f);
|
||||
isFirstJudged = true;
|
||||
}
|
||||
|
||||
if (isFirstJudged && !isHolding && songTime < holdEndTime)
|
||||
{
|
||||
isHolding = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (noteJudgeSubmodule != null && !EditorManager.instance.cameraManager.isSceneCameraActive)
|
||||
{
|
||||
foreach (NoteJudgeUnit unit in noteJudgeSubmodule.judgeUnitList.Where(unit => unit.isShowingJudge))
|
||||
{
|
||||
unit.UpdateJudge();
|
||||
}
|
||||
}
|
||||
|
||||
if (noteVisual != null)
|
||||
{
|
||||
noteVisual.effectSubmodule.effectCollection["Generate"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
noteVisual.effectSubmodule.effectCollection["GeneralJudge"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
|
||||
noteVisual.effectSubmodule.effectCollection["Holding"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
|
||||
switch (EditorManager.instance.currentJudgeType)
|
||||
{
|
||||
case NoteJudgeType.Perfect:
|
||||
noteVisual.effectSubmodule.effectCollection["Perfect"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
case NoteJudgeType.Good:
|
||||
noteVisual.effectSubmodule.effectCollection["Good"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
case NoteJudgeType.Bad:
|
||||
noteVisual.effectSubmodule.effectCollection["Bad"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
case NoteJudgeType.Miss:
|
||||
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
}
|
||||
|
||||
if (EditorManager.instance.cameraManager.haveGameCamera)
|
||||
{
|
||||
noteScreenPosition = EditorManager.instance.cameraManager.gameCamera.camera.WorldToScreenPoint(noteVisual.transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class Hold_BM : NoteBase_BM
|
||||
{
|
||||
public float holdEndTime;
|
||||
|
||||
public Hold_BM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Hold_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement, float exactJudgeTime, float holdEndTime)
|
||||
: base(elementName, elementGuid, tags, attachedElement, exactJudgeTime)
|
||||
{
|
||||
this.holdEndTime = holdEndTime;
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
matchedElement = Hold.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid), exactJudgeTime, holdEndTime);
|
||||
}
|
||||
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return Hold.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent, exactJudgeTime, holdEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using Dreamteck.Splines;
|
||||
using Ichni.Editor;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
[Title("In-Game Info")]
|
||||
public Vector2 noteScreenPosition;
|
||||
public bool isJudged;
|
||||
[FormerlySerializedAs("isJudged")] public bool isFirstJudged;
|
||||
|
||||
/// <summary>
|
||||
/// 在MovableTrack上更新Note的位置,注意HoldNote需要重写这个方法
|
||||
@@ -61,7 +62,7 @@ namespace Ichni.RhythmGame
|
||||
noteJudgeSubmodule = new NoteJudgeSubmodule(this);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (isOnTrack)
|
||||
{
|
||||
@@ -73,17 +74,17 @@ namespace Ichni.RhythmGame
|
||||
|
||||
float songTime = EditorManager.instance.songInformation.songTime;
|
||||
|
||||
if (isJudged && songTime < exactJudgeTime)
|
||||
if (isFirstJudged && songTime < exactJudgeTime)
|
||||
{
|
||||
isJudged = false;
|
||||
isFirstJudged = false;
|
||||
}
|
||||
|
||||
if (!isJudged && songTime >= exactJudgeTime)
|
||||
if (!isFirstJudged && songTime >= exactJudgeTime)
|
||||
{
|
||||
if (!isJudged)
|
||||
if (!isFirstJudged)
|
||||
{
|
||||
//AudioSource.PlayClipAtPoint(EditorManager.instance.basePrefabs.tapNoteSound, Camera.main.transform.position, 1f);
|
||||
isJudged = true;
|
||||
isFirstJudged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||||
throw new Exception("如果Note要生成在Track上,Track必须有TrackTimeSubmodule组件。");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -56,7 +56,7 @@ namespace Ichni.RhythmGame
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Generate");
|
||||
var container = inspector.GenerateContainer("Stay");
|
||||
var generateNoteVisualButton = inspector.GenerateButton(this, container, "Generate Note Visual", () =>
|
||||
{
|
||||
TemporaryObject.GenerateElement("New Note Visual", Guid.NewGuid(), new List<string>(), true, this);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Ichni.RhythmGame
|
||||
base.SetUpInspector();
|
||||
|
||||
IHaveInspection inspector = EditorManager.instance.uiManager.inspector;
|
||||
var container = inspector.GenerateContainer("Generate");
|
||||
var container = inspector.GenerateContainer("Tap");
|
||||
var generateNoteVisualButton = inspector.GenerateButton(this, container, "Generate Note Visual", () =>
|
||||
{
|
||||
TemporaryObject.GenerateElement("New Note Visual", Guid.NewGuid(), new List<string>(), true, this);
|
||||
|
||||
@@ -32,6 +32,8 @@ namespace Ichni.RhythmGame
|
||||
this.trackSamplingType = trackSamplingType;
|
||||
this.isClosed = isClosed;
|
||||
|
||||
this.path.sampleRate = 16;
|
||||
|
||||
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
|
||||
//闭合路径在PathNode生成时执行,在初始化的情况下,PathNode数量为0,不会执行闭合操作
|
||||
|
||||
|
||||
Reference in New Issue
Block a user