93 lines
2.5 KiB
C#
93 lines
2.5 KiB
C#
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());
|
|
}
|
|
}
|
|
} |