63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Convention;
|
|
using UnityEngine;
|
|
using System;
|
|
|
|
namespace Demo.Game
|
|
{
|
|
public class DDT : ScriptableObject, IEnumerable<float>
|
|
{
|
|
public static DDT Make()
|
|
{
|
|
return new GameObject().AddComponent<DDT>();
|
|
}
|
|
|
|
public List<float> Datas = new();
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public void Add(float value)
|
|
{
|
|
Datas.Add(value);
|
|
}
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public void Add(int barSplitTimes, int barCount, int tickCount)
|
|
{
|
|
Datas.Add((barCount + tickCount / (float)barSplitTimes) * OneBarTime);
|
|
}
|
|
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public float At(int index)
|
|
{
|
|
if (index < 0)
|
|
index = Datas.Count + index;
|
|
if (index < 0 || index >= Datas.Count)
|
|
throw new IndexOutOfRangeException($"{index} is out of [0, {Datas.Count})");
|
|
return Datas[index];
|
|
}
|
|
|
|
/// <summary>
|
|
/// »ñÈ¡Êý¾Ý³¤¶È
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Convention.RScript.Variable.Attr.Method]
|
|
public int GetCount()
|
|
{
|
|
return Datas.Count;
|
|
}
|
|
|
|
public IEnumerator<float> GetEnumerator()
|
|
{
|
|
return ((IEnumerable<float>)Datas).GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return ((IEnumerable)Datas).GetEnumerator();
|
|
}
|
|
|
|
public int Count => Datas.Count;
|
|
}
|
|
}
|