基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
93
Assets/Scripts/Base/BaseElement.cs
Normal file
93
Assets/Scripts/Base/BaseElement.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
[System.Serializable]
|
||||
public abstract partial class BaseElement : SerializedMonoBehaviour
|
||||
{
|
||||
//物体名
|
||||
public string elementName;
|
||||
|
||||
//序列号
|
||||
public int serialNumber;
|
||||
|
||||
//标识 GUID
|
||||
public Guid elementGuid;
|
||||
|
||||
//存档
|
||||
//public BaseElement_BM matchedBM;
|
||||
|
||||
//父游戏物体
|
||||
public BaseElement parentElement;
|
||||
|
||||
//子物体列表
|
||||
public List<BaseElement> childElementList = new List<BaseElement>();
|
||||
|
||||
//次级模块
|
||||
public TimeDurationSubmodule timeDurationSubmodule;
|
||||
public TransformSubmodule transformSubmodule;
|
||||
|
||||
/// <summary>
|
||||
/// 首次初始化
|
||||
/// </summary>
|
||||
/// <param name="name">物体名</param>
|
||||
public virtual void NewInitialize(string name)
|
||||
{
|
||||
this.elementName = name;
|
||||
this.elementGuid = Guid.NewGuid();
|
||||
//GameManager.beatMapContainer.beatMapElementList.Add(this);
|
||||
//serialNumber = totalSerialNumber++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在所有物体生成完毕后,执行的初始化方法
|
||||
/// </summary>
|
||||
public virtual void AfterInitialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新物体的状态
|
||||
/// </summary>
|
||||
public virtual void Refresh()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置父物体
|
||||
/// </summary>
|
||||
/// <param name="parentElement">父物体</param>
|
||||
public void SetParent(BaseElement parentElement)
|
||||
{
|
||||
if (parentElement != null)
|
||||
{
|
||||
parentElement.childElementList.Add(this);
|
||||
this.parentElement = parentElement;
|
||||
transform.SetParent(parentElement.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract partial class BaseElement
|
||||
{
|
||||
public virtual void SetTimeDuration()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Button("Apply Time Duration From Child")]
|
||||
public void ApplyTimeDuration()
|
||||
{
|
||||
childElementList.ForEach(x => x.ApplyTimeDuration());
|
||||
|
||||
timeDurationSubmodule?.SetDurationFromChildren(childElementList.Select(x=>x.timeDurationSubmodule).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user