public Vector2 Calculate(Arma arma, float secs) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { alvo = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); } Vector2 desired = alvo - arma.getPosition(); desired = Vector2.Normalize(desired) * arma.getMaxVelocidade(); return(desired - arma.getVelocidade()); }
public Vector2 Calculate(Arma arma, float secs, Vector2 target) { if (Vector2.Distance(arma.getPosition(), target) > panic) { return(new Vector2()); } Vector2 desired = arma.getPosition() - target; desired = Vector2.Normalize(desired) * arma.getMaxVelocidade(); return(desired - arma.getVelocidade()); }
public Vector2 Calcularpursuit(Arma arma, float secs) { Vector2 toTarget = alvo.getPosition() - arma.getPosition(); float relative = Vector2.Dot(arma.getDirecao(), alvo.getDirecao()); if (Vector2.Dot(toTarget, arma.getDirecao()) > 0 && relative < -0.95) { return(new BehaviorSeek(alvo.getPosition()).Calculate(arma, secs)); } float lookAheadTime = toTarget.Length() / (arma.getMaxVelocidade() + alvo.getVelocidade().Length()); return(new BehaviorSeek(alvo.getPosition() + alvo.getVelocidade() * lookAheadTime).Calculate(arma, secs)); }