|
- using System;
- using UnityEngine;
-
- namespace SUISSEngine
- {
- [Serializable]
- public struct GridIndex
- {
- public GridIndex(int u, int v)
- {
- this.u = u;
- this.v = v;
- }
-
- public GridIndex(GridPoint point)
- {
- this.u = Mathf.RoundToInt(point.u);
- this.v = Mathf.RoundToInt(point.v);
- }
-
- public static GridIndex invalid
- {
- get
- {
- return new GridIndex(-1, -1);
- }
- }
-
- public bool isInvalid
- {
- get
- {
- return this.u < 0 || this.v < 0;
- }
- }
-
- public override string ToString()
- {
- return string.Format("({0},{1})", this.u, this.v);
- }
-
- public override int GetHashCode()
- {
- return this.u + 1000 * this.v;
- }
-
- public override bool Equals(object obj)
- {
- if (obj is GridIndex)
- {
- GridIndex gridIndex = (GridIndex)obj;
- return gridIndex.u == this.u && gridIndex.v == this.v;
- }
- return base.Equals(obj);
- }
-
- public int u;
-
- public int v;
- }
- }
|