本文整理汇总了C++中PlayerState::CorrectDashPowerForStamina方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::CorrectDashPowerForStamina方法的具体用法?C++ PlayerState::CorrectDashPowerForStamina怎么用?C++ PlayerState::CorrectDashPowerForStamina使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerState
的用法示例。
在下文中一共展示了PlayerState::CorrectDashPowerForStamina方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CyclePredictedToPoint
/**
* 计算用同一dash_power到达某点需要的时间
* Caculate cycles needed to a target position with a certain dash power.
* @param player the player to caculate.
* @param target the target position to go to.
* @param dash_power the power for dash to predict.
* @return an integer to show the cycles caculated.
*/
int Dasher::CyclePredictedToPoint(const PlayerState& player , Vector target , double dash_power)
{
double corrected_dash_power = dash_power;
double effective_power;
double predicted_stamina = player.GetStamina();
double predicted_effort = player.GetEffort();
double predicted_recovery = player.GetRecovery();
double predicted_capacity = player.GetCapacity();
double myang = player.GetBodyDir();
Vector position = player.GetPos();
Vector velocity;
if (player.GetVelConf() < FLOAT_EPS)
{
velocity = Vector(0,0);
}
else
{
velocity = player.GetVel();
}
Vector last_position = position;
int max_cyc = (int)(position.Dist(target) / player.GetEffectiveSpeedMax() + 100);
int last_action = 0; /* 0 -- turn , 1 -- dash*/
for (int i = 0;i < max_cyc;i++)
{
if (position.Dist(target) < PlayerParam::instance().AtPointBuffer())
{
return i;
}
if (position.Dist(target) > last_position.Dist(target) + FLOAT_EPS && last_action == 1)
{
return i;
}
last_position = position;
/*decide if we should turn*/
double targ_ang;
if (dash_power > 0)
{
targ_ang = (target - position).Dir() - myang;
}
else
{
targ_ang = (target - position).Dir() - GetNormalizeAngleDeg(myang + 180);
}
double max_go_to_point_angle_err = 4; //见08CP_max_go_to_point_angle_err
if (fabs(GetNormalizeAngleDeg(targ_ang)) > max_go_to_point_angle_err)
{
/*turnint*/
double this_turn = MinMax(-player.GetMaxTurnAngle(), GetNormalizeAngleDeg(targ_ang) , player.GetMaxTurnAngle());
myang += this_turn;
corrected_dash_power = 0;
last_action = 0;
}
else
{
corrected_dash_power = player.CorrectDashPowerForStamina(dash_power);
if (fabs(corrected_dash_power) > predicted_stamina)
{
effective_power = Sign(corrected_dash_power) * predicted_stamina;
}
else
{
effective_power = corrected_dash_power;
}
effective_power *= predicted_effort;
effective_power *= player.GetDashPowerRate();
velocity += Polar2Vector(effective_power , myang);
last_action = 1;
}
if (velocity.Mod() > player.GetEffectiveSpeedMax())
{
velocity *= (player.GetEffectiveSpeedMax()/ velocity.Mod());
}
position += velocity;
velocity *= player.GetPlayerDecay();
//08 内UpdatePredictStaminaWithDash函数 直接写入此函数
if (dash_power > 0)
{
predicted_stamina -= dash_power;
}
else
//.........这里部分代码省略.........