2021-01-11 08:54:28 +08:00
|
|
|
|
/************************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 - 2021 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/************************************************/
|
2020-07-06 08:41:28 +08:00
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// Vessel component for liquid chart. There can be multiple vessels in a Chart, which can be matched by vesselIndex in Serie.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// <para>
|
|
|
|
|
|
/// 容器组件。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// 一般用于LiquidChart。一个Chart中可以有多个Vessel,Serie中用vesselIndex来对应。
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </para>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class Vessel : MainComponent
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum Shape
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 圆形
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Circle,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 正方形。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Rect,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 三角形。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Triangle,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 菱形。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
Diamond,
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 不显示标记。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
None,
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] private bool m_Show = true;
|
|
|
|
|
|
[SerializeField] private Shape m_Shape = Shape.Circle;
|
|
|
|
|
|
[SerializeField] private float m_ShapeWidth = 5f;
|
|
|
|
|
|
[SerializeField] private float m_Gap = 10f;
|
2020-08-23 14:31:26 +08:00
|
|
|
|
[SerializeField] private Color32 m_Color;
|
|
|
|
|
|
[SerializeField] private Color32 m_BackgroundColor;
|
2020-07-06 08:41:28 +08:00
|
|
|
|
[SerializeField] private bool m_AutoColor = true;
|
|
|
|
|
|
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
|
|
|
|
|
[SerializeField] private float m_Radius = 0.5f;
|
|
|
|
|
|
[SerializeField] [Range(0.5f, 10f)] private float m_Smoothness = 1f;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// Whether to show the vessel.
|
|
|
|
|
|
/// 是否显示容器组件。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [defaut: true]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool show
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Show; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// The shape of vessel.
|
|
|
|
|
|
/// 容器形状。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default: Shape.Circle]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Shape shape
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Shape; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-07 06:53:02 +08:00
|
|
|
|
/// Thickness of vessel.
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// 容器厚度。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [defaut: 5f]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float shapeWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_ShapeWidth; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-07 06:53:02 +08:00
|
|
|
|
/// The gap between the vessel and the liquid.
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// 间隙。容器和液体的间隙。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [defaut: 10f]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float gap
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Gap; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// The center of vesselß. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
|
|
|
|
|
|
/// When value between 0 and 1 represents a percentage relative to the chart.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// 中心点。数组的第一项是横坐标,第二项是纵坐标。
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// 当值为0-1之间时表示百分比,设置成百分比时表示图表宽高最小值的百分比。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default:[0.5f,0.45f]]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float[] center
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Center; }
|
|
|
|
|
|
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// The radius of vessel.
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// When value between 0 and 1 represents a percentage relative to the chart.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// 半径。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default: 0.35f]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float radius
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Radius; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-06 09:09:24 +08:00
|
|
|
|
/// The smoothness of wave.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// 水波平滑度。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default: 1f]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float smoothness
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_Smoothness; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Background color of polar, which is transparent by default.
|
|
|
|
|
|
/// 背景色,默认透明。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default: `Color.clear`]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
2020-08-23 14:31:26 +08:00
|
|
|
|
public Color32 backgroundColor
|
2020-07-06 08:41:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
get { return m_BackgroundColor; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// Vessel color. The default is consistent with Serie.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// 容器颜色。默认和serie一致。
|
|
|
|
|
|
/// </summary>
|
2020-08-23 14:31:26 +08:00
|
|
|
|
public Color32 color
|
2020-07-06 08:41:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
get { return m_Color; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// Whether automatic color. If true, the color matches serie.
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// 是否自动颜色。为true时颜色会和serie一致。
|
2020-07-15 09:11:35 +08:00
|
|
|
|
/// [default: true]
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool autoColor
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return m_AutoColor; }
|
2021-01-11 08:54:28 +08:00
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
|
2020-07-06 08:41:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
public int index { get; internal set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the runtime center position of vessel.
|
|
|
|
|
|
/// 运行时中心点。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Vector3 runtimeCenterPos { get; internal set; }
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// the runtime radius of vessel.
|
|
|
|
|
|
/// 运行时半径。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float runtimeRadius { get; internal set; }
|
|
|
|
|
|
/// <summary>
|
2020-07-07 06:53:02 +08:00
|
|
|
|
/// The actual radius after deducting shapeWidth and gap.
|
|
|
|
|
|
/// 运行时内半径。扣除厚度和间隙后的实际半径。
|
2020-07-06 08:41:28 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float runtimeInnerRadius { get; internal set; }
|
|
|
|
|
|
public static Vessel defaultVessel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var vessel = new Vessel
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Show = true,
|
|
|
|
|
|
m_Shape = Shape.Circle,
|
|
|
|
|
|
m_ShapeWidth = 5,
|
|
|
|
|
|
m_Gap = 10,
|
|
|
|
|
|
m_Radius = 0.35f,
|
|
|
|
|
|
m_AutoColor = true,
|
|
|
|
|
|
m_Color = new Color32(70, 70, 240, 255),
|
|
|
|
|
|
m_Smoothness = 1
|
|
|
|
|
|
};
|
|
|
|
|
|
vessel.center[0] = 0.5f;
|
|
|
|
|
|
vessel.center[1] = 0.45f;
|
|
|
|
|
|
return vessel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|