public static int AttackDistance(UnitBase from, UnitBase to) //计算攻击需要的距离 { if (from == null || to == null) { return(-1); } int cnt = 0; int fromY = from.GetPosition().Position.y; int toY = to.GetPosition().Position.y; if (fromY > toY) { TheGameCommon.Common.Swap(ref fromY, ref toY); } //foreach (var i in GameGlobal.Getinstance().GameMain.GridSystem.RowCounter) // Debug.Log(i); for (int i = fromY; i <= toY; i++) { if (GameGlobal.Get().GameMain.GridSystem.RowCounter[i] > 0) { cnt++; } } return(cnt); }