基础内容-5
主题包; 测试NoteVisual与NoteEffect; LookAt旋转动画与FlexibleBool 动画杂项 控制台初步
This commit is contained in:
BIN
Assets/Scripts/.DS_Store
vendored
BIN
Assets/Scripts/.DS_Store
vendored
Binary file not shown.
@@ -38,6 +38,11 @@ namespace Ichni.RhythmGame
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(startTimes.Min(), endTimes.Max());
|
||||
}
|
||||
|
||||
public virtual void SetTimeDuration(float startTime, float endTime)
|
||||
{
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(startTime, endTime);
|
||||
}
|
||||
|
||||
protected abstract void UpdateAnimation(float songTime);
|
||||
|
||||
protected virtual void Update()
|
||||
|
||||
8
Assets/Scripts/Animations/Color.meta
Normal file
8
Assets/Scripts/Animations/Color.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3418d0d84b6b476db0e552f2e754c7e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
62
Assets/Scripts/Animations/Color/BaseColorChange.cs
Normal file
62
Assets/Scripts/Animations/Color/BaseColorChange.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class BaseColorChange : AnimationBase
|
||||
{
|
||||
public ColorSubmodule targetColorSubmodule;
|
||||
public FlexibleFloat colorR, colorG, colorB, colorA;
|
||||
|
||||
public static BaseColorChange GenerateElement(string elementName, BaseElement targetObject,
|
||||
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorA)
|
||||
{
|
||||
BaseColorChange baseColorChange = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<BaseColorChange>();
|
||||
|
||||
baseColorChange.NewInitialize(elementName, targetObject);
|
||||
baseColorChange.colorR = colorR;
|
||||
baseColorChange.colorG = colorG;
|
||||
baseColorChange.colorB = colorB;
|
||||
baseColorChange.colorA = colorA;
|
||||
baseColorChange.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.colorSubmodule != null)
|
||||
{
|
||||
baseColorChange.targetColorSubmodule = targetObject.colorSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a ColorSubmodule");
|
||||
}
|
||||
|
||||
baseColorChange.SetTimeDuration(colorR, colorG, colorB, colorA);
|
||||
|
||||
return baseColorChange;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
colorR.UpdateFlexibleFloat(songTime);
|
||||
colorG.UpdateFlexibleFloat(songTime);
|
||||
colorB.UpdateFlexibleFloat(songTime);
|
||||
colorA.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorA.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Color colorOffset = new Color(colorR.value, colorG.value, colorB.value, colorA.value);
|
||||
targetColorSubmodule.baseColorOffset.Add(colorOffset);
|
||||
targetColorSubmodule.baseColorDirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Color/BaseColorChange.cs.meta
Normal file
11
Assets/Scripts/Animations/Color/BaseColorChange.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dada7ead8505418198027da3d9984bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/Scripts/Animations/Color/EmissionColorChange.cs
Normal file
65
Assets/Scripts/Animations/Color/EmissionColorChange.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class EmissionColorChange : AnimationBase
|
||||
{
|
||||
public ColorSubmodule targetColorSubmodule;
|
||||
public FlexibleFloat colorR, colorG, colorB, colorI;
|
||||
|
||||
public static EmissionColorChange GenerateElement(string elementName, BaseElement targetObject,
|
||||
FlexibleFloat colorR, FlexibleFloat colorG, FlexibleFloat colorB, FlexibleFloat colorI)
|
||||
{
|
||||
EmissionColorChange baseColorChange = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<EmissionColorChange>();
|
||||
|
||||
baseColorChange.NewInitialize(elementName, targetObject);
|
||||
baseColorChange.colorR = colorR;
|
||||
baseColorChange.colorG = colorG;
|
||||
baseColorChange.colorB = colorB;
|
||||
baseColorChange.colorI = colorI;
|
||||
baseColorChange.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.colorSubmodule != null)
|
||||
{
|
||||
baseColorChange.targetColorSubmodule = targetObject.colorSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a ColorSubmodule");
|
||||
}
|
||||
|
||||
baseColorChange.SetTimeDuration(colorR, colorG, colorB, colorI);
|
||||
|
||||
return baseColorChange;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
colorR.UpdateFlexibleFloat(songTime);
|
||||
colorG.UpdateFlexibleFloat(songTime);
|
||||
colorB.UpdateFlexibleFloat(songTime);
|
||||
colorI.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (colorR.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorG.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorB.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
colorI.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Color colorOffset = new Color(colorR.value, colorG.value, colorB.value);
|
||||
float intensityOffset = colorI.value;
|
||||
|
||||
targetColorSubmodule.emissionColorOffset.Add(colorOffset);
|
||||
targetColorSubmodule.emissionIntensityOffset.Add(intensityOffset);
|
||||
targetColorSubmodule.emissionColorDirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Color/EmissionColorChange.cs.meta
Normal file
11
Assets/Scripts/Animations/Color/EmissionColorChange.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed8c4bbcff6cc433dae44740d8f01b84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Animations/Track.meta
Normal file
8
Assets/Scripts/Animations/Track.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17936224adc4a4e3497f05188aeb115f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/Scripts/Animations/Track/TrackTotalTimeChange.cs
Normal file
43
Assets/Scripts/Animations/Track/TrackTotalTimeChange.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TrackTotalTimeChange : AnimationBase
|
||||
{
|
||||
public FlexibleFloat totalTime;
|
||||
public TrackTimeSubmoduleStatic targetTrackTimeSubmoduleStatic;
|
||||
|
||||
public static TrackTotalTimeChange GenerateElement(string elementName, Track targetTrack, FlexibleFloat totalTime)
|
||||
{
|
||||
TrackTotalTimeChange trackTotalTimeChange = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<TrackTotalTimeChange>();
|
||||
trackTotalTimeChange.NewInitialize(elementName, targetTrack);
|
||||
|
||||
if (targetTrack.trackTimeSubmodule is TrackTimeSubmoduleStatic submoduleStatic)
|
||||
{
|
||||
trackTotalTimeChange.targetTrackTimeSubmoduleStatic = submoduleStatic;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TrackTimeSubmoduleStatic");
|
||||
}
|
||||
|
||||
trackTotalTimeChange.totalTime = totalTime;
|
||||
trackTotalTimeChange.animationReturnType = FlexibleReturnType.Before;
|
||||
trackTotalTimeChange.SetTimeDuration(totalTime);
|
||||
return trackTotalTimeChange;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
totalTime.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (totalTime.returnType == FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
targetTrackTimeSubmoduleStatic.trackTotalTime = totalTime.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Track/TrackTotalTimeChange.cs.meta
Normal file
11
Assets/Scripts/Animations/Track/TrackTotalTimeChange.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2eec4a2a4ac744e0ca183d59c465c4e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -41,6 +41,11 @@ namespace Ichni.RhythmGame
|
||||
return displacement;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
positionX.UpdateFlexibleFloat(songTime);
|
||||
@@ -56,6 +61,10 @@ namespace Ichni.RhythmGame
|
||||
targetTransformSubmodule.positionOffset.Add(currentPosition);
|
||||
targetTransformSubmodule.positionDirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
|
||||
//本体使用,用于判断动画是否结束
|
||||
// else if (positionX.returnType is FlexibleReturnType.After or FlexibleReturnType.None &&
|
||||
|
||||
71
Assets/Scripts/Animations/Transform/LookAt.cs
Normal file
71
Assets/Scripts/Animations/Transform/LookAt.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
/// <summary>
|
||||
/// 将物体的z轴指向目标物体,注意,LookAt的启用期间,物体的旋转将被锁定
|
||||
/// </summary>
|
||||
public class LookAt : AnimationBase
|
||||
{
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public BaseElement lookAtObject;
|
||||
public FlexibleBool enabling;
|
||||
|
||||
public static LookAt GenerateElement(string elementName, BaseElement targetObject,
|
||||
BaseElement lookAtTarget, FlexibleBool enabling)
|
||||
{
|
||||
LookAt swirl = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<LookAt>();
|
||||
|
||||
swirl.NewInitialize(elementName, targetObject);
|
||||
|
||||
swirl.lookAtObject = lookAtTarget;
|
||||
swirl.enabling = enabling;
|
||||
swirl.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.transformSubmodule != null)
|
||||
{
|
||||
swirl.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
swirl.SetTimeDuration(-999, 999); //TODO: 换为(-delay, songLength)
|
||||
|
||||
return swirl;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
enabling.UpdateFlexibleBool(songTime);
|
||||
if (enabling.value)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 lookingDirection =
|
||||
(lookAtObject.transform.position - targetObject.transform.position).normalized;
|
||||
|
||||
Vector3 eulerAnglesOffset = Quaternion.LookRotation(lookingDirection).eulerAngles;
|
||||
|
||||
targetTransformSubmodule.eulerAnglesOffsetLock = true;
|
||||
|
||||
targetTransformSubmodule.currentEulerAngles = eulerAnglesOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
targetTransformSubmodule.eulerAnglesOffsetLock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Transform/LookAt.cs.meta
Normal file
11
Assets/Scripts/Animations/Transform/LookAt.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c02ee9e15cdc048c5909a61377382530
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -49,6 +49,10 @@ namespace Ichni.RhythmGame
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset.Add(currentScale);
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,10 @@ namespace Ichni.RhythmGame
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleInterval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Assets/Scripts/Base/.DS_Store
vendored
Normal file
BIN
Assets/Scripts/Base/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
@@ -31,6 +32,7 @@ namespace Ichni.RhythmGame
|
||||
//次级模块
|
||||
public TimeDurationSubmodule timeDurationSubmodule;
|
||||
public TransformSubmodule transformSubmodule;
|
||||
public ColorSubmodule colorSubmodule;
|
||||
|
||||
/// <summary>
|
||||
/// 首次初始化
|
||||
@@ -42,6 +44,7 @@ namespace Ichni.RhythmGame
|
||||
this.elementGuid = Guid.NewGuid();
|
||||
//GameManager.beatMapContainer.beatMapElementList.Add(this);
|
||||
//serialNumber = totalSerialNumber++;
|
||||
SetTransformObserver();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,6 +80,11 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public abstract partial class BaseElement
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
SetTransformObserver();
|
||||
}
|
||||
|
||||
public virtual void SetTimeDuration()
|
||||
{
|
||||
|
||||
@@ -89,5 +97,60 @@ namespace Ichni.RhythmGame
|
||||
|
||||
timeDurationSubmodule?.SetDurationFromChildren(childElementList.Select(x=>x.timeDurationSubmodule).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置物体Transform的监听,顺序为Scale -> EulerAngles -> Position
|
||||
/// 如果有一些特殊的物体(例如Camera,ElementFolder),需要自定义监听,可以重写这个方法
|
||||
/// </summary>
|
||||
public virtual void SetTransformObserver()
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (transformSubmodule == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (transformSubmodule.scaleDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 scaleOffset in transformSubmodule.scaleOffset)
|
||||
{
|
||||
offset += scaleOffset;
|
||||
}
|
||||
transformSubmodule.currentScale = transformSubmodule.originalScale + offset;
|
||||
transform.localScale = transformSubmodule.currentScale;
|
||||
transformSubmodule.scaleDirtyMark = false;
|
||||
}
|
||||
|
||||
if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 eulerOffset in transformSubmodule.eulerAnglesOffset)
|
||||
{
|
||||
offset += eulerOffset;
|
||||
}
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
transform.localEulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
}
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 posOffset in transformSubmodule.positionOffset)
|
||||
{
|
||||
offset += posOffset;
|
||||
}
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
transform.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
}
|
||||
|
||||
transformSubmodule.scaleOffset.Clear();
|
||||
transformSubmodule.eulerAnglesOffset.Clear();
|
||||
transformSubmodule.positionOffset.Clear();
|
||||
}).AddTo(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Assets/Scripts/Base/FlexibleTypes/FlexibleBool.cs
Normal file
70
Assets/Scripts/Base/FlexibleTypes/FlexibleBool.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AnimatedBool
|
||||
{
|
||||
public bool value; //bool值
|
||||
public float time; //当前时间
|
||||
|
||||
public AnimatedBool(bool value, float time)
|
||||
{
|
||||
this.value = value;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class FlexibleBool
|
||||
{
|
||||
public bool value;
|
||||
public List<AnimatedBool> animations;
|
||||
|
||||
public FlexibleBool()
|
||||
{
|
||||
animations = new List<AnimatedBool>();
|
||||
}
|
||||
|
||||
public FlexibleBool(List<AnimatedBool> anim)
|
||||
{
|
||||
this.animations = anim;
|
||||
}
|
||||
|
||||
public void Add(AnimatedBool animatedBool)
|
||||
{
|
||||
animations.Add(animatedBool);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在动画脚本的Update中更新Bool Value
|
||||
/// </summary>
|
||||
/// <param name="歌曲时间"></param>
|
||||
public FlexibleReturnType UpdateFlexibleBool(float nowTime)
|
||||
{
|
||||
AnimatedBool nowAnimatedBool = GetAnimatedBool(nowTime); //获取当前时间点对应的AnimatedBool
|
||||
value = nowAnimatedBool.value; //更新value
|
||||
return FlexibleReturnType.MiddleExecuting;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取songTime对应的AnimatedBool的时间段
|
||||
/// </summary>
|
||||
/// <param name="歌曲时间"></param>
|
||||
/// <returns>返回距离当前时间最近的前一个AnimatedBool</returns>
|
||||
AnimatedBool GetAnimatedBool(float nowTime)
|
||||
{
|
||||
for (int i = 0; i < animations.Count; i++)
|
||||
{
|
||||
if (nowTime >= animations[i].time)
|
||||
{
|
||||
return animations[i];
|
||||
}
|
||||
}
|
||||
|
||||
return new AnimatedBool(false, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Base/FlexibleTypes/FlexibleBool.cs.meta
Normal file
11
Assets/Scripts/Base/FlexibleTypes/FlexibleBool.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43cce55e6aac440e9b664e917adc2f74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,6 +22,11 @@ namespace Ichni.RhythmGame
|
||||
public bool baseColorDirtyMark;
|
||||
public bool emissionColorDirtyMark;
|
||||
|
||||
public ColorSubmodule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ColorSubmodule(Color originalBaseColor)
|
||||
{
|
||||
this.originalBaseColor = originalBaseColor;
|
||||
|
||||
@@ -26,25 +26,53 @@ namespace Ichni.RhythmGame
|
||||
public bool positionDirtyMark;
|
||||
public bool eulerAnglesDirtyMark;
|
||||
public bool scaleDirtyMark;
|
||||
|
||||
public bool eulerAnglesOffsetLock;
|
||||
|
||||
public UnityAction OnPositionChanged;
|
||||
public UnityAction OnEulerAnglesChanged;
|
||||
public UnityAction OnScaleChanged;
|
||||
|
||||
public TransformSubmodule()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public TransformSubmodule(Vector3 originalPosition, Vector3 originalEulerAngles, Vector3 originalScale)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -9,6 +9,7 @@ public class BasePrefabsCollection : SerializedScriptableObject
|
||||
[Title("基础预制体")]
|
||||
public GameObject emptyObject;
|
||||
public GameObject elementFolder;
|
||||
public GameObject gameCamera;
|
||||
|
||||
[Title("Track相关")]
|
||||
public GameObject track;
|
||||
|
||||
@@ -34,6 +34,11 @@ namespace Ichni
|
||||
|
||||
t0.AfterInitialize();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
songModule.songTime += Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
public class SongModule
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
@@ -123,20 +124,23 @@ namespace Ichni
|
||||
[System.Serializable]
|
||||
public class ThemeBundleAbstract
|
||||
{
|
||||
public string themeBundleName;
|
||||
public string fileName;
|
||||
public string displayName;
|
||||
public string description;
|
||||
public List<string> tags;
|
||||
|
||||
public string iconPath;
|
||||
|
||||
public ThemeBundleAbstract()
|
||||
{
|
||||
}
|
||||
|
||||
public ThemeBundleAbstract(string themeBundleName, List<string> tags, string iconPath)
|
||||
public ThemeBundleAbstract(string fileName)
|
||||
{
|
||||
this.themeBundleName = themeBundleName;
|
||||
this.tags = tags;
|
||||
this.iconPath = iconPath;
|
||||
this.fileName = fileName;
|
||||
this.displayName = fileName;
|
||||
this.description = "Default Description";
|
||||
this.tags = new List<string>();
|
||||
this.iconPath = "Icons/Default.png";
|
||||
}
|
||||
|
||||
public Texture2D GetIcon()
|
||||
|
||||
8
Assets/Scripts/Console.meta
Normal file
8
Assets/Scripts/Console.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e7fc3c136a914933bc2a6d75b13e7d1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/Console/EditorConsole.cs
Normal file
31
Assets/Scripts/Console/EditorConsole.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DynamicExpresso;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public partial class EditorConsole : MonoBehaviour
|
||||
{
|
||||
public Interpreter functionInterpreter;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SetUpFunctions();
|
||||
|
||||
//Test
|
||||
functionInterpreter.Eval("Log(\"Hello World!\")");
|
||||
}
|
||||
}
|
||||
|
||||
public partial class EditorConsole
|
||||
{
|
||||
private void SetUpFunctions()
|
||||
{
|
||||
functionInterpreter = new Interpreter();
|
||||
|
||||
functionInterpreter.SetFunction("Log", (System.Action<object>)Debug.Log);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Console/EditorConsole.cs.meta
Normal file
11
Assets/Scripts/Console/EditorConsole.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 912c3a32e155f4ca79a4ca1fa1f359e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -14,10 +14,10 @@ namespace Ichni.RhythmGame
|
||||
|
||||
elementFolder.NewInitialize(name);
|
||||
elementFolder.SetParent(parentElement);
|
||||
elementFolder.transformSubmodule = new TransformSubmodule(Vector3.zero, Vector3.zero, Vector3.one);
|
||||
//elementFolder.GenerateTab(parentElement);
|
||||
|
||||
return elementFolder;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class EnvironmentObject : SubstantialObject
|
||||
{
|
||||
public bool isStatic;
|
||||
|
||||
public static SubstantialObject GenerateElement(string elementName, string themeBundleName,
|
||||
string objectName, Vector3 position, Vector3 eulerAngles, Vector3 scale, BaseElement parent,
|
||||
bool isStatic, bool isFirstGenerated = true)
|
||||
{
|
||||
EnvironmentObject themeBundleObject = ThemeBundleManager.instance.GetObject<EnvironmentObject>(themeBundleName, objectName);
|
||||
EnvironmentObject environmentObject = LeanPool.Spawn(themeBundleObject, parent.transform).GetComponent<EnvironmentObject>();
|
||||
environmentObject.NewInitialize(elementName);
|
||||
environmentObject.isStatic = isStatic;
|
||||
return environmentObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b73aa7982dc9e4261b2ff45db0112d48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GameElements/GameCamera.meta
Normal file
8
Assets/Scripts/GameElements/GameCamera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56a4c0ac4ed204fcfb16a22f625230cd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/Scripts/GameElements/GameCamera/GameCamera.cs
Normal file
90
Assets/Scripts/GameElements/GameCamera/GameCamera.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class GameCamera : BaseElement
|
||||
{
|
||||
public Camera camera;
|
||||
public Transform rotationPoint;
|
||||
public Transform positionPoint;
|
||||
public Transform cameraTransform;
|
||||
|
||||
public CameraViewType cameraViewType;
|
||||
public float perspectiveAngle;
|
||||
public float orthographicSize;
|
||||
|
||||
public static GameCamera GenerateElement(string elementName, BaseElement parentElement,
|
||||
CameraViewType cameraViewType, float perspectiveAngle, float orthographicSize,
|
||||
Vector3 initialPosition, Vector3 initialEulerAngles)
|
||||
{
|
||||
GameCamera gameCamera = LeanPool.Spawn(EditorManager.instance.basePrefabs.gameCamera).GetComponent<GameCamera>();
|
||||
|
||||
gameCamera.NewInitialize(elementName);
|
||||
gameCamera.parentElement = parentElement;
|
||||
gameCamera.cameraViewType = cameraViewType;
|
||||
gameCamera.camera.orthographic = cameraViewType == CameraViewType.Orthographic;
|
||||
gameCamera.perspectiveAngle = perspectiveAngle;
|
||||
gameCamera.orthographicSize = orthographicSize;
|
||||
gameCamera.transformSubmodule = new TransformSubmodule(initialPosition, initialEulerAngles, Vector3.one);
|
||||
gameCamera.cameraTransform = gameCamera.transform;
|
||||
|
||||
gameCamera.SetParent(parentElement);
|
||||
|
||||
return gameCamera;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
public enum CameraViewType
|
||||
{
|
||||
None = -1,
|
||||
Perspective = 0,
|
||||
Orthographic = 1
|
||||
}
|
||||
}
|
||||
|
||||
public partial class GameCamera
|
||||
{
|
||||
public override void SetTransformObserver()
|
||||
{
|
||||
Observable.EveryUpdate().Subscribe(_ =>
|
||||
{
|
||||
if (transformSubmodule.eulerAnglesOffsetLock)
|
||||
{
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
}
|
||||
else if (transformSubmodule.eulerAnglesDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 eulerOffset in transformSubmodule.eulerAnglesOffset)
|
||||
{
|
||||
offset += eulerOffset;
|
||||
}
|
||||
transformSubmodule.currentEulerAngles = transformSubmodule.originalEulerAngles + offset;
|
||||
rotationPoint.eulerAngles = transformSubmodule.currentEulerAngles;
|
||||
transformSubmodule.eulerAnglesDirtyMark = false;
|
||||
}
|
||||
|
||||
if (transformSubmodule.positionDirtyMark)
|
||||
{
|
||||
Vector3 offset = Vector3.zero;
|
||||
foreach (Vector3 posOffset in transformSubmodule.positionOffset)
|
||||
{
|
||||
offset += posOffset;
|
||||
}
|
||||
transformSubmodule.currentPosition = transformSubmodule.originalPosition + offset;
|
||||
positionPoint.localPosition = transformSubmodule.currentPosition;
|
||||
transformSubmodule.positionDirtyMark = false;
|
||||
}
|
||||
}).AddTo(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameElements/GameCamera/GameCamera.cs.meta
Normal file
11
Assets/Scripts/GameElements/GameCamera/GameCamera.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79d811a12f27f43629797719fcbfc6ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,9 +17,9 @@ namespace Ichni.RhythmGame
|
||||
public Track track;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
// [Title("NoteVisual")]
|
||||
// public GeneralNoteVisual noteVisual;
|
||||
//
|
||||
[Title("NoteVisual")]
|
||||
public NoteVisualBase noteVisual;
|
||||
|
||||
[Title("NoteEffect")]
|
||||
[Tooltip("生成Note时的特效")]
|
||||
public EffectSubmodule generateEffects;
|
||||
|
||||
12
Assets/Scripts/GameElements/Notes/NoteEffectBase.cs
Normal file
12
Assets/Scripts/GameElements/Notes/NoteEffectBase.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class NoteEffectBase : EffectBase
|
||||
{
|
||||
public NoteBase note;
|
||||
public NoteVisualBase noteVisual;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameElements/Notes/NoteEffectBase.cs.meta
Normal file
11
Assets/Scripts/GameElements/Notes/NoteEffectBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5346ecda36b94450cba8f853621bdfdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,17 +2,22 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NoteVisualBase : MonoBehaviour
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public class NoteVisualBase : SubstantialObject
|
||||
{
|
||||
public NoteBase note;
|
||||
|
||||
}
|
||||
public GameObject noteMain;
|
||||
public GameObject judgeEffect;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
public List<GameObject> notePartList;
|
||||
public List<GameObject> effectPartList;
|
||||
|
||||
public void NewInitialize(NoteBase note)
|
||||
{
|
||||
base.NewInitialize(note.elementName + " Note Visual");
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Dreamteck.Splines;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
@@ -15,6 +16,8 @@ namespace Ichni.RhythmGame
|
||||
public Track track;
|
||||
public SplinePositioner trackPositioner;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
private bool isBeyond1 = false;
|
||||
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
@@ -23,6 +26,8 @@ namespace Ichni.RhythmGame
|
||||
point.NewInitialize(elementName, track, trackPercent);
|
||||
point.SetParent(track);
|
||||
|
||||
point.isBeyond1 = trackPercent.animations.Any(animation => animation.endValue > 1);//判断是否有超过1的动画,超过1将会循环
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
@@ -42,7 +47,14 @@ namespace Ichni.RhythmGame
|
||||
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
|
||||
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
trackPositioner.SetPercent(trackPercent.value);
|
||||
float finalValue = trackPercent.value;
|
||||
|
||||
if (isBeyond1)
|
||||
{
|
||||
finalValue -= Mathf.Floor(finalValue);
|
||||
}
|
||||
|
||||
trackPositioner.SetPercent(finalValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user