//--------------------- //选择地图内的 随机位置 Vector2 SelectFreeTargetPos() { Vector2 pos = Maths.RndVector() * BattleScene.Heigth; BattleScene.SceneSizeLimit(ref pos); return(pos); }
//不攻击了,没有武器 或者 投降了 void StopAttck() { //缓慢惯性移动 this.SetPosition(this.GetPosition() + NowDirection * inertiaSpeed * 0.15f); if (BattleScene.SceneSizeLimit(this.GetPosition())) { //出界就自动回来。 Vector2 returnDir = Vector2.Zero - this.GetPosition(); Maths.Normalize(ref returnDir); TrackPos(this.GetPosition() + returnDir * 180f); } }
//选择要去的目标位置. void SelectTargetPos() { if (LockShip != null && TrackAction.IsTracking == false) { Vector2 targetDir = LockShip.GetPosition() - this.GetPosition(); targetDir = new Vector2(targetDir.Y, -targetDir.X); Maths.Normalize(ref targetDir); //根据0~180的随机角度旋转targetDir targetDir.TurnTo(targetDir, Maths.Rnd.Next(314) * 0.01f); targetDir = targetDir * keepDisFromEnemy + LockShip.GetPosition(); BattleScene.SceneSizeLimit(ref targetDir); TrackPos(targetDir); } }
//----------------- //惯性移动 void InertiaMove() { if (TrackAction.IsTracking == false) { this.SetPosition(this.GetPosition() + NowDirection * inertiaSpeed); if (BattleScene.SceneSizeLimit(this.GetPosition())) { //出界就自动回来。 if (LockShip == null) { Vector2 returnDir = Vector2.Zero - this.GetPosition(); Maths.Normalize(ref returnDir); TrackPos(this.GetPosition() + returnDir * 180f); } } } }