2019-05-11 04:33:54 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[Serializable]
|
|
|
|
|
|
public class Coordinate : IEquatable<Coordinate>
|
|
|
|
|
|
{
|
|
|
|
|
|
[SerializeField] private float m_Left;
|
|
|
|
|
|
[SerializeField] private float m_Right;
|
|
|
|
|
|
[SerializeField] private float m_Top;
|
|
|
|
|
|
[SerializeField] private float m_Bottom;
|
|
|
|
|
|
[SerializeField] private float m_Tickness;
|
|
|
|
|
|
[SerializeField] private int m_FontSize;
|
|
|
|
|
|
|
|
|
|
|
|
public float left { get { return m_Left; } set { m_Left = value; } }
|
|
|
|
|
|
public float right { get { return m_Right; } set { m_Right = value; } }
|
|
|
|
|
|
public float top { get { return m_Top; } set { m_Top = value; } }
|
|
|
|
|
|
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
|
|
|
|
|
|
public float tickness { get { return m_Tickness; } set { m_Tickness = value; } }
|
|
|
|
|
|
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
|
|
|
|
|
|
|
|
|
|
|
public static Coordinate defaultCoordinate
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var coordinate = new Coordinate
|
|
|
|
|
|
{
|
2019-07-15 00:24:04 +08:00
|
|
|
|
m_Left = 50,
|
|
|
|
|
|
m_Right = 30,
|
2019-07-15 19:21:22 +08:00
|
|
|
|
m_Top = 50,
|
2019-07-15 00:24:04 +08:00
|
|
|
|
m_Bottom = 30,
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_Tickness = 0.6f,
|
|
|
|
|
|
m_FontSize = 16,
|
|
|
|
|
|
};
|
|
|
|
|
|
return coordinate;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Copy(Coordinate other)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_Left = other.left;
|
|
|
|
|
|
m_Right = other.right;
|
|
|
|
|
|
m_Top = other.top;
|
|
|
|
|
|
m_Bottom = other.bottom;
|
|
|
|
|
|
m_Tickness = other.tickness;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(null, obj))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is Coordinate)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Equals((Coordinate)obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(Coordinate other)
|
|
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
return m_Left == other.left &&
|
|
|
|
|
|
m_Right == other.right &&
|
|
|
|
|
|
m_Top == other.top &&
|
|
|
|
|
|
m_Bottom == other.bottom &&
|
|
|
|
|
|
m_Tickness == other.tickness &&
|
|
|
|
|
|
m_FontSize == other.fontSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-17 04:29:19 +08:00
|
|
|
|
public static bool operator ==(Coordinate left, Coordinate right)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return Equals(left, right);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-06-17 04:29:19 +08:00
|
|
|
|
public static bool operator !=(Coordinate left, Coordinate right)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-06-17 04:29:19 +08:00
|
|
|
|
return !(left == right);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|