📄 formations_8c-source.html
字号:
00261 <font class="keywordflow">return</font> <font class="keyword">true</font>;00262 }00263 <a name="l00266"></a><a class="code" href="classFormationTypeInfo.html#a3">00266</a> <a class="code" href="SoccerTypes_8h.html#a249">FormationT</a> <a class="code" href="classFormationTypeInfo.html#a3">FormationTypeInfo::getFormationType</a>( )<font class="keyword"> const</font>00267 <font class="keyword"></font>{00268 <font class="keywordflow">return</font> <a class="code" href="classFormationTypeInfo.html#o0">formationType</a>;00269 }00270 <a name="l00282"></a><a class="code" href="classFormationTypeInfo.html#a1">00282</a> <font class="keywordtype">void</font> <a class="code" href="classFormationTypeInfo.html#a1">FormationTypeInfo::show</a>( ostream &os )00283 {00284 <font class="keywordtype">char</font> str[128];00285 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a0">MAX_TEAMMATES</a>; i++ )00286 {00287 sprintf(str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[i].getX() );00288 os << str;00289 }00290 os << endl;00291 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a0">MAX_TEAMMATES</a>; i++ )00292 {00293 sprintf( str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[i].getY() );00294 os << str;00295 }00296 os << endl;00297 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a0">MAX_TEAMMATES</a>; i++ )00298 {00299 sprintf( str, <font class="stringliteral">"%5d "</font>, (<font class="keywordtype">int</font>)<a class="code" href="classFormationTypeInfo.html#o2">playerType</a>[i] );00300 os << str;00301 }00302 os << endl;00303 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a2">MAX_PLAYER_TYPES</a>; i++ )00304 {00305 sprintf( str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[i].getAttrX() );00306 os << str;00307 }00308 os << endl;00309 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a2">MAX_PLAYER_TYPES</a>; i++ )00310 {00311 sprintf( str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[i].getAttrY() );00312 os << str;00313 }00314 os << endl;00315 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a2">MAX_PLAYER_TYPES</a>; i++ )00316 {00317 sprintf( str, <font class="stringliteral">"%5d "</font>, <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[i].getBehindBall() );00318 os << str;00319 }00320 os << endl;00321 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a2">MAX_PLAYER_TYPES</a>; i++ )00322 {00323 sprintf( str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[i].getMinX() );00324 os << str;00325 }00326 os << endl;00327 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0; i < <a class="code" href="SoccerTypes_8h.html#a2">MAX_PLAYER_TYPES</a>; i++ )00328 {00329 sprintf( str, <font class="stringliteral">"%3.2f "</font>, <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[i].getMaxX() );00330 os << str;00331 }00332 os << endl;00333 }00334 00335 <a name="l00344"></a><a class="code" href="classFormationTypeInfo.html#a4">00344</a> <font class="keywordtype">bool</font> <a class="code" href="classFormationTypeInfo.html#a4">FormationTypeInfo::setPosHome</a>( <a class="code" href="classVecPosition.html">VecPosition</a> pos, <font class="keywordtype">int</font> atIndex )00345 {00346 <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[ atIndex ] = pos;00347 <font class="keywordflow">return</font> <font class="keyword">true</font>;00348 }00349 <a name="l00355"></a><a class="code" href="classFormationTypeInfo.html#a5">00355</a> <font class="keywordtype">bool</font> <a class="code" href="classFormationTypeInfo.html#a5">FormationTypeInfo::setXPosHome</a>( <font class="keywordtype">double</font> x, <font class="keywordtype">int</font> atIndex )00356 {00357 <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[ atIndex ].<a class="code" href="classVecPosition.html#a25">setX</a>( x );00358 <font class="keywordflow">return</font> <font class="keyword">true</font>;00359 }00360 <a name="l00366"></a><a class="code" href="classFormationTypeInfo.html#a6">00366</a> <font class="keywordtype">bool</font> <a class="code" href="classFormationTypeInfo.html#a6">FormationTypeInfo::setYPosHome</a>( <font class="keywordtype">double</font> y, <font class="keywordtype">int</font> atIndex )00367 {00368 <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[ atIndex ].<a class="code" href="classVecPosition.html#a27">setY</a>( y );00369 <font class="keywordflow">return</font> <font class="keyword">true</font>;00370 }00371 <a name="l00377"></a><a class="code" href="classFormationTypeInfo.html#a7">00377</a> <a class="code" href="classVecPosition.html">VecPosition</a> <a class="code" href="classFormationTypeInfo.html#a7">FormationTypeInfo::getPosHome</a>( <font class="keywordtype">int</font> atIndex )<font class="keyword"> const</font>00378 <font class="keyword"></font>{00379 <font class="keywordflow">return</font> <a class="code" href="classFormationTypeInfo.html#o1">posHome</a>[ atIndex ];00380 }00381 <a name="l00387"></a><a class="code" href="classFormationTypeInfo.html#a8">00387</a> <font class="keywordtype">bool</font> <a class="code" href="classFormationTypeInfo.html#a8">FormationTypeInfo::setPlayerType</a>( <a class="code" href="SoccerTypes_8h.html#a248">PlayerT</a> type, <font class="keywordtype">int</font> atIndex )00388 {00389 <a class="code" href="classFormationTypeInfo.html#o2">playerType</a>[ atIndex ] = type;00390 <font class="keywordflow">return</font> <font class="keyword">true</font>;00391 }00392 <a name="l00396"></a><a class="code" href="classFormationTypeInfo.html#a9">00396</a> <a class="code" href="SoccerTypes_8h.html#a248">PlayerT</a> <a class="code" href="classFormationTypeInfo.html#a9">FormationTypeInfo::getPlayerType</a>( <font class="keywordtype">int</font> atIndex )<font class="keyword"> const</font>00397 <font class="keyword"></font>{00398 <font class="keywordflow">return</font> <a class="code" href="classFormationTypeInfo.html#o2">playerType</a>[ atIndex ];00399 }00400 <a name="l00406"></a><a class="code" href="classFormationTypeInfo.html#a10">00406</a> <font class="keywordtype">bool</font> <a class="code" href="classFormationTypeInfo.html#a10">FormationTypeInfo::setPlayerTypeInfo</a>( <a class="code" href="classPlayerTypeInfo.html">PlayerTypeInfo</a> info, <font class="keywordtype">int</font> atIndex )00407 {00408 <a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[ atIndex ] = info;00409 <font class="keywordflow">return</font> <font class="keyword">true</font>;00410 }00411 <a name="l00416"></a><a class="code" href="classFormationTypeInfo.html#a11">00416</a> <a class="code" href="classPlayerTypeInfo.html">PlayerTypeInfo</a>* <a class="code" href="classFormationTypeInfo.html#a11">FormationTypeInfo::getPlayerTypeInfo</a>( <font class="keywordtype">int</font> atIndex )00417 {00418 <font class="keywordflow">return</font> &<a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[ atIndex ];00419 }00420 00421 <a name="l00426"></a><a class="code" href="classFormationTypeInfo.html#a12">00426</a> <a class="code" href="classPlayerTypeInfo.html">PlayerTypeInfo</a>* <a class="code" href="classFormationTypeInfo.html#a12">FormationTypeInfo::getPlayerTypeInfoOfPlayer</a>(00427 <font class="keywordtype">int</font> iPlayerInFormation )00428 {00429 <font class="keywordflow">return</font> &<a class="code" href="classFormationTypeInfo.html#o3">playerTypeInfo</a>[ <a class="code" href="classFormationTypeInfo.html#o2">playerType</a>[iPlayerInFormation] ];00430 }00431 00432 <font class="comment">/******************************************************************************/</font>00433 <font class="comment">/********************** CLASS FORMATIONS **************************************/</font>00434 <font class="comment">/******************************************************************************/</font>00435 <a name="l00443"></a><a class="code" href="classFormations.html#a0">00443</a> <a class="code" href="classFormations.html#a0">Formations::Formations</a>( <font class="keyword">const</font> <font class="keywordtype">char</font> *strFile, <a class="code" href="SoccerTypes_8h.html#a249">FormationT</a> curFt, <font class="keywordtype">int</font> iNr )00444 {00445 <font class="keywordflow">if</font>( strFile == NULL )00446 {00447 cerr << <font class="stringliteral">"(Formations::Formations) No Filename given"</font> << endl;00448 <font class="keywordflow">return</font>;00449 }00450 00451 <font class="keywordflow">if</font>( <a class="code" href="classFormations.html#a3">readFormations</a>( strFile ) == <font class="keyword">false</font> )00452 cerr << <font class="stringliteral">"(Formations::Formations) Error reading file"</font> << endl;00453 <a class="code" href="classFormations.html#o1">curFormation</a> = curFt;00454 <a class="code" href="classFormations.html#a6">setPlayerInFormation</a>( iNr );00455 }00456 <a name="l00461"></a><a class="code" href="classFormations.html#a1">00461</a> <font class="keywordtype">void</font> <a class="code" href="classFormations.html#a1">Formations::show</a>( ostream &os )00462 {00463 <font class="keywordflow">for</font>( <font class="keywordtype">int</font> i = 0 ; i < <a class="code" href="SoccerTypes_8h.html#a3">MAX_FORMATION_TYPES</a>; i ++ )00464 <a class="code" href="classFormations.html#o0">formations</a>[i].<a class="code" href="classFormationTypeInfo.html#a1">show</a>( os );00465 os << <font class="stringliteral">"Current formation: "</font> << (int)<a class="code" href="classFormations.html#o1">curFormation</a> << endl00466 << <font class="stringliteral">"Player nr in formation: "</font> << <a class="code" href="classFormations.html#o2">iPlayerInFormation</a> ;00467 }00468 <a name="l00488"></a><a class="code" href="classFormations.html#a2">00488</a> <a class="code" href="classVecPosition.html">VecPosition</a> <a class="code" href="classFormations.html#a2">Formations::getStrategicPosition</a>( <font class="keywordtype">int</font> iPlayer, <a class="code" href="classVecPosition.html">VecPosition</a> posBall,00489 <font class="keywordtype">double</font> dMaxXInPlayMode )00490 {00491 <a class="code" href="classVecPosition.html">VecPosition</a> posHome;00492 <a class="code" href="classPlayerTypeInfo.html">PlayerTypeInfo</a>* ptInfo = <a class="code" href="classFormations.html#o0">formations</a>[<a class="code" href="classFormations.html#o1">curFormation</a>].00493 getPlayerTypeInfoOfPlayer( iPlayer );00494 <font class="keywordtype">double</font> x, y;00495 00496 <font class="comment">// get the home position and calculate the associated strategic position</font>00497 posHome = formations[<a class="code" href="classFormations.html#o1">curFormation</a>].getPosHome( iPlayer );00498 y = posHome.<a class="code" href="classVecPosition.html#a28">getY</a>() + posBall.<a class="code" href="classVecPosition.html#a28">getY</a>() * ptInfo-><a class="code" href="classPlayerTypeInfo.html#a9">getAttrY</a>();00499 x = posHome.<a class="code" href="classVecPosition.html#a26">getX</a>() + posBall.<a class="code" href="classVecPosition.html#a26">getX</a>() * ptInfo-><a class="code" href="classPlayerTypeInfo.html#a7">getAttrX</a>();00500 00501 <font class="comment">// do not move to much to the side</font>00502 <font class="keywordflow">if</font>( fabs( y ) > 0.5*0.75*<a class="code" href="SoccerTypes_8h.html#a14">PITCH_WIDTH</a> )00503 y -= 0.5*posBall.<a class="code" href="classVecPosition.html#a28">getY</a>() * ptInfo-><a class="code" href="classPlayerTypeInfo.html#a9">getAttrY</a>();00504 00505 <font class="comment">// when behind ball is set, do not move to point in front of ball</font>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -