本文整理汇总了C++中MapInfo::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ MapInfo::Init方法的具体用法?C++ MapInfo::Init怎么用?C++ MapInfo::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapInfo
的用法示例。
在下文中一共展示了MapInfo::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartAttack
int CPlayer::StartAttack( CPlayer* pDefender )
{
int destroyCount = 0;
int hitCount = 0;
int turn = 0;
int maxTurn = MAP_SIZE * MAP_SIZE;
Position attackPosition = {0, };
HitResult result = MISS;
MapInfo mapInfo;
char string[255] = {0, };
m_MyMap.InitMapInfo(MI_All);
InitGuessShipState();
while(turn < maxTurn)
{
mapInfo.Init();
++turn;
m_MyMap.InitMapInfo(MI_Probability);
#ifdef TEST_FLAG
// 공격 결과 출력
sprintf_s(string, " ");
CUIManager::GetInstance()->BroadCast(string);
m_MyMap.DisplayMap(MI_HitResult);
#endif
// 확률 계산
CalculateProbability();
// 최대값 찾기
attackPosition = GetBestPosition();
result = pDefender->HitCheck(attackPosition);
#ifdef TEST_FLAG
sprintf_s(string, " Attack Position : ( %c , %c ) ", attackPosition.x, attackPosition.y);
CUIManager::GetInstance()->BroadCast(string);
#endif
switch (result)
{
case MISS:
#ifdef TEST_FLAG
sprintf_s(string, " Miss! - Turn : %d", turn);
CUIManager::GetInstance()->BroadCast(string);
sprintf_s(string, " - Hit : %d, Destroy : %d", hitCount, destroyCount);
CUIManager::GetInstance()->BroadCast(string);
#endif
mapInfo.type = MI_HitResult;
mapInfo.value.hitResult = MISS;
m_MyMap.SetMapInfo(attackPosition, mapInfo);
break;
case HIT:
++hitCount;
#ifdef TEST_FLAG
sprintf_s(string, " Hit ! - Turn : %d", turn);
CUIManager::GetInstance()->BroadCast(string);
sprintf_s(string, " - Hit : %d, Destroy : %d", hitCount, destroyCount);
CUIManager::GetInstance()->BroadCast(string);
#endif
mapInfo.type = MI_HitResult;
mapInfo.value.hitResult = HIT;
m_MyMap.SetMapInfo(attackPosition, mapInfo);
break;
case DESTROY_AIRCRAFT:
case DESTROY_BATTLESHIP:
case DESTROY_CRUISER:
case DESTROY_DESTROYER:
case DESTROY_SUBMARINE:
mapInfo.type = MI_HitResult;
mapInfo.value.hitResult = HIT;
m_MyMap.SetMapInfo(attackPosition, mapInfo);
#ifdef TEST_FLAG
sprintf_s(string, " Destroy!!! - Turn : %d", turn);
CUIManager::GetInstance()->BroadCast(string);
sprintf_s(string, " - Hit : %d, Destroy : %d", hitCount, destroyCount);
CUIManager::GetInstance()->BroadCast(string);
#endif
// 터진 배 추측
GuessDestroyedShip(result, attackPosition);
++hitCount;
++destroyCount;
if(destroyCount >= sizeof(m_Ships) / sizeof(m_Ships[0]))
{
#ifdef TEST_FLAG
m_MyMap.DisplayMap(MI_Probability, attackPosition.x, attackPosition.y);
pDefender->m_MyMap.DisplayMap(MI_ShipType);
#endif
sprintf_s(string, " Victory !!! Turn : %d", turn);
CUIManager::GetInstance()->BroadCast(string);
#ifdef TEST_FLAG
CUIManager::GetInstance()->Sound(4);
//.........这里部分代码省略.........