基础内容-5
主题包; 测试NoteVisual与NoteEffect; LookAt旋转动画与FlexibleBool 动画杂项 控制台初步
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user