public void MoveTo( int x , int y ) { TarPos = new iVec2 (x, y); //TarPos.X = x; //TarPos.Y = y; if (TarPos.Collision (Loc)) { // this case won't trig move end event. return; } if (pathfind != null) { PathList = pathfind; pathfind = null; } else { PathList = Panel_StageUI.Instance.PathFinding( this , Loc , TarPos ); // ensure we can reach if( PathList == null ) // move direct if no path can find { PathList = GameScene.Instance.Grids.GetPathList (Loc, TarPos); } } MoveNextPoint(); }
// v = 目的座標, E 的敵方座標 public bool ZocCheck(iVec2 C, iVec2 E ) { // it wont zoc if the same point if( Collision( C ) || Collision( E ) || C.Collision(E)) return false; //距離短的的絕不會是 ZOC int distc = Dist (C); int diste = Dist (E); if ( distc <= diste ) return false; // 座標在相對45度以上 不會是ZOC double ang1 = GetAngleFromTwoPoint(C, E); ; if ( Math.Abs( ang1 ) > 26 ) // 45 is too large ... return false; // 由目標點夾角判斷。這邊不知道對不對 // double ang = C.GetAngleFromTwoPoint(this, E); // Math.Atan2(sin, cos) * (180 / Math.PI); // // // ang = Math.Abs( ang ); // // if (ang > 180) // { // ang = 360 - ang; // } // return ang < 40; return true; }