架构重新设计
基本重做了所有物体和次级模块代码
This commit is contained in:
@@ -3,11 +3,12 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class CrossTrackPoint : BaseElement
|
||||
public partial class CrossTrackPoint : GameElement, IHaveTimeDurationSubmodule
|
||||
{
|
||||
public ElementFolder trackListFolder;
|
||||
public Track nowAttachedTrack;
|
||||
@@ -16,24 +17,32 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public FlexibleInt trackSwitch;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||||
|
||||
public static CrossTrackPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated,
|
||||
ElementFolder elementFolder, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
|
||||
{
|
||||
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform).AddComponent<CrossTrackPoint>();
|
||||
point.Initialize(elementName, id, tags);
|
||||
CrossTrackPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, elementFolder.transform)
|
||||
.AddComponent<CrossTrackPoint>();
|
||||
point.Initialize(elementName, id, tags, isFirstGenerated);
|
||||
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
||||
point.nowAttachedTrackIndex = -1;
|
||||
point.trackListFolder = elementFolder;
|
||||
point.trackSwitch = trackSwitch;
|
||||
point.trackPercent = trackPercent;
|
||||
point.transformSubmodule = new TransformSubmodule(point);
|
||||
point.timeDurationSubmodule = new TimeDurationSubmodule(point);
|
||||
point.SetParent(elementFolder);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
protected override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
submoduleList.Add(timeDurationSubmodule);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (trackPercent.animations.Count > 0)
|
||||
@@ -46,7 +55,8 @@ namespace Ichni.RhythmGame
|
||||
|
||||
private void SetPoint()
|
||||
{
|
||||
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 && trackSwitch.value < trackListFolder.trackList.Count)
|
||||
if (nowAttachedTrackIndex != trackSwitch.value && trackSwitch.value >= 0 &&
|
||||
trackSwitch.value < trackListFolder.trackList.Count)
|
||||
{
|
||||
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
|
||||
nowAttachedTrackIndex = trackSwitch.value;
|
||||
@@ -56,28 +66,30 @@ namespace Ichni.RhythmGame
|
||||
trackPositioner.SetPercent(trackPercent.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public partial class CrossTrackPoint
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.CrossTrackPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackSwitch, trackPercent);
|
||||
matchedBM = new CrossTrackPoint_BM(elementName, elementGuid, tags,
|
||||
parentElement.matchedBM as GameElement_BM, trackSwitch, trackPercent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class CrossTrackPoint_BM : BaseElement_BM
|
||||
public class CrossTrackPoint_BM : GameElement_BM
|
||||
{
|
||||
public FlexibleInt trackSwitch;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
public CrossTrackPoint_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CrossTrackPoint_BM(string elementName, Guid elementGuid, List<string> tags,
|
||||
BaseElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
|
||||
GameElement_BM attachedElement, FlexibleInt trackSwitch, FlexibleFloat trackPercent)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.trackSwitch = trackSwitch;
|
||||
@@ -86,14 +98,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as ElementFolder,
|
||||
trackSwitch, trackPercent);
|
||||
CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid) as ElementFolder, trackSwitch, trackPercent);
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, parent as ElementFolder,
|
||||
trackSwitch, trackPercent);
|
||||
return CrossTrackPoint.GenerateElement(elementName, elementGuid, tags, false,
|
||||
parent as ElementFolder, trackSwitch, trackPercent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,23 +2,27 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class TrackHeadPoint : BaseElement
|
||||
public partial class TrackHeadPoint : GameElement, IHaveTimeDurationSubmodule
|
||||
{
|
||||
public Track track;
|
||||
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags, Track track)
|
||||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||||
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated, Track track)
|
||||
{
|
||||
TrackHeadPoint head = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
|
||||
.AddComponent<TrackHeadPoint>();
|
||||
|
||||
head.Initialize(elementName, id, tags);
|
||||
head.Initialize(elementName, id, tags, isFirstGenerated);
|
||||
head.track = track;
|
||||
head.trackPositioner = head.gameObject.AddComponent<SplinePositioner>();
|
||||
head.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
@@ -27,6 +31,12 @@ namespace Ichni.RhythmGame
|
||||
return head;
|
||||
}
|
||||
|
||||
protected override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
submoduleList.Add(timeDurationSubmodule);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
|
||||
@@ -40,13 +50,13 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM);
|
||||
matchedBM = new TrackHeadPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackHeadPoint_BM : BaseElement_BM
|
||||
public class TrackHeadPoint_BM : GameElement_BM
|
||||
{
|
||||
public TrackHeadPoint_BM()
|
||||
{
|
||||
@@ -54,20 +64,20 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
|
||||
public TrackHeadPoint_BM(string elementName, Guid elementGuid, List<string> tags,
|
||||
BaseElement_BM attachedElement)
|
||||
GameElement_BM attachedElement)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
TrackHeadPoint.GenerateElement(elementName, elementGuid, tags,
|
||||
TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid) as Track);
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, parent as Track);
|
||||
return TrackHeadPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
@@ -12,31 +13,41 @@ namespace Ichni.RhythmGame
|
||||
/// <summary>
|
||||
/// 在轨道上根据百分比进行运动的点
|
||||
/// </summary>
|
||||
public partial class TrackPercentPoint : BaseElement
|
||||
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule
|
||||
{
|
||||
public Track track;
|
||||
public SplinePositioner trackPositioner;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
|
||||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||||
|
||||
private bool isBeyond1 = false;
|
||||
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Guid id, List<string> tags,
|
||||
bool isFirstGenerated,
|
||||
Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
||||
TrackPercentPoint point = Instantiate(EditorManager.instance.basePrefabs.emptyObject, track.transform)
|
||||
.AddComponent<TrackPercentPoint>();
|
||||
|
||||
point.Initialize(elementName, id, tags);
|
||||
point.Initialize(elementName, id, tags, isFirstGenerated);
|
||||
point.track = track;
|
||||
point.trackPositioner = point.gameObject.AddComponent<SplinePositioner>();
|
||||
point.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
point.trackPercent = trackPercent;
|
||||
point.SetParent(track);
|
||||
|
||||
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画,超过1将会循环
|
||||
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1); //判断是否有超过1的动画,超过1将会循环
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
protected override void SetDefaultSubmodules()
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
submoduleList.Add(timeDurationSubmodule);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (trackPercent.animations.Count > 0)
|
||||
@@ -45,38 +56,41 @@ namespace Ichni.RhythmGame
|
||||
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
float finalValue = trackPercent.value;
|
||||
|
||||
|
||||
if (isBeyond1)
|
||||
{
|
||||
finalValue -= Mathf.Floor(finalValue);
|
||||
}
|
||||
|
||||
|
||||
trackPositioner.SetPercent(finalValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public partial class TrackPercentPoint
|
||||
{
|
||||
public override void SaveBM()
|
||||
{
|
||||
matchedBM = new Beatmap.TrackPercentPoint_BM(elementName, elementGuid, tags, parentElement.matchedBM, trackPercent.ConvertToBM());
|
||||
matchedBM = new TrackPercentPoint_BM(elementName, elementGuid, tags,
|
||||
parentElement.matchedBM as GameElement_BM,
|
||||
trackPercent.ConvertToBM());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Beatmap
|
||||
{
|
||||
public class TrackPercentPoint_BM : BaseElement_BM
|
||||
public class TrackPercentPoint_BM : GameElement_BM
|
||||
{
|
||||
public FlexibleFloat_BM trackPercent;
|
||||
|
||||
public TrackPercentPoint_BM()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public TrackPercentPoint_BM(string elementName, Guid elementGuid, List<string> tags,
|
||||
BaseElement_BM attachedElement, FlexibleFloat_BM trackPercent)
|
||||
GameElement_BM attachedElement, FlexibleFloat_BM trackPercent)
|
||||
: base(elementName, elementGuid, tags, attachedElement)
|
||||
{
|
||||
this.trackPercent = trackPercent;
|
||||
@@ -84,12 +98,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void ExecuteBM()
|
||||
{
|
||||
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
|
||||
TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false,
|
||||
GetElement(attachedElementGuid) as Track, trackPercent.ConvertToGameType());
|
||||
}
|
||||
|
||||
public override BaseElement DuplicateBM(BaseElement parent)
|
||||
public override GameElement DuplicateBM(GameElement parent)
|
||||
{
|
||||
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, parent as Track, trackPercent.ConvertToGameType());
|
||||
return TrackPercentPoint.GenerateElement(elementName, elementGuid, tags, false, parent as Track,
|
||||
trackPercent.ConvertToGameType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user