361 lines
9.7 KiB
C++
361 lines
9.7 KiB
C++
|
|
#include "PDK_GameEndNode.h"
|
|||
|
|
#include "Define.h"
|
|||
|
|
#include "PDK_CMD.h"
|
|||
|
|
#include "ActionEx.h"
|
|||
|
|
#include "PDK_SmallCardSprite.h"
|
|||
|
|
#include "SelectShareScene.h"
|
|||
|
|
|
|||
|
|
PDKGameEndNode::PDKGameEndNode()
|
|||
|
|
{
|
|||
|
|
//init();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
PDKGameEndNode::~PDKGameEndNode()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool PDKGameEndNode::init()
|
|||
|
|
{
|
|||
|
|
if (!Node::init())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
auto root = CSLoader::createNodeWithVisibleSize("Games/PDK/ResultLayer.csb");
|
|||
|
|
CC_ASSERT(root != nullptr);
|
|||
|
|
this->addChild(root);
|
|||
|
|
|
|||
|
|
m_rootPanel = root->getChildByName("sprResult");
|
|||
|
|
CC_ASSERT(m_rootPanel != nullptr);
|
|||
|
|
|
|||
|
|
//<2F>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
m_btnPrivate = static_cast<Button*>(m_rootPanel->getChildByName("btnPrivate"));
|
|||
|
|
CC_ASSERT(m_btnPrivate != nullptr);
|
|||
|
|
ASSERT(m_btnPrivate);
|
|||
|
|
m_btnPrivate->setVisible(false);
|
|||
|
|
m_btnPrivate->addClickEventListener([=](Ref *pSender){
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(SHOW_PRIVATE_END);
|
|||
|
|
this->hide();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
m_btnContinue = static_cast<Button*>(m_rootPanel->getChildByName("btnContinue"));
|
|||
|
|
CC_ASSERT(m_btnContinue != nullptr);
|
|||
|
|
m_btnContinue->addClickEventListener(CC_CALLBACK_1(PDKGameEndNode::onButtonContinueClick, this));
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
m_btnShare = static_cast<Button*>(m_rootPanel->getChildByName("btnShare"));
|
|||
|
|
CC_ASSERT(m_btnShare != nullptr);
|
|||
|
|
m_btnShare->addClickEventListener([=](Ref *pSender){
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(WEIXIN_SHOW);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//ʤ<><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
m_sprTitleWin = static_cast<Sprite*>(m_rootPanel->getChildByName("sprTitleWin"));
|
|||
|
|
CC_ASSERT(m_sprTitleWin != nullptr);
|
|||
|
|
|
|||
|
|
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־;
|
|||
|
|
//m_sprLandlord = static_cast<Sprite*>(m_rootPanel->getChildByName("sprLandlord"));
|
|||
|
|
//CC_ASSERT(m_sprLandlord != nullptr);
|
|||
|
|
|
|||
|
|
//ʤ<><CAA4><EFBFBD><EFBFBD>־;
|
|||
|
|
m_sprWin = static_cast<Sprite*>(m_rootPanel->getChildByName("sprWin"));
|
|||
|
|
CC_ASSERT(m_sprWin != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־;
|
|||
|
|
m_sprChunTian = static_cast<Sprite*>(m_rootPanel->getChildByName("sprChunTian"));
|
|||
|
|
CC_ASSERT(m_sprChunTian != nullptr);
|
|||
|
|
m_sprChunTian->setVisible(false);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʾ;
|
|||
|
|
void PDKGameEndNode::show(uint16 wLandChairID, uint16 wSelfChairID, std::string aryNickName[], PDK_CMD_S_GameConclude* pGameConclude, uint16 wTime)
|
|||
|
|
{
|
|||
|
|
uint8 cbCardIndex = 0;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>ı<EFBFBD>;
|
|||
|
|
for (int i = 0; i < PDK_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto panelPlayer = static_cast<Layout*>(m_rootPanel->getChildByName(StringUtils::format("panelPlayer_%d", i)));
|
|||
|
|
CC_ASSERT(panelPlayer != nullptr);
|
|||
|
|
panelPlayer->setVisible(true);
|
|||
|
|
|
|||
|
|
if (!pGameConclude->bActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
panelPlayer->setVisible(false);
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto txtNickName = static_cast<Text*>(panelPlayer->getChildByName("txtNickName"));
|
|||
|
|
CC_ASSERT(txtNickName != nullptr);
|
|||
|
|
|
|||
|
|
txtNickName->setString(aryNickName[i]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
auto splandlord = static_cast<Sprite*>(panelPlayer->getChildByName("landlord"));
|
|||
|
|
CC_ASSERT(splandlord != nullptr);
|
|||
|
|
splandlord->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>;
|
|||
|
|
auto txtGameScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtGameScore"));
|
|||
|
|
CC_ASSERT(txtGameScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lGameScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtGameScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtGameScore->setString(StringUtils::format("+%d", pGameConclude->lGameScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtGameScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtGameScore->setString(StringUtils::format("%d", pGameConclude->lGameScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto txtBombScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtBombScore"));
|
|||
|
|
CC_ASSERT(txtBombScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lBombScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtBombScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtBombScore->setString(StringUtils::format("+%d", pGameConclude->lBombScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtBombScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtBombScore->setString(StringUtils::format("%d", pGameConclude->lBombScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB><EFBFBD>;
|
|||
|
|
auto txtAllScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtAllScore"));
|
|||
|
|
CC_ASSERT(txtAllScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lAllScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtAllScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtAllScore->setString(StringUtils::format("+%d", pGameConclude->lAllScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtAllScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtAllScore->setString(StringUtils::format("%d", pGameConclude->lAllScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto panelLeftCard = static_cast<Layout*>(panelPlayer->getChildByName("panelLeftCard"));
|
|||
|
|
CC_ASSERT(panelLeftCard != nullptr);
|
|||
|
|
panelLeftCard->removeAllChildren();
|
|||
|
|
|
|||
|
|
if (pGameConclude->cbCardCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
showLeftCard(panelLeftCard, &pGameConclude->cbHandCardData[cbCardIndex], pGameConclude->cbCardCount[i]);
|
|||
|
|
|
|||
|
|
cbCardIndex += pGameConclude->cbCardCount[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
CC_ASSERT(wSelfChairID <= PDK_GAME_PLAYER);
|
|||
|
|
if (pGameConclude->lGameScore[wSelfChairID] > 0)
|
|||
|
|
{
|
|||
|
|
////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD>;
|
|||
|
|
//if (wLandChairID == wSelfChairID)
|
|||
|
|
//{
|
|||
|
|
// m_sprLandlord->setTexture(PDK_DIZHU_SHENG_PNG_FILE);
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// m_sprLandlord->setTexture(PDK_NONGMIN_SHENG_PNG_FILE);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
m_sprTitleWin->setTexture(PDK_END_TITLE_WIN_PNG_FILE);
|
|||
|
|
m_sprWin->setTexture(PDK_SHENG_PNG_FILE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD>;
|
|||
|
|
//if (wLandChairID == wSelfChairID)
|
|||
|
|
//{
|
|||
|
|
// m_sprLandlord->setTexture(PDK_DIZHU_SHU_PNG_FILE);
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// m_sprLandlord->setTexture(PDK_NONGMIN_SHU_PNG_FILE);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
m_sprTitleWin->setTexture(PDK_END_TITLE_LOSE_PNG_FILE);
|
|||
|
|
m_sprWin->setTexture(PDK_SHU_PNG_FILE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if (pGameConclude->bChunTian)
|
|||
|
|
//{
|
|||
|
|
// m_sprChunTian->setTexture("Games/DDZ/Result/chuntian.png");
|
|||
|
|
//}
|
|||
|
|
//else if (pGameConclude->bFanChunTian)
|
|||
|
|
//{
|
|||
|
|
// m_sprChunTian->setTexture("Games/DDZ/Result/fanchuntian.png");
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
{
|
|||
|
|
m_sprChunTian->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void PDKGameEndNode::show(uint16 wLandChairID, uint16 wSelfChairID, std::string aryNickName[], PDK_CMD_S_GameConclude* pGameConclude, uint16 wTurnWiner, uint8 cbTurnCardCount, uint8 cbTurnCardData[])
|
|||
|
|
{
|
|||
|
|
uint8 cbCardIndex = 0;
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>ı<EFBFBD>;
|
|||
|
|
for (int i = 0; i < PDK_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto panelPlayer = static_cast<Layout*>(m_rootPanel->getChildByName(StringUtils::format("panelPlayer_%d", i)));
|
|||
|
|
CC_ASSERT(panelPlayer != nullptr);
|
|||
|
|
panelPlayer->setVisible(true);
|
|||
|
|
|
|||
|
|
if (!pGameConclude->bActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
panelPlayer->setVisible(false);
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto txtNickName = static_cast<Text*>(panelPlayer->getChildByName("txtNickName"));
|
|||
|
|
CC_ASSERT(txtNickName != nullptr);
|
|||
|
|
|
|||
|
|
txtNickName->setString(aryNickName[i]);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
auto splandlord = static_cast<Sprite*>(panelPlayer->getChildByName("landlord"));
|
|||
|
|
CC_ASSERT(splandlord != nullptr);
|
|||
|
|
splandlord->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>;
|
|||
|
|
auto txtGameScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtGameScore"));
|
|||
|
|
CC_ASSERT(txtGameScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lGameScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtGameScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtGameScore->setString(StringUtils::format("+%d", pGameConclude->lGameScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtGameScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtGameScore->setString(StringUtils::format("%d", pGameConclude->lGameScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ը<><D5A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto txtBombScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtBombScore"));
|
|||
|
|
CC_ASSERT(txtBombScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lBombScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtBombScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtBombScore->setString(StringUtils::format("+%d", pGameConclude->lBombScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtBombScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtBombScore->setString(StringUtils::format("%d", pGameConclude->lBombScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ܻ<EFBFBD><DCBB><EFBFBD>;
|
|||
|
|
auto txtAllScore = static_cast<TextBMFont*>(panelPlayer->getChildByName("txtAllScore"));
|
|||
|
|
CC_ASSERT(txtAllScore != nullptr);
|
|||
|
|
|
|||
|
|
if (pGameConclude->lAllScore[i] > 0)
|
|||
|
|
{
|
|||
|
|
txtAllScore->setFntFile(PDK_WIN_NUMBER_FNT_FILE);
|
|||
|
|
txtAllScore->setString(StringUtils::format("+%d", pGameConclude->lAllScore[i]));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtAllScore->setFntFile(PDK_LOSE_NUMBER_FNT_FILE);
|
|||
|
|
txtAllScore->setString(StringUtils::format("%d", pGameConclude->lAllScore[i]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto panelLeftCard = static_cast<Layout*>(panelPlayer->getChildByName("panelLeftCard"));
|
|||
|
|
CC_ASSERT(panelLeftCard != nullptr);
|
|||
|
|
panelLeftCard->removeAllChildren();
|
|||
|
|
|
|||
|
|
if (pGameConclude->cbCardCount[i] > 0)
|
|||
|
|
{
|
|||
|
|
showLeftCard(panelLeftCard, &pGameConclude->cbHandCardData[cbCardIndex], pGameConclude->cbCardCount[i]);
|
|||
|
|
|
|||
|
|
cbCardIndex += pGameConclude->cbCardCount[i];
|
|||
|
|
}
|
|||
|
|
else if (i == wTurnWiner)// <EFBFBD><EFBFBD>ʾӮ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
{
|
|||
|
|
showLeftCard(panelLeftCard, cbTurnCardData, cbTurnCardCount);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
CC_ASSERT(wSelfChairID <= PDK_GAME_PLAYER);
|
|||
|
|
if (pGameConclude->lGameScore[wSelfChairID] > 0)
|
|||
|
|
{
|
|||
|
|
m_sprTitleWin->setTexture(PDK_END_TITLE_WIN_PNG_FILE);
|
|||
|
|
m_sprWin->setTexture(PDK_SHENG_PNG_FILE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
m_sprTitleWin->setTexture(PDK_END_TITLE_LOSE_PNG_FILE);
|
|||
|
|
m_sprWin->setTexture(PDK_SHU_PNG_FILE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_sprChunTian->setVisible(false);
|
|||
|
|
|
|||
|
|
this->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void PDKGameEndNode::hide()
|
|||
|
|
{
|
|||
|
|
this->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>;
|
|||
|
|
void PDKGameEndNode::onButtonContinueClick(Ref*)
|
|||
|
|
{
|
|||
|
|
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
|||
|
|
EventCustom event(CONTINUE_GAME);
|
|||
|
|
|
|||
|
|
//<2F>ɷ<EFBFBD><C9B7>ܾ<EFBFBD><DCBE><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>DDZGameScene
|
|||
|
|
dispatcher->dispatchEvent(&event);
|
|||
|
|
|
|||
|
|
hide();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void PDKGameEndNode::onButtonShareClick(Ref*)
|
|||
|
|
{
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(WEIXIN_SHOW);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void PDKGameEndNode::SetShowPrivate()
|
|||
|
|
{
|
|||
|
|
m_btnContinue->setVisible(false);
|
|||
|
|
m_btnPrivate->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʾʣ<CABE><CAA3><EFBFBD>˿<EFBFBD>;
|
|||
|
|
void PDKGameEndNode::showLeftCard(Layout* pRootPanel, uint8 aryCardData[], uint8 cbCardCount)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(pRootPanel != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><CBBF><EFBFBD>;
|
|||
|
|
for (uint8 i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
PDKSmallCardSprite* pCard = PDKSmallCardSprite::create(aryCardData[i]);
|
|||
|
|
|
|||
|
|
CC_ASSERT(pCard != nullptr);
|
|||
|
|
if (pCard)
|
|||
|
|
{
|
|||
|
|
pCard->setPositionX(i * 15);
|
|||
|
|
pRootPanel->addChild(pCard);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|