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