590 lines
16 KiB
C++
590 lines
16 KiB
C++
|
|
|
|||
|
|
#include "NN_PrivateEndNode.h"
|
|||
|
|
|
|||
|
|
#include "cocostudio/CocoStudio.h"
|
|||
|
|
#include "ui/CocosGUI.h"
|
|||
|
|
#include "GameDefine.h"
|
|||
|
|
#include "ImagicDownManager.h"
|
|||
|
|
#include "JniFun.h"
|
|||
|
|
|
|||
|
|
USING_NS_CC;
|
|||
|
|
using namespace ui;
|
|||
|
|
using namespace std;
|
|||
|
|
|
|||
|
|
#define SETCTRLTEXT(pNode, ctrl, str) \
|
|||
|
|
{ \
|
|||
|
|
Text* pText = (Text*)pNode->getChildByName(ctrl);\
|
|||
|
|
if (pText) pText->setString(str);\
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
NNPrivateEndNode::NNPrivateEndNode()
|
|||
|
|
{
|
|||
|
|
m_ImageViewBg = nullptr; // <20><><EFBFBD>ڵ<EFBFBD>
|
|||
|
|
m_btnleave = nullptr; // <20>û<EFBFBD><C3BB>뿪
|
|||
|
|
m_btnShow = nullptr; // <20><><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
zeromemory(m_pPlayNode, sizeof(m_pPlayNode)); // <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
NNPrivateEndNode::~NNPrivateEndNode()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool NNPrivateEndNode::init()
|
|||
|
|
{
|
|||
|
|
if (!Node::init()) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto rootNode = static_cast<Node*>(CSLoader::createNodeWithVisibleSize("Games/NiuNiu/PrivateEndScene.csb"));
|
|||
|
|
ASSERT(rootNode != nullptr);
|
|||
|
|
this->addChild(rootNode);
|
|||
|
|
|
|||
|
|
m_ImageViewBg = (ImageView*)rootNode->getChildByName("ImageBg");
|
|||
|
|
ASSERT(m_ImageViewBg != nullptr);
|
|||
|
|
|
|||
|
|
m_txtRoomID = (Text*)m_ImageViewBg->getChildByName("txtRoomID");
|
|||
|
|
ASSERT(m_txtRoomID != nullptr);
|
|||
|
|
m_txtRoomID->setString("");
|
|||
|
|
|
|||
|
|
m_txtTime = (Text*)m_ImageViewBg->getChildByName("txtTime");
|
|||
|
|
ASSERT(m_txtTime != nullptr);
|
|||
|
|
m_txtTime->setString("");
|
|||
|
|
|
|||
|
|
// <20>뿪<EFBFBD><EBBFAA>ť
|
|||
|
|
m_btnleave = (Button*)m_ImageViewBg->getChildByName("btnClose");
|
|||
|
|
ASSERT(m_btnleave);
|
|||
|
|
m_btnleave->addClickEventListener([=](Ref *pSender){
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(LEAVE_GAME);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
m_btnShow = (Button*)m_ImageViewBg->getChildByName("btnShow");
|
|||
|
|
ASSERT(m_btnShow);
|
|||
|
|
m_btnShow->addClickEventListener([=](Ref *pSender){
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(WEIXIN_SHOW);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
m_PanelList = (Layout*)m_ImageViewBg->getChildByName("PanelList");
|
|||
|
|
ASSERT(m_PanelList != nullptr);
|
|||
|
|
|
|||
|
|
//m_ListItem = (Layout*)m_PanelList->getChildByName("Item");
|
|||
|
|
//ASSERT(m_ListItem != nullptr);
|
|||
|
|
//m_ListItem->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
for (WORD i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
m_pPlayNode[i] = (Node*)m_PanelList->getChildByName(StringUtils::format("UserItem_%d", i));
|
|||
|
|
ASSERT(m_pPlayNode[i]);
|
|||
|
|
m_pPlayNode[i]->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::SetRoomID(std::string strRoomID)
|
|||
|
|
{
|
|||
|
|
if (m_txtRoomID != nullptr)
|
|||
|
|
{
|
|||
|
|
m_txtRoomID->setString(strRoomID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::string NNPrivateEndNode::getcurrTime()
|
|||
|
|
{
|
|||
|
|
struct tm* tm;
|
|||
|
|
time_t timep;
|
|||
|
|
time(&timep);
|
|||
|
|
tm = localtime(&timep);
|
|||
|
|
return StringUtils::format("%02d-%02d-%02d %02d:%02d", 1900+tm->tm_year, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::ShowGameResult(NN_CMD_S_Private_End_Info* pNetInfo, GamePlayer* players[NN_GAME_PLAYER],
|
|||
|
|
bool bUnionScore, SCORE lGameGold, SCORE lScoreMultiple)
|
|||
|
|
{
|
|||
|
|
if (pNetInfo == nullptr) return;
|
|||
|
|
|
|||
|
|
// <20><>ǰʱ<C7B0><CAB1>;
|
|||
|
|
if (m_txtTime != nullptr)
|
|||
|
|
{
|
|||
|
|
std::string strSystemTime = JniFun::getDataTime();
|
|||
|
|
m_txtTime->setString(strSystemTime);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//SCORE lMaxScore = 0;
|
|||
|
|
int iWinPlayer = 0;
|
|||
|
|
int iUserCount = 0;
|
|||
|
|
|
|||
|
|
// Ѱ<>Ҵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
SCORE lMaxScore = 0;
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5><EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
if (lMaxScore < pNetInfo->lAllScore[i])
|
|||
|
|
{
|
|||
|
|
lMaxScore = pNetInfo->lAllScore[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><CBB0>;
|
|||
|
|
SCORE lRevenue = 0;
|
|||
|
|
if (bUnionScore)
|
|||
|
|
{
|
|||
|
|
// ͳ<>ƴ<EFBFBD>Ӯ<EFBFBD><D3AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
int iMaxScoreCount = 0;
|
|||
|
|
for (int j = 0; j < NN_GAME_PLAYER; j++)
|
|||
|
|
{
|
|||
|
|
if ((lMaxScore > 0) && (pNetInfo->lAllScore[j] == lMaxScore))
|
|||
|
|
{
|
|||
|
|
iMaxScoreCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (iMaxScoreCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>;
|
|||
|
|
lRevenue = floor(lGameGold / iMaxScoreCount);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>;
|
|||
|
|
if (pNetInfo->aryActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
if (nullptr == m_pPlayNode[iUserCount]) continue;
|
|||
|
|
|
|||
|
|
// ͷ<><CDB7>
|
|||
|
|
Sprite* pHead = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("Head");
|
|||
|
|
if (pHead)
|
|||
|
|
{
|
|||
|
|
ImagicDownManager::Instance().addDown(pHead, pPlayer->GetHeadHttp(), pPlayer->GetGameID());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtUserName", pPlayer->GetNickName()); // <20><><EFBFBD><EFBFBD>
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtGameID", StringUtils::format("ID:%d", pPlayer->GetGameID())); // ID
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_WIN]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllLose", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_LOSE]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllNN", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_NIUNIU]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_WIN]));
|
|||
|
|
|
|||
|
|
auto txtAllScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtAllScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
SCORE lGameScore = pNetInfo->lAllScore[i];
|
|||
|
|
if (lGameScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format(".%d", lGameScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format("/%d", std::abs(lGameScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Sprite* pCreate = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("create");
|
|||
|
|
if (pCreate) pCreate->setVisible(0 == i);
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2>Ǵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
bool bMaxWinUser = false;
|
|||
|
|
if ((lMaxScore > 0) && (lMaxScore == pNetInfo->lAllScore[i]))
|
|||
|
|
{
|
|||
|
|
bMaxWinUser = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
auto winicon = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("win");
|
|||
|
|
if (winicon) winicon->setVisible(bMaxWinUser);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>;
|
|||
|
|
auto txtUnionScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtUnionScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
ASSERT(txtUnionScore != nullptr);
|
|||
|
|
|
|||
|
|
if (bUnionScore)
|
|||
|
|
{
|
|||
|
|
SCORE lUnionScore = pNetInfo->lAllScore[i] * lScoreMultiple;
|
|||
|
|
|
|||
|
|
if (bMaxWinUser)
|
|||
|
|
{
|
|||
|
|
if (lUnionScore > lRevenue)
|
|||
|
|
{
|
|||
|
|
lUnionScore -= lRevenue;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lUnionScore = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (lUnionScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format(".%d", lUnionScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format("/%d", std::abs(lUnionScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pPlayNode[iUserCount]->setVisible(true);
|
|||
|
|
|
|||
|
|
iUserCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><>Ӯ<EFBFBD><D3AE>
|
|||
|
|
//if (lMaxScore > 0)
|
|||
|
|
//{
|
|||
|
|
// auto winicon = (Sprite*)m_pPlayNode[iWinPlayer]->getChildByName("win");
|
|||
|
|
// if (winicon) winicon->setVisible(true);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
if (iUserCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fPlanelWidth = m_PanelList->getContentSize().width;
|
|||
|
|
// <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fItemWidth = m_pPlayNode[0]->getContentSize().width;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>*<2A>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>+1<><31>;
|
|||
|
|
float fIntervalWidth = (fPlanelWidth - fItemWidth*iUserCount) / (iUserCount + 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
for (int i = 0; i < iUserCount; i++)
|
|||
|
|
{
|
|||
|
|
if ((m_pPlayNode[i] != nullptr) && m_pPlayNode[i]->isVisible())
|
|||
|
|
{
|
|||
|
|
m_pPlayNode[i]->setPositionX(fIntervalWidth + (fItemWidth + fIntervalWidth)*i);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::ShowGameResult(NN_CMD_S_Private_End_Info* pNetInfo, GamePlayer* players[NN_GAME_PLAYER],
|
|||
|
|
CMD_GF_Private_Room_Info& RoomInfo, CMD_GF_Private_Score_Info& ScoreInfo)
|
|||
|
|
{
|
|||
|
|
if (pNetInfo == nullptr) return;
|
|||
|
|
|
|||
|
|
bool bUnionScore = (RoomInfo.cbUnionGoldOpen == 1);
|
|||
|
|
//SCORE lScoreMultiple = RoomInfo.lScoreMultiple;
|
|||
|
|
uint8 cbBaseScore = RoomInfo.cbBaseScore;
|
|||
|
|
SCORE lGameGold = RoomInfo.lGameGold * RoomInfo.dwPlayCost;
|
|||
|
|
|
|||
|
|
// <20><>ǰʱ<C7B0><CAB1>;
|
|||
|
|
if (m_txtTime != nullptr)
|
|||
|
|
{
|
|||
|
|
std::string strSystemTime = JniFun::getDataTime();
|
|||
|
|
m_txtTime->setString(strSystemTime);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//SCORE lMaxScore = 0;
|
|||
|
|
int iWinPlayer = 0;
|
|||
|
|
int iUserCount = 0;
|
|||
|
|
|
|||
|
|
// Ѱ<>Ҵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
SCORE lMaxScore = 0;
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5><EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
if (lMaxScore < pNetInfo->lAllScore[i])
|
|||
|
|
{
|
|||
|
|
lMaxScore = pNetInfo->lAllScore[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>˰<EFBFBD><CBB0>;
|
|||
|
|
SCORE lRevenue = 0;
|
|||
|
|
if (bUnionScore)
|
|||
|
|
{
|
|||
|
|
// ͳ<>ƴ<EFBFBD>Ӯ<EFBFBD><D3AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
int iMaxScoreCount = 0;
|
|||
|
|
for (int j = 0; j < NN_GAME_PLAYER; j++)
|
|||
|
|
{
|
|||
|
|
if ((lMaxScore > 0) && (pNetInfo->lAllScore[j] == lMaxScore))
|
|||
|
|
{
|
|||
|
|
iMaxScoreCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (iMaxScoreCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>;
|
|||
|
|
lRevenue = floor(lGameGold / iMaxScoreCount);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>;
|
|||
|
|
if (pNetInfo->aryActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
if (nullptr == m_pPlayNode[iUserCount]) continue;
|
|||
|
|
|
|||
|
|
// ͷ<><CDB7>
|
|||
|
|
Sprite* pHead = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("Head");
|
|||
|
|
if (pHead)
|
|||
|
|
{
|
|||
|
|
ImagicDownManager::Instance().addDown(pHead, pPlayer->GetHeadHttp(), pPlayer->GetGameID());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtUserName", pPlayer->GetNickName()); // <20><><EFBFBD><EFBFBD>
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtGameID", StringUtils::format("ID:%d", pPlayer->GetGameID())); // ID
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_WIN]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllLose", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_LOSE]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllNN", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_NIUNIU]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_WIN]));
|
|||
|
|
|
|||
|
|
auto txtAllScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtAllScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
SCORE lGameScore = pNetInfo->lAllScore[i] * cbBaseScore;
|
|||
|
|
if (lGameScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format(".%d", lGameScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format("/%d", std::abs(lGameScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Sprite* pCreate = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("create");
|
|||
|
|
if (pCreate) pCreate->setVisible(0 == i);
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2>Ǵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
bool bMaxWinUser = false;
|
|||
|
|
if ((lMaxScore > 0) && (lMaxScore == pNetInfo->lAllScore[i]))
|
|||
|
|
{
|
|||
|
|
bMaxWinUser = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
auto winicon = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("win");
|
|||
|
|
if (winicon) winicon->setVisible(bMaxWinUser);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>;
|
|||
|
|
auto txtUnionScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtUnionScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
ASSERT(txtUnionScore != nullptr);
|
|||
|
|
|
|||
|
|
auto txtAllUnionScore = (Text*)m_pPlayNode[iUserCount]->getChildByName("txtAllUnionScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
ASSERT(txtAllUnionScore != nullptr);
|
|||
|
|
|
|||
|
|
if (bUnionScore)
|
|||
|
|
{
|
|||
|
|
SCORE lUnionScore = pNetInfo->lAllScore[i] * cbBaseScore;
|
|||
|
|
if (bMaxWinUser)
|
|||
|
|
{
|
|||
|
|
if (lUnionScore > lRevenue)
|
|||
|
|
{
|
|||
|
|
lUnionScore -= lRevenue;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
lUnionScore = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB>ֻ<EFBFBD><D6BB><EFBFBD>
|
|||
|
|
SCORE lAllUnionScore = ScoreInfo.kScoreInfoArray[i] + lUnionScore;
|
|||
|
|
|
|||
|
|
if (lUnionScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format(".%d", lUnionScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format("/%d", std::abs(lUnionScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
txtAllUnionScore->setString(StringUtils::format("%d", lAllUnionScore));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setVisible(false);
|
|||
|
|
txtAllUnionScore->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pPlayNode[iUserCount]->setVisible(true);
|
|||
|
|
|
|||
|
|
iUserCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//// <20><>Ӯ<EFBFBD><D3AE>
|
|||
|
|
//if (lMaxScore > 0)
|
|||
|
|
//{
|
|||
|
|
// auto winicon = (Sprite*)m_pPlayNode[iWinPlayer]->getChildByName("win");
|
|||
|
|
// if (winicon) winicon->setVisible(true);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
if (iUserCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fPlanelWidth = m_PanelList->getContentSize().width;
|
|||
|
|
// <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fItemWidth = m_pPlayNode[0]->getContentSize().width;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>*<2A>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>+1<><31>;
|
|||
|
|
float fIntervalWidth = (fPlanelWidth - fItemWidth*iUserCount) / (iUserCount + 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
for (int i = 0; i < iUserCount; i++)
|
|||
|
|
{
|
|||
|
|
if ((m_pPlayNode[i] != nullptr) && m_pPlayNode[i]->isVisible())
|
|||
|
|
{
|
|||
|
|
m_pPlayNode[i]->setPositionX(fIntervalWidth + (fItemWidth + fIntervalWidth)*i);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::ShowGameResult(NN_CMD_S_Private_End_Info* pNetInfo, GamePlayer* players[NN_GAME_PLAYER],
|
|||
|
|
uint8 cbBaseScore)
|
|||
|
|
{
|
|||
|
|
if (pNetInfo == nullptr) return;
|
|||
|
|
|
|||
|
|
// <20><>ǰʱ<C7B0><CAB1>;
|
|||
|
|
if (m_txtTime != nullptr)
|
|||
|
|
{
|
|||
|
|
std::string strSystemTime = JniFun::getDataTime();
|
|||
|
|
m_txtTime->setString(strSystemTime);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//SCORE lMaxScore = 0;
|
|||
|
|
int iWinPlayer = 0;
|
|||
|
|
int iUserCount = 0;
|
|||
|
|
|
|||
|
|
// Ѱ<>Ҵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
SCORE lMaxScore = 0;
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
|
|||
|
|
// <20>ҵ<EFBFBD><D2B5><EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
if (lMaxScore < pNetInfo->lAllScore[i])
|
|||
|
|
{
|
|||
|
|
lMaxScore = pNetInfo->lAllScore[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < NN_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>;
|
|||
|
|
if (pNetInfo->aryActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = players[i];
|
|||
|
|
if (nullptr == pPlayer) continue;
|
|||
|
|
if (nullptr == m_pPlayNode[iUserCount]) continue;
|
|||
|
|
|
|||
|
|
// ͷ<><CDB7>
|
|||
|
|
Sprite* pHead = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("Head");
|
|||
|
|
if (pHead)
|
|||
|
|
{
|
|||
|
|
ImagicDownManager::Instance().addDown(pHead, pPlayer->GetHeadHttp(), pPlayer->GetGameID());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtUserName", pPlayer->GetNickName()); // <20><><EFBFBD><EFBFBD>
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtGameID", StringUtils::format("ID:%d", pPlayer->GetGameID())); // ID
|
|||
|
|
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_WIN]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllLose", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_ALL_LOSE]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllNN", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_NIUNIU]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtWin", StringUtils::format("%d", pNetInfo->aryResultTypeCount[i][NN_RT_WIN]));
|
|||
|
|
SETCTRLTEXT(m_pPlayNode[iUserCount], "txtAllUnionScore", "");
|
|||
|
|
|
|||
|
|
auto txtAllScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtAllScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
SCORE lGameScore = pNetInfo->lAllScore[i];
|
|||
|
|
if (lGameScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format(".%d", lGameScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtAllScore->setProperty(StringUtils::format("/%d", std::abs(lGameScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Sprite* pCreate = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("create");
|
|||
|
|
if (pCreate) pCreate->setVisible(0 == i);
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2>Ǵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
bool bMaxWinUser = false;
|
|||
|
|
if ((lMaxScore > 0) && (lMaxScore == pNetInfo->lAllScore[i]))
|
|||
|
|
{
|
|||
|
|
bMaxWinUser = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
auto winicon = (Sprite*)m_pPlayNode[iUserCount]->getChildByName("win");
|
|||
|
|
if (winicon) winicon->setVisible(bMaxWinUser);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>;
|
|||
|
|
auto txtUnionScore = (TextAtlas*)m_pPlayNode[iUserCount]->getChildByName("txtUnionScore"); // <20>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
ASSERT(txtUnionScore != nullptr);
|
|||
|
|
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB><EFBFBD>;
|
|||
|
|
SCORE lUnionScore = pNetInfo->lAllScore[i] * cbBaseScore;
|
|||
|
|
if (lUnionScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format(".%d", lUnionScore), "Games/NiuNiu/Table/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtUnionScore->setProperty(StringUtils::format("/%d", std::abs(lUnionScore)), "Games/NiuNiu/Table/num_loss.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pPlayNode[iUserCount]->setVisible(true);
|
|||
|
|
|
|||
|
|
iUserCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
if (iUserCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fPlanelWidth = m_PanelList->getContentSize().width;
|
|||
|
|
// <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
float fItemWidth = m_pPlayNode[0]->getContentSize().width;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>*<2A>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>+1<><31>;
|
|||
|
|
float fIntervalWidth = (fPlanelWidth - fItemWidth*iUserCount) / (iUserCount + 1);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
for (int i = 0; i < iUserCount; i++)
|
|||
|
|
{
|
|||
|
|
if ((m_pPlayNode[i] != nullptr) && m_pPlayNode[i]->isVisible())
|
|||
|
|
{
|
|||
|
|
m_pPlayNode[i]->setPositionX(fIntervalWidth + (fItemWidth + fIntervalWidth)*i);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::pushScene()
|
|||
|
|
{
|
|||
|
|
this->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void NNPrivateEndNode::popScene()
|
|||
|
|
{
|
|||
|
|
this->removeFromParent();
|
|||
|
|
}
|