本文整理汇总了C++中Network::GetFinalResult方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::GetFinalResult方法的具体用法?C++ Network::GetFinalResult怎么用?C++ Network::GetFinalResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::GetFinalResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NET_PlayGameFlow
//.........这里部分代码省略.........
{
Coordinate netShot;
bool isAttacked;
while (true)
{
do
{
netShot = m_Player1->RandomAttack(); //Make AI Attack T-T
//netShot = m_GameInterface->AttackInterface(FIRST_MAP_GOTOX, FIRST_MAP_GOTOY); //Manual Mode
isAttacked = m_Player2->CheckAttacked(netShot);
} while (isAttacked);
Coord myShot(netShot.m_X, netShot.m_Y);
error = network.SubmitAttack(myShot);
if (error == ET_INVALID_ATTACK)
printf_s("유효하지 않은 공격");
else
break;
}
break;
}
case PKT_SC_ATTACK_RESULT:
{
Network::AttackResultData attackResult = network.GetAttackResult();
Coordinate shot;
shot.m_X = attackResult.pos.mX;
shot.m_Y = attackResult.pos.mY;
HitResult shotResult = (HitResult)attackResult.attackResult;
if (attackResult.isMine) //내 에너미 맵에 내가 공격한 결과를 반영 마크
{
m_GameRenderer->PrintResult(shotResult);
m_GameRenderer->PrintTurn(++m_Turn, DEFAULT_MAP_SIZE);
m_Player1->MarkOnEnemyMap(shot, shotResult);
m_Player2->MarkOnMyMap(shot, shotResult);
m_Player1->RenderUpdateEnemyMapStatus(FIRST_MAP_GOTOX, FIRST_MAP_GOTOY);
}
else //내가 어택당하는 함수
{
m_Player1->MarkOnMyMap(shot, shotResult);
m_Player1->RenderUpdateMyMapStatus((m_MapSize + 3) * 4 + 30, FIRST_MAP_GOTOY);
}
break;
}
case PKT_SC_GAME_OVER:
{
Network::GameResultData gameResult = network.GetGameResult();
ResetGame();
if (gameResult.isWinner)
puts("승리!!!");
else
puts("패배...");
printf_s("턴 수: %d\n", gameResult.turns);
gameOver = true;
break;
}
default:
throw Network::UNEXPECTED_PACKET;
break;
}
}
network.GetPacketType(&type);
if (type == PKT_SC_NEXT_GAME)
{
puts("다음 게임을 준비해주세요.");
}
else if (type == PKT_SC_ALL_OVER)
{
Network::FinalResultData finalResult = network.GetFinalResult();
allOver = true;
}
else
throw Network::UNEXPECTED_PACKET;
}
}
catch (Network::Exception ex)
{
switch (ex)
{
case Network::NETWORK_ERROR:
puts("네트워크에 문제가 발생했습니다.");
break;
case Network::SERVER_CLOSED:
puts("서버와의 연결이 끊어졌습니다.");
break;
case Network::PARAMETER_ERROR:
puts("함수의 인수가 잘못되었습니다.");
break;
case Network::UNEXPECTED_PACKET:
puts("서버에서 잘못된 정보가 전송되었습니다.");
break;
default:
break;
}
}
network.Disconnect();
m_GameStatus = WIN;
}
示例2: Networking
//.........这里部分代码省略.........
}
break;
}
// 공격 결과
case PKT_SC_ATTACK_RESULT:
{
Network::AttackResultData attackResult = network.GetAttackResult();
Position attackpos;
attackpos.x = attackResult.pos.mX;
attackpos.y = attackResult.pos.mY;
HitResult hitResult = TranslateHitResult(attackResult.attackResult);
if (attackResult.isMine){
// puts("공격 결과:");
m_Attacker->ReceiveHitResult(attackpos, hitResult);
}
else
{
puts("피격 결과:");
//HandleOpositionAttackResult(attackResult.attackResult, attackResult.pos.mX, attackResult.pos.mY);
m_Zido_Attacker->ZidoMarkByGM(attackpos);
}
printf_s("X: %d, Y: %d, RESULT: %s\n", attackResult.pos.mX, attackResult.pos.mY, ATTACK_RESULT_STR[attackResult.attackResult]);
break;
}
// 게임 종료
case PKT_SC_GAME_OVER:
{
Network::GameResultData gameResult = network.GetGameResult();
if (gameResult.isWinner)
puts("승리!!!");
else
puts("패배...");
printf_s("턴 수: %d\n", gameResult.turns);
gameOver = true;
break;
}
default:
throw Network::UNEXPECTED_PACKET;
break;
}
}
/*
** 종료후 처리
*/
network.GetPacketType(&type);
if (type == PKT_SC_NEXT_GAME)
{
puts("다음 게임을 준비해주세요.");
}
else if (type == PKT_SC_ALL_OVER)
{
Network::FinalResultData finalResult = network.GetFinalResult();
puts("모두 종료");
printf_s("승리 횟수: %d, 평균 턴 수: %.1f", finalResult.winCount, finalResult.avgTurns);
allOver = true;
}
else
throw Network::UNEXPECTED_PACKET;
}
}
catch (Network::Exception ex)
{
switch (ex)
{
case Network::NETWORK_ERROR:
puts("네트워크에 문제가 발생했습니다.");
break;
case Network::SERVER_CLOSED:
puts("서버와의 연결이 끊어졌습니다.");
break;
case Network::PARAMETER_ERROR:
puts("함수의 인수가 잘못되었습니다.");
break;
case Network::UNEXPECTED_PACKET:
puts("서버에서 잘못된 정보가 전송되었습니다.");
break;
default:
break;
}
}
/*
** 연결 종료
참고로 소멸시에도 자동으로 Disconnect를 호출한다.
*/
network.Disconnect();
_getch();
}