当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerState::GetUnum方法代码示例

本文整理汇总了C++中PlayerState::GetUnum方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::GetUnum方法的具体用法?C++ PlayerState::GetUnum怎么用?C++ PlayerState::GetUnum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerState的用法示例。


在下文中一共展示了PlayerState::GetUnum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetShootAngle

AngleDeg PositionInfo::GetShootAngle(AngleDeg left,AngleDeg right, const PlayerState & state , AngleDeg & interval)
{
	vector< pair<Unum, AngleDeg> > tmp;
	for (vector<PlayerState*>::const_iterator it = mpWorldState->GetPlayerList().begin(); it != mpWorldState->GetPlayerList().end(); ++it){
    if ((*it)->IsAlive() && (*it)->GetPosConf() > FLOAT_EPS && (*it)->GetUnum() != state.GetUnum() &&((*it)->GetPos()-state.GetPos()).Dir() + Rad2Deg(1/10) >left&&((*it)->GetPos()-state.GetPos()).Dir() - Rad2Deg(1/10) <right){//介于左右门柱之间
		tmp.push_back(pair<Unum, AngleDeg>((*it)->GetUnum(), ((*it)->GetPos()-state.GetPos()).Dir()));
	}
	}
	if(tmp.size()!=0){
		sort(tmp.begin(),tmp.end(),PlayerDirCompare());
			vector<pair<int,AngleDeg> > dis;
			int i=0;
	vector<pair<int,AngleDeg> >::const_iterator it;
	for(it = tmp.begin(); it != tmp.end();++it){
			if(i==0){
				dis.push_back(pair<int,AngleDeg>(i++,((*it).second-left/* - Rad2Deg(1/10) - Rad2Deg(1/3)*/)));
				}
			else{
				dis.push_back(pair<int,AngleDeg>(i++,((*it).second-(*(it-1)).second)/*- 2*Rad2Deg(1/10) - Rad2Deg(1/3)*/));
			}
			}
				dis.push_back(pair<int,AngleDeg>(i,(right-(*(it-1)).second)/*- Rad2Deg(1/10) - Rad2Deg(1/3)*/));
		sort(dis.begin(),dis.end(),PlayerDirCompare());

		if(dis.back().first==0){
			interval = dis.back().second-Rad2Deg(1.0/10.0)-Rad2Deg(1.0/4.0);
			return MinMax(left + 1,dis.back().second/2+left-Rad2Deg(1.0/10.0)-Rad2Deg(1.0/4.0),right -1 );
		}
		else if(dis.back().first == i){
			interval = dis.back().second-Rad2Deg(1.0/10.0)-Rad2Deg(1.0/4.0);
			return MinMax(left + 1,right -dis.back().second/2+Rad2Deg(1.0/10.0)+Rad2Deg(1.0/4.0),right -1);
		}
		else{
			interval = dis.back().second  - 2* Rad2Deg(1.0/10.0) - Rad2Deg(1.0/4.0);
			return MinMax(left +1,(*(tmp.begin()+dis.back().first-1)).second + dis.back().second/2 ,right -1);
		}
	}
	else {
		interval = right-left  ;
		return (left+right)/2;
	}
}
开发者ID:RexSkz,项目名称:Walker,代码行数:42,代码来源:PositionInfo.cpp

示例2: MayDangerousIfTackle

bool Tackler::MayDangerousIfTackle(const PlayerState & tackler, const WorldState & world_state)
{
	if (tackler.GetTackleProb(false) < FLOAT_EPS && tackler.GetTackleProb(true) < FLOAT_EPS) { //不可铲
		return false;
	}

	const Vector tackler_pos = tackler.GetPos();
	const Vector ball_pos = world_state.GetBall().GetPos();
	const Vector ball_2_tackler = ball_pos - tackler_pos;
	const double ball_dist2 = ball_2_tackler.Mod2();
	const AngleDeg ball_dir = ball_2_tackler.Dir();

	for (unsigned i = 0; i < world_state.GetPlayerList().size(); ++i) {
		const PlayerState & opp = *world_state.GetPlayerList()[i];

		if (!opp.IsAlive()) continue; //dead
		if (opp.GetUnum() * tackler.GetUnum() > 0) continue; //not opp
		if (opp.IsIdling()) continue; //idling
		if (!opp.IsKickable()) continue; //not kickable

		//cond. 1. opp no dashing -- 无从知晓,这里认为对手一定会dash
		//cond. 2. ball near -- 球离自己更近,不构成危险情况
		Vector opp_2_tackler = opp.GetPos() - tackler_pos;
		if (opp_2_tackler.Mod2() > ball_dist2) continue;
		//cond. 3. behind or big y_diff -- 对手在自己与球连线方向上在自己身后或错开位置太大,不构成危险情况
		opp_2_tackler = opp_2_tackler.Rotate(-ball_dir);
		if (opp_2_tackler.X() < 0.0 || std::fabs( opp_2_tackler.Y() ) > opp.GetPlayerSize() + tackler.GetPlayerSize()) continue;
		//cond. 4. over body_diff -- 对手身体角度跟自己与球连线方向的夹角大于90度,不构成危险情况
		AngleDeg body_diff = std::fabs( GetNormalizeAngleDeg( opp.GetBodyDir() - ball_dir ) );
		if (body_diff > 90.0) continue;

		return true;
	}

	return false;
}
开发者ID:antiphoton,项目名称:wrighteaglebase,代码行数:36,代码来源:Tackler.cpp


注:本文中的PlayerState::GetUnum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。