136 lines
2.9 KiB
C#
136 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public class value_class2
|
|
{
|
|
public List<float> value;
|
|
|
|
public List<float> select_value;
|
|
|
|
public List<bool> active;
|
|
|
|
public List<string> text;
|
|
|
|
public float value_total;
|
|
|
|
public int active_total;
|
|
|
|
public AnimationCurve curve;
|
|
|
|
public animation_curve_math_class animation_curve_math;
|
|
|
|
public value_class2()
|
|
{
|
|
value = new List<float>();
|
|
select_value = new List<float>();
|
|
active = new List<bool>();
|
|
text = new List<string>();
|
|
curve = new AnimationCurve();
|
|
animation_curve_math = new animation_curve_math_class();
|
|
}
|
|
|
|
public virtual void calc_value()
|
|
{
|
|
if (select_value.Count < value.Count)
|
|
{
|
|
select_value_init();
|
|
}
|
|
value_total = 0f;
|
|
active_total = 0;
|
|
float num = 0f;
|
|
for (int i = 0; i < value.Count; i++)
|
|
{
|
|
if (active[i])
|
|
{
|
|
value_total += value[i];
|
|
active_total++;
|
|
}
|
|
}
|
|
Keyframe[] array = new Keyframe[active_total + 1];
|
|
int num2 = 0;
|
|
for (int i = 0; i < value.Count; i++)
|
|
{
|
|
if (active[i])
|
|
{
|
|
array[num2].value = 1f / ((float)active_total * 1f) * (float)(num2 + 1);
|
|
array[num2].time = num + value[i] / value_total;
|
|
select_value[i] = (num * 2f + value[i] / value_total) / 2f;
|
|
text[i] = "(V " + num.ToString("F2") + "-" + array[num2].time.ToString("F2") + ")";
|
|
num = array[num2].time;
|
|
num2++;
|
|
}
|
|
else
|
|
{
|
|
text[i] = "(V - )";
|
|
}
|
|
}
|
|
curve = animation_curve_math.set_curve_linear(new AnimationCurve(array));
|
|
}
|
|
|
|
public virtual void add_value(int value_index, float number)
|
|
{
|
|
if (select_value.Count < value.Count)
|
|
{
|
|
int num = value.Count - select_value.Count;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
select_value.Add(0f);
|
|
}
|
|
}
|
|
value.Insert(value_index, number);
|
|
select_value.Insert(value_index, 0f);
|
|
text.Insert(value_index, string.Empty);
|
|
active.Insert(value_index, true);
|
|
calc_value();
|
|
}
|
|
|
|
public virtual void erase_value(int value_index)
|
|
{
|
|
value.RemoveAt(value_index);
|
|
if (value_index < select_value.Count)
|
|
{
|
|
select_value.RemoveAt(value_index);
|
|
}
|
|
text.RemoveAt(value_index);
|
|
active.RemoveAt(value_index);
|
|
calc_value();
|
|
}
|
|
|
|
public virtual void clear_value()
|
|
{
|
|
value.Clear();
|
|
select_value.Clear();
|
|
text.Clear();
|
|
active.Clear();
|
|
}
|
|
|
|
public virtual void swap_value(int value_number1, int value_number2)
|
|
{
|
|
if (select_value.Count < value.Count)
|
|
{
|
|
select_value_init();
|
|
}
|
|
float num = value[value_number1];
|
|
bool flag = active[value_number1];
|
|
float num2 = select_value[value_number1];
|
|
value[value_number1] = value[value_number2];
|
|
value[value_number2] = num;
|
|
active[value_number1] = active[value_number2];
|
|
active[value_number2] = flag;
|
|
select_value[value_number1] = select_value[value_number2];
|
|
select_value[value_number2] = num2;
|
|
calc_value();
|
|
}
|
|
|
|
public virtual void select_value_init()
|
|
{
|
|
int num = value.Count - select_value.Count;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
select_value.Add(0f);
|
|
}
|
|
}
|
|
}
|