本文整理汇总了C++中PlayerState::IsGoalie方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::IsGoalie方法的具体用法?C++ PlayerState::IsGoalie怎么用?C++ PlayerState::IsGoalie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerState
的用法示例。
在下文中一共展示了PlayerState::IsGoalie方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CycleNeedToPointWithCertainPosture
/**
* player 以确定得姿势(指倒着跑和正跑),跑到 target 所需要的周期数
* This function returns the minimum cycles for a player to go to a target position with
* a certain posture, forward or backward.
* @param player the player to caculate.
* @param target the target position to go to.
* @param inverse true means running backwards.
* @param buffer
* @return an integer to show the minimum cycles caculated.
*/
int Dasher::CycleNeedToPointWithCertainPosture(const PlayerState & player, Vector target, const bool inverse, double *buf)
{
int cycle = 0; //用的周期
const double & decay = player.GetPlayerDecay();
const double & speedmax = player.GetEffectiveSpeedMax();
const double & stamina = player.GetStamina();
const double & stamina_inc_max = player.GetStaminaIncMax();
const double & dash_max = ServerParam::instance().maxDashPower();
const Vector & pos = player.GetPos();
const Vector & vel = player.GetVel();
const double accrate = player.GetDashPowerRate() * player.GetEffort();
double speed = vel.Mod();
const Vector predict_pos_1 = pos + vel;
const Vector predict_pos_2 = predict_pos_1 + vel * decay;
const double dir = (target - pos).Dir();
double dis = (target - predict_pos_1).Mod();
const double kick_area = player.IsGoalie()? ServerParam::instance().catchAreaLength(): (player.GetKickableArea() - GETBALL_BUFFER);
if (dis <= kick_area){
dis = pos.Dist(target);
if (buf) *buf = 0;
return 1;
}
double facing;
if (player.IsBodyDirValid()) {
facing = player.GetBodyDir();
}
else if (speed > 0.26){
facing = vel.Dir();
}
else {
facing = dir; //认为不用转身
}
double diffang = fabs(GetNormalizeAngleDeg(dir - facing));
const double oneturnang = player.GetMaxTurnAngle();
const double stamina_recovery_thr = ServerParam::instance().recoverDecThr() * ServerParam::instance().staminaMax();
double angbuf = FLOAT_EPS;
angbuf = ASin(kick_area / dis);
angbuf = Max(angbuf , 15.0);
if (inverse) {
diffang = 180.0 - diffang;
facing = GetNormalizeAngleDeg(180.0 + facing);
}
//I 调整阶段
if(diffang <= angbuf){ //不需要转身
target = (target - pos).Rotate(-facing);
dis = fabs(target.X());
double y = fabs(target.Y());
if(y < kick_area){
dis -= sqrt(kick_area * kick_area - y * y);
}
speed *= Cos(vel.Dir() - facing); //身体方向上的投影
}
else if(diffang <= oneturnang){
cycle += 1;
target -= predict_pos_1;
speed *= Cos(vel.Dir() - dir); //取得目标方向的投影
speed *= decay;//进行投影.垂直方向1个周期后衰减到10+厘米了,并且在1turn时可加入考虑修正掉
dis = target.Mod();
dis -= kick_area;
}
else{ //认为转身两下(不细致)
cycle += 2;
target -= predict_pos_2;
speed *= Cos(vel.Dir() - dir); //取得目标方向的投影
speed *= decay * decay;//进行投影.垂直方向1个周期后衰减到10+厘米了,并且在1turn时可加入考虑修正掉
dis = target.Mod();
dis -= kick_area;
}
if (dis <= 0){
if(buf != NULL){
*buf = -dis / ( speed / decay);
*buf = Min(*buf , 0.99);
}
return Max(cycle, 0);
}
//II 加速 & 消耗体力阶段
const double stamina_used_per_cycle = inverse? dash_max * 2.0: dash_max;
const int full_cyc = int((stamina - stamina_recovery_thr) / (stamina_used_per_cycle - stamina_inc_max)); //满体力阶段
//.........这里部分代码省略.........