基础内容-6
技术性调整; Note效果;
This commit is contained in:
@@ -20,6 +20,9 @@ namespace Ichni.RhythmGame
|
||||
//标识 GUID
|
||||
public Guid elementGuid;
|
||||
|
||||
//标签
|
||||
public List<string> tags;
|
||||
|
||||
//存档
|
||||
//public BaseElement_BM matchedBM;
|
||||
|
||||
@@ -38,13 +41,14 @@ namespace Ichni.RhythmGame
|
||||
/// 首次初始化
|
||||
/// </summary>
|
||||
/// <param name="name">物体名</param>
|
||||
public virtual void NewInitialize(string name)
|
||||
public virtual void Initialize(string name)
|
||||
{
|
||||
this.elementName = name;
|
||||
this.elementGuid = Guid.NewGuid();
|
||||
EditorManager.instance.elementList.Add(this);
|
||||
//GameManager.beatMapContainer.beatMapElementList.Add(this);
|
||||
//serialNumber = totalSerialNumber++;
|
||||
SetTransformObserver();
|
||||
//SetTransformObserver();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -63,6 +67,14 @@ namespace Ichni.RhythmGame
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当物体被删除时执行的方法
|
||||
/// </summary>
|
||||
public virtual void OnDelete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置父物体
|
||||
/// </summary>
|
||||
@@ -76,6 +88,23 @@ namespace Ichni.RhythmGame
|
||||
transform.SetParent(parentElement.transform);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Delete()
|
||||
{
|
||||
if (this.childElementList != null)
|
||||
{
|
||||
for (int i = 0; i < childElementList.Count; i++)
|
||||
{
|
||||
childElementList[i].Delete(); //删除子GameElement、
|
||||
}
|
||||
}
|
||||
|
||||
OnDelete();
|
||||
|
||||
EditorManager.instance.elementList.Remove(this); //从保存列表中剔除
|
||||
this.parentElement.childElementList.Remove(this);
|
||||
Destroy(gameObject); //销毁
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class BaseElement
|
||||
|
||||
@@ -10,45 +10,62 @@ namespace Ichni.RhythmGame
|
||||
public bool emissionEnabled;
|
||||
public Color originalEmissionColor;
|
||||
public float originalEmissionIntensity;
|
||||
|
||||
|
||||
public List<Color> baseColorOffset = new List<Color>();
|
||||
public List<Color> emissionColorOffset = new List<Color>();
|
||||
public List<float> emissionIntensityOffset = new List<float>();
|
||||
|
||||
|
||||
public Color currentBaseColor;
|
||||
public Color currentEmissionColor;
|
||||
public float currentEmissionIntensity;
|
||||
|
||||
public bool baseColorDirtyMark;
|
||||
public bool emissionColorDirtyMark;
|
||||
|
||||
public ColorSubmodule()
|
||||
|
||||
public ColorSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
|
||||
this.originalBaseColor = Color.white;
|
||||
this.emissionEnabled = false;
|
||||
this.originalEmissionColor = Color.black;
|
||||
this.originalEmissionIntensity = 0;
|
||||
|
||||
this.currentBaseColor = Color.white;
|
||||
this.currentEmissionColor = Color.black;
|
||||
this.currentEmissionIntensity = 0;
|
||||
|
||||
this.baseColorDirtyMark = false;
|
||||
this.emissionColorDirtyMark = false;
|
||||
}
|
||||
|
||||
public ColorSubmodule(Color originalBaseColor)
|
||||
|
||||
public ColorSubmodule(BaseElement attachedElement, Color originalBaseColor) : base(attachedElement)
|
||||
{
|
||||
this.originalBaseColor = originalBaseColor;
|
||||
this.emissionEnabled = false;
|
||||
this.originalEmissionColor = Color.black;
|
||||
this.originalEmissionIntensity = 0;
|
||||
|
||||
|
||||
this.currentBaseColor = originalBaseColor;
|
||||
this.currentEmissionColor = Color.black;
|
||||
this.currentEmissionIntensity = 0;
|
||||
|
||||
this.baseColorDirtyMark = false;
|
||||
this.emissionColorDirtyMark = false;
|
||||
}
|
||||
|
||||
public ColorSubmodule(Color originalBaseColor, bool emissionEnabled, Color originalEmissionColor, float originalEmissionIntensity)
|
||||
|
||||
public ColorSubmodule(BaseElement attachedElement, Color originalBaseColor, bool emissionEnabled,
|
||||
Color originalEmissionColor, float originalEmissionIntensity) : base(attachedElement)
|
||||
{
|
||||
this.originalBaseColor = originalBaseColor;
|
||||
this.emissionEnabled = emissionEnabled;
|
||||
this.originalEmissionColor = originalEmissionColor;
|
||||
this.originalEmissionIntensity = originalEmissionIntensity;
|
||||
|
||||
|
||||
this.currentBaseColor = originalBaseColor;
|
||||
this.currentEmissionColor = originalEmissionColor;
|
||||
this.currentEmissionIntensity = originalEmissionIntensity;
|
||||
|
||||
this.baseColorDirtyMark = false;
|
||||
this.emissionColorDirtyMark = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,11 @@ namespace Ichni.RhythmGame
|
||||
public class EffectSubmodule : SubmoduleBase
|
||||
{
|
||||
public List<EffectBase> effectList;
|
||||
|
||||
public EffectSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
effectList = new List<EffectBase>();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class EffectBase
|
||||
|
||||
@@ -6,6 +6,13 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
public abstract class SubmoduleBase
|
||||
{
|
||||
public BaseElement attachedElement;
|
||||
|
||||
public SubmoduleBase(BaseElement attachedElement)
|
||||
{
|
||||
this.attachedElement = attachedElement;
|
||||
}
|
||||
|
||||
public virtual void InitialRefresh()
|
||||
{
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ namespace Ichni.RhythmGame
|
||||
public bool isOverridingDuration; //是否手动设置了时间区间,开启时,子物体的时间区间将被忽略
|
||||
public float startTime, endTime; //起止时间
|
||||
|
||||
public TimeDurationSubmodule()
|
||||
public TimeDurationSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
isOverridingDuration = false;
|
||||
startTime = 0;
|
||||
endTime = 0;
|
||||
startTime = -999;//TODO: 换为-delay
|
||||
endTime = 999;//TODO: 换为songLength
|
||||
}
|
||||
|
||||
public TimeDurationSubmodule(float startTime, float endTime)
|
||||
public TimeDurationSubmodule(BaseElement attachedElement, float startTime, float endTime) : base(attachedElement)
|
||||
{
|
||||
this.isOverridingDuration = false;
|
||||
this.startTime = startTime;
|
||||
|
||||
@@ -14,83 +14,70 @@ namespace Ichni.RhythmGame
|
||||
public Vector3 originalPosition;
|
||||
public Vector3 originalEulerAngles;
|
||||
public Vector3 originalScale;
|
||||
|
||||
|
||||
public List<Vector3> positionOffset;
|
||||
public List<Vector3> eulerAnglesOffset;
|
||||
public List<Vector3> scaleOffset;
|
||||
|
||||
|
||||
public Vector3 currentPosition;
|
||||
public Vector3 currentEulerAngles;
|
||||
public Vector3 currentScale;
|
||||
|
||||
|
||||
public bool positionDirtyMark;
|
||||
public bool eulerAnglesDirtyMark;
|
||||
public bool scaleDirtyMark;
|
||||
|
||||
public bool eulerAnglesOffsetLock;
|
||||
|
||||
|
||||
public UnityAction OnPositionChanged;
|
||||
public UnityAction OnEulerAnglesChanged;
|
||||
public UnityAction OnScaleChanged;
|
||||
|
||||
public TransformSubmodule()
|
||||
public TransformSubmodule(BaseElement attachedElement) : base(attachedElement)
|
||||
{
|
||||
this.originalPosition = Vector3.zero;
|
||||
this.originalEulerAngles = Vector3.zero;
|
||||
this.originalScale = Vector3.one;
|
||||
|
||||
|
||||
positionOffset = new List<Vector3>();
|
||||
eulerAnglesOffset = new List<Vector3>();
|
||||
scaleOffset = new List<Vector3>();
|
||||
|
||||
|
||||
currentPosition = Vector3.zero;
|
||||
currentEulerAngles = Vector3.zero;
|
||||
currentScale = Vector3.one;
|
||||
|
||||
|
||||
positionDirtyMark = false;
|
||||
eulerAnglesDirtyMark = false;
|
||||
scaleDirtyMark = false;
|
||||
|
||||
|
||||
eulerAnglesOffsetLock = false;
|
||||
|
||||
attachedElement.SetTransformObserver();
|
||||
}
|
||||
|
||||
public TransformSubmodule(Vector3 originalPosition, Vector3 originalEulerAngles, Vector3 originalScale)
|
||||
public TransformSubmodule(BaseElement attachedElement,
|
||||
Vector3 originalPosition, Vector3 originalEulerAngles, Vector3 originalScale) : base(attachedElement)
|
||||
{
|
||||
this.originalPosition = originalPosition;
|
||||
this.originalEulerAngles = originalEulerAngles;
|
||||
this.originalScale = originalScale;
|
||||
|
||||
|
||||
positionOffset = new List<Vector3>();
|
||||
eulerAnglesOffset = new List<Vector3>();
|
||||
scaleOffset = new List<Vector3>();
|
||||
|
||||
|
||||
currentPosition = originalPosition;
|
||||
currentEulerAngles = originalEulerAngles;
|
||||
currentScale = originalScale;
|
||||
|
||||
|
||||
positionDirtyMark = false;
|
||||
eulerAnglesDirtyMark = false;
|
||||
scaleDirtyMark = false;
|
||||
|
||||
|
||||
eulerAnglesOffsetLock = false;
|
||||
}
|
||||
|
||||
public void SetObserver(BaseElement target)
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (var positionOffset in positionOffset)
|
||||
{
|
||||
offset += positionOffset;
|
||||
}
|
||||
currentPosition = originalPosition + offset;
|
||||
positionDirtyMark = false;
|
||||
}
|
||||
positionOffset.Clear();
|
||||
}).AddTo(target);
|
||||
|
||||
attachedElement.SetTransformObserver();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.ThemeBundles.Basic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -13,6 +14,8 @@ namespace Ichni
|
||||
|
||||
public SongModule songModule;
|
||||
public BasePrefabsCollection basePrefabs;
|
||||
|
||||
public List<BaseElement> elementList = new List<BaseElement>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -22,17 +25,20 @@ namespace Ichni
|
||||
private void Start()
|
||||
{
|
||||
var f0 = ElementFolder.GenerateElement("Folder", null);
|
||||
var dis0 = Displacement.GenerateElement("Displacement-0", f0,
|
||||
new FlexibleFloat(),
|
||||
new FlexibleFloat(new List<AnimatedFloat>(){new (0,2,0,2, AnimationCurveType.Linear)}),
|
||||
new FlexibleFloat());
|
||||
var t0 = Track.GenerateElement("Track", f0, Vector3.left * 5f);
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule();
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable();
|
||||
t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient();
|
||||
(t0.trackPathSubmodule).NewInitialize(t0, false, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed);
|
||||
(t0.trackTimeSubmodule as TrackTimeSubmoduleMovable).NewInitialize(t0, 0, 1, 1, AnimationCurveType.Linear);
|
||||
(t0.trackRendererSubmodule as TrackRendererSubmoduleAutoOrient).NewInitialize(t0);
|
||||
var p0 = PathNode.GeneratePathNode("PathNode-0", t0, 0, Vector3.zero, Vector3.forward, 1, Color.white);
|
||||
var p1 = PathNode.GeneratePathNode("PathNode-1", t0, 1, Vector3.one * 10f, Vector3.left, 0, Color.red);
|
||||
|
||||
t0.AfterInitialize();
|
||||
t0.trackPathSubmodule = new TrackPathSubmodule(t0, Track.TrackSpaceType.Linear, Track.TrackSamplingType.TimeDistributed, false);
|
||||
t0.trackTimeSubmodule = new TrackTimeSubmoduleMovable(t0, 0, 2, 1, AnimationCurveType.Linear);
|
||||
t0.trackRendererSubmodule = new TrackRendererSubmoduleAutoOrient(t0);
|
||||
var p0 = PathNode.GenerateElement("PathNode-0", t0, 0, new Vector3(-5,5,10), Vector3.forward, 1, Color.white);
|
||||
var p1 = PathNode.GenerateElement("PathNode-1", t0, 1, new Vector3(5,-5,10), Vector3.forward, 0, Color.red);
|
||||
var n0 = Tap.GenerateElement("Note-0", 1f, t0);
|
||||
var n0v = BasicNoteVisual.GenerateElement("Note-0-V", "basic", "BasicNoteTap3D", Vector3.zero, Vector3.zero, Vector3.one, n0);
|
||||
|
||||
elementList.ForEach(e => e.AfterInitialize());
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
@@ -20,20 +20,16 @@ namespace Ichni
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
loadedThemeBundleList = new List<ThemeBundle>();
|
||||
|
||||
AssetBundle.UnloadAllAssetBundles(true);
|
||||
LoadAllThemeBundlesAbstract();
|
||||
|
||||
//DontDestroyOnLoad(gameObject);
|
||||
|
||||
LoadThemeBundle("fundamental");
|
||||
LoadThemeBundle("basic");
|
||||
}
|
||||
|
||||
|
||||
public T GetObject<T>(string themeBundleName, string objectName) where T : class
|
||||
{
|
||||
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
|
||||
|
||||
Reference in New Issue
Block a user