本文整理汇总了C++中Aircraft::HitCheck方法的典型用法代码示例。如果您正苦于以下问题:C++ Aircraft::HitCheck方法的具体用法?C++ Aircraft::HitCheck怎么用?C++ Aircraft::HitCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aircraft
的用法示例。
在下文中一共展示了Aircraft::HitCheck方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HitCheck
AttackResult Player::HitCheck(Position pos)
{
// Draw picaso;
for (int i = 0; i < m_MyShip.size(); ++i)
{
AttackResult result = AR_NONE;
MapDataTypes shipType = m_MyShip[i]->GetShipType();
//각각 배로 타입 변환하여 hitcheck
if (shipType == MD_AIRCRAFT)
{
Aircraft* aircraft = (Aircraft*)m_MyShip[i];
result = aircraft->HitCheck(pos);
}
else if (shipType == MD_BATTLESHIP)
{
BattleShip_* battleship = (BattleShip_*)m_MyShip[i];
result = battleship->HitCheck(pos);
}
else if (shipType == MD_CRUISER)
{
Cruiser* cruiser = (Cruiser*)m_MyShip[i];
result = cruiser->HitCheck(pos);
}
else if(shipType == MD_DESTROYER1 || shipType == MD_DESTROYER2)
{
Destroyer* destroyer = (Destroyer*)m_MyShip[i];
result = destroyer->HitCheck(pos);
}
//hit나 destroy 인 경우
switch (result)
{
case AR_HIT:
printf_s("HIT\n");
m_MyMap.ChangeStatusMap(pos, MAP_HIT);
break;
case AR_DESTROY_AIRCRAFT:
m_MyMap.ChangeStatusMap(pos, MAP_DESTROY);
printf_s("AIRCREFT DESTROY\n");
break;
case AR_DESTROY_BATTLESHIP:
m_MyMap.ChangeStatusMap(pos, MAP_DESTROY);
printf_s("BATTLESHIP DESTROY\n");
break;
case AR_DESTROY_CRUISER:
m_MyMap.ChangeStatusMap(pos, MAP_DESTROY);
printf_s("CRUISER DESTROY\n");
break;
case AR_DESTROY_DESTROYER:
m_MyMap.ChangeStatusMap(pos, MAP_DESTROY);
printf_s("DESTROYER DESTROY\n");
break;
default:
break;
}
//miss가 아닌 경우 바로 리턴
if (result != AR_MISS)
{
return result;
}
}
//반복문을 빠져 나오면 miss인 경우임
printf_s("MISS\n");
m_MyMap.ChangeStatusMap(pos, ATTACK);
return AR_MISS;
}