public OrderMoveCircle ( Vector2 aimPos, float moveVel, IAIOrderServer orderServer, ActionFinishHandler finishHandler, bool stopCallFinish ) { this.orderServer = orderServer; moveVel = Math.Min( Math.Max( -orderServer.MaxBackwardSpeed, moveVel ), orderServer.MaxForwardSpeed ); Vector2 direction = orderServer.Direction; Line curVertice = MathTools.VerticeLine( new Line( orderServer.Pos, direction ), orderServer.Pos ); Line midVertice = MathTools.MidVerLine( orderServer.Pos, aimPos ); Vector2 center; if (!MathTools.InterPoint( curVertice, midVertice, out center )) { this.moveVel = moveVel; this.rotaVel = 0; float forward = Vector2.Dot( direction, aimPos - orderServer.Pos ); this.length = Vector2.Distance( aimPos, orderServer.Pos ) * Math.Sign( forward ); } else { float radius = Vector2.Distance( center, orderServer.Pos ); float turnRight = MathTools.Vector2Cross( direction, aimPos - orderServer.Pos ); if (orderServer.MaxRotaSpeed * radius < Math.Abs( moveVel )) { this.moveVel = orderServer.MaxRotaSpeed * radius; this.rotaVel = orderServer.MaxRotaSpeed * Math.Sign( turnRight ); } else { this.moveVel = moveVel; this.rotaVel = moveVel / radius * Math.Sign( turnRight ); } float ang = MathTools.AngBetweenVectors( orderServer.Pos - center, aimPos - center ); bool inFront = Vector2.Dot( direction, aimPos - orderServer.Pos ) >= 0; if (moveVel > 0) { if (inFront) { this.length = ang * radius; } else { this.length = (2 * MathHelper.Pi - ang) * radius; } } else { if (inFront) { this.length = -(2 * MathHelper.Pi - ang) * radius; } else { this.length = -ang * radius; } } } this.finishHandler = finishHandler; this.stopCallFinish = stopCallFinish; }
public AIActionHelper ( IAIOrderServer orderServer ) { this.orderServer = orderServer; }
public ConsiderCenter(IAIOrderServer orderServer) { considers = new List <ConsiderWithPRI>(); this.orderServer = orderServer; }