Files
ichni_Creator_Studio/Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs
SoulliesOfficial 5f64c4faf8 基础内容-6
技术性调整;
Note效果;
2025-01-30 22:45:33 -05:00

105 lines
2.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class EffectSubmodule : SubmoduleBase
{
public List<EffectBase> effectList;
public EffectSubmodule(BaseElement attachedElement) : base(attachedElement)
{
effectList = new List<EffectBase>();
}
}
public abstract class EffectBase
{
public enum EffectState
{
Before = -1,
Middle = 0,
After = 1,
Error = 100
}
/// <summary>
/// 效果的持续时间如果为0则表示瞬间效果
/// </summary>
public float effectTime;
/// <summary>
/// 是否是瞬间效果
/// </summary>
public bool isInstantEffect => effectTime <= 0;
/// <summary>
/// 效果当前的状态
/// </summary>
public EffectState nowEffectState;
protected EffectBase()
{
this.effectTime = 0;
this.nowEffectState = EffectState.Before;
}
protected EffectBase(float effectTime)
{
this.effectTime = effectTime;
this.nowEffectState = EffectState.Before;
}
public virtual void UpdateEffect()
{
EffectState state = CheckEffectState();
if (state == EffectState.Before && nowEffectState != EffectState.Before)
{
nowEffectState = EffectState.Before;
Recover();
}
else if (state == EffectState.Middle)
{
nowEffectState = EffectState.Middle;
Execute();
}
else if (state == EffectState.After && nowEffectState != EffectState.After)
{
nowEffectState = EffectState.After;
Adjust();
}
}
public virtual EffectState CheckEffectState()
{
throw new System.NotImplementedException();
}
/// <summary>
/// 在效果的持续时间内,触发这个方法
/// </summary>
public virtual void Execute()
{
}
/// <summary>
/// 如果是非瞬间效果,在效果完成后,触发这个方法;
/// 如果是瞬间效果则此方法即为Execute。原有的Execute方法不被调用。
/// </summary>
public virtual void Adjust()
{
}
/// <summary>
/// 如果时间轴回退到效果的触发时间之前,则触发这个方法
/// </summary>
public virtual void Recover()
{
}
}
}