2375 lines
61 KiB
C++
2375 lines
61 KiB
C++
|
|
#include "ZJH_GameScene.h"
|
|||
|
|
|
|||
|
|
#include "ZJH_GamePlayer.h"
|
|||
|
|
#include "ZJH_GameLogic.h"
|
|||
|
|
#include "UserInfo.h"
|
|||
|
|
#include "MainScene.h"
|
|||
|
|
#include "MissionWeiXin.h"
|
|||
|
|
#include "DismissScene.h"
|
|||
|
|
|
|||
|
|
#include "PopScene.h"
|
|||
|
|
#include "ActionEx.h"
|
|||
|
|
#include "JniFun.h"
|
|||
|
|
#include "SetScene.h"
|
|||
|
|
#include "ChatScene.h"
|
|||
|
|
#include "PlayerScene.h"
|
|||
|
|
#include "IpTipScene.h"
|
|||
|
|
|
|||
|
|
#include "SimpleAudioEngine.h"
|
|||
|
|
|
|||
|
|
using namespace ZJH_SPACE;
|
|||
|
|
|
|||
|
|
bool ZJHGameScene::init()
|
|||
|
|
{
|
|||
|
|
if (!GameFrameBase::init())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_strGameRuleInfo = "";
|
|||
|
|
m_cbGameStatus = ZJH_GS_FREE;
|
|||
|
|
m_bPrivateEnd = false;
|
|||
|
|
|
|||
|
|
_lCellScore = 1;
|
|||
|
|
_wOperTimeOut = 1;
|
|||
|
|
_cbCurRound = 1;
|
|||
|
|
_cbMaxRound = 1;
|
|||
|
|
_lMaxChipScore = 1;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
_aryChairToViewID[i] = INVALID_CHAIR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
zeromemory(&m_PrivateRoomInfo, sizeof(CMD_GF_Private_Room_Info));
|
|||
|
|
|
|||
|
|
initNet();
|
|||
|
|
initScene();
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɻص<C9BB>;
|
|||
|
|
void ZJHGameScene::onEnterTransitionDidFinish()
|
|||
|
|
{
|
|||
|
|
GameFrameBase::onEnterTransitionDidFinish();
|
|||
|
|
|
|||
|
|
if (true == GAME_MUISCBG)
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("Games/ZJH/Sound/BackMusic.mp3", true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʱͣ<CAB1>˲<EFBFBD><CBB2><EFBFBD>;
|
|||
|
|
#if CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
pAudio->stopBackgroundMusic(true);
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
// ¼<><C2BC>ģʽ;
|
|||
|
|
if (m_IsGameRecord)
|
|||
|
|
{
|
|||
|
|
StartRecord(ZJH_GAME_PLAYER);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
|||
|
|
dispatcher->addCustomEventListener(SHOW_PRIVATE_END, CC_CALLBACK_1(ZJHGameScene::onEventShowPrivate, this));
|
|||
|
|
|
|||
|
|
CGameServerItem* pGameServerItem = GameMission::g_pGameServerItem;
|
|||
|
|
CC_ASSERT(pGameServerItem != nullptr);
|
|||
|
|
if (pGameServerItem != nullptr)
|
|||
|
|
{
|
|||
|
|
m_kGameMission.SetServerItem(pGameServerItem);
|
|||
|
|
m_kGameMission.start();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>;
|
|||
|
|
void ZJHGameScene::onExit()
|
|||
|
|
{
|
|||
|
|
GameFrameBase::onExit();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
SafeDelete(m_aryPlayer[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
|||
|
|
dispatcher->removeCustomEventListeners(SHOW_PRIVATE_END);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>;
|
|||
|
|
void ZJHGameScene::initScene()
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ڵ<EFBFBD>;
|
|||
|
|
m_rootNode = CSLoader::createNodeWithVisibleSize("Games/ZJH/GameTableScene.csb");
|
|||
|
|
CC_ASSERT(m_rootNode != nullptr);
|
|||
|
|
this->addChild(m_rootNode, ZO_DEFAULT);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
auto ImageSytem = (ImageView*)m_rootNode->getChildByName("ImgRoll");
|
|||
|
|
CC_ASSERT(ImageSytem!=nullptr);
|
|||
|
|
SetSystemNode(ImageSytem);
|
|||
|
|
|
|||
|
|
// <20><EFBFBD><F3B6A8BD><EFBFBD>Ԫ<EFBFBD><D4AA>;
|
|||
|
|
_MainPanel = static_cast<Layout*>(m_rootNode->getChildByName("MainPanel"));
|
|||
|
|
CC_ASSERT(_MainPanel != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
_imgRoomInfo = static_cast<ImageView*>(_MainPanel->getChildByName("imgRoomInfo"));
|
|||
|
|
CC_ASSERT(_imgRoomInfo != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ID;
|
|||
|
|
_txtRoomID = static_cast<Text*>(_imgRoomInfo->getChildByName("txtRoomID"));
|
|||
|
|
CC_ASSERT(_txtRoomID != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtCompareRound = static_cast<Text*>(_imgRoomInfo->getChildByName("txtCompareRound"));
|
|||
|
|
CC_ASSERT(_txtCompareRound != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtLookCardRound = static_cast<Text*>(_imgRoomInfo->getChildByName("txtLookCard"));
|
|||
|
|
CC_ASSERT(_txtLookCardRound != nullptr);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtOpenCardRound = static_cast<Text*>(_imgRoomInfo->getChildByName("txtOpenCardRound"));
|
|||
|
|
CC_ASSERT(_txtOpenCardRound != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
_txtJushu = static_cast<Text*>(_imgRoomInfo->getChildByName("txtRoundNum"));
|
|||
|
|
CC_ASSERT(_txtJushu != nullptr);
|
|||
|
|
_txtJushu->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_ChipPanel = static_cast<Layout*>(_MainPanel->getChildByName("ChipPanel"));
|
|||
|
|
CC_ASSERT(_ChipPanel != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_ComparePanel = static_cast<Layout*>(m_rootNode->getChildByName("comparePanel"));
|
|||
|
|
CC_ASSERT(_ComparePanel != nullptr);
|
|||
|
|
_ComparePanel->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>;
|
|||
|
|
_armCompare = static_cast<Armature*>(_ComparePanel->getChildByName("armCompare"));
|
|||
|
|
CC_ASSERT(_armCompare != nullptr);
|
|||
|
|
_armCompare->setVisible(false);
|
|||
|
|
|
|||
|
|
ArmatureAnimation* pAniCompare = _armCompare->getAnimation();
|
|||
|
|
if (pAniCompare != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniCompare->setMovementEventCallFunc(CC_CALLBACK_3(ZJHGameScene::movementEventCallFunc, this));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ͷ<EFBFBD><CDB7>;
|
|||
|
|
_sprLeftHead = static_cast<Sprite*>(_ComparePanel->getChildByName("sprLeftHead"));
|
|||
|
|
CC_ASSERT(_sprLeftHead != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>dz<EFBFBD>;
|
|||
|
|
_txtLeftNickName = static_cast<Text*>(_ComparePanel->getChildByName("txtLeftNickName"));
|
|||
|
|
CC_ASSERT(_txtLeftNickName != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_sprLeftBackCard = static_cast<Sprite*>(_ComparePanel->getChildByName("sprLeftBackCard"));
|
|||
|
|
CC_ASSERT(_sprLeftBackCard != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Ӯ<EFBFBD><D3AE>־;
|
|||
|
|
_sprLeftFlag = static_cast<Sprite*>(_ComparePanel->getChildByName("sprLeftFlag"));
|
|||
|
|
CC_ASSERT(_sprLeftFlag != nullptr);
|
|||
|
|
_sprLeftFlag->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>;
|
|||
|
|
_armLeftLose = static_cast<Armature*>(_ComparePanel->getChildByName("armLeftLose"));
|
|||
|
|
CC_ASSERT(_armLeftLose != nullptr);
|
|||
|
|
_armLeftLose->setVisible(false);
|
|||
|
|
|
|||
|
|
ArmatureAnimation* pAniLeftLose = _armLeftLose->getAnimation();
|
|||
|
|
if (pAniLeftLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniLeftLose->setMovementEventCallFunc(CC_CALLBACK_3(ZJHGameScene::movementEventCallFunc, this));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ͷ<EFBFBD><CDB7>;
|
|||
|
|
_sprRightHead = static_cast<Sprite*>(_ComparePanel->getChildByName("sprRightHead"));
|
|||
|
|
CC_ASSERT(_sprRightHead != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>dz<EFBFBD>;
|
|||
|
|
_txtRightNickName = static_cast<Text*>(_ComparePanel->getChildByName("txtRightNickName"));
|
|||
|
|
CC_ASSERT(_txtRightNickName != nullptr);
|
|||
|
|
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>;
|
|||
|
|
_sprRightBackCard = static_cast<Sprite*>(_ComparePanel->getChildByName("sprRightBackCard"));
|
|||
|
|
CC_ASSERT(_sprRightBackCard != nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Ӯ<EFBFBD><D3AE>־;
|
|||
|
|
_sprRightFlag = static_cast<Sprite*>(_ComparePanel->getChildByName("sprRightFlag"));
|
|||
|
|
CC_ASSERT(_sprRightFlag != nullptr);
|
|||
|
|
_sprRightFlag->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>ʧ<EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>;
|
|||
|
|
_armRightLose = static_cast<Armature*>(_ComparePanel->getChildByName("armRightLose"));
|
|||
|
|
CC_ASSERT(_armRightLose != nullptr);
|
|||
|
|
_armRightLose->setVisible(false);
|
|||
|
|
|
|||
|
|
ArmatureAnimation* pAniRightLose = _armRightLose->getAnimation();
|
|||
|
|
if (pAniRightLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniRightLose->setMovementEventCallFunc(CC_CALLBACK_3(ZJHGameScene::movementEventCallFunc, this));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_ResultPanel = static_cast<Layout*>(m_rootNode->getChildByName("resultPanel"));
|
|||
|
|
CC_ASSERT(_ResultPanel != nullptr);
|
|||
|
|
_ResultPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
// ʤ<><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_pArmatureResult = (Armature*)_ResultPanel->getChildByName("armaGameResult");
|
|||
|
|
CC_ASSERT(_pArmatureResult != nullptr);
|
|||
|
|
_pArmatureResult->setVisible(false);
|
|||
|
|
|
|||
|
|
// <><D7BC><EFBFBD><EFBFBD>ť;
|
|||
|
|
_btnReady = static_cast<Button*>(_ResultPanel->getChildByName("btnReady"));
|
|||
|
|
CC_ASSERT(_btnReady != nullptr);
|
|||
|
|
|
|||
|
|
// <><D7BC><EFBFBD><EFBFBD>ʼ;
|
|||
|
|
_btnReady->addClickEventListener([=](Ref* pSender) {
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
SendUserReady();
|
|||
|
|
|
|||
|
|
ArmatureAnimation* pAniResult = _pArmatureResult->getAnimation();
|
|||
|
|
if (pAniResult != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniResult->stop();
|
|||
|
|
}
|
|||
|
|
_pArmatureResult->setVisible(false);
|
|||
|
|
|
|||
|
|
_ResultPanel->setVisible(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20>鿴<EFBFBD>ܳɼ<DCB3><C9BC><EFBFBD>ť;
|
|||
|
|
_btnPrivateEnd = static_cast<Button*>(_ResultPanel->getChildByName("btnPrivateEnd"));
|
|||
|
|
CC_ASSERT(_btnPrivateEnd != nullptr);
|
|||
|
|
_btnPrivateEnd->setVisible(false);
|
|||
|
|
_btnPrivateEnd->addClickEventListener([this](Ref*){
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
|
|||
|
|
_OpenResultScene->updateUIData(m_dwRoomID, &_aryResultItem, true);
|
|||
|
|
_OpenResultScene->setVisible(true);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
for (uint16 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
string strName = StringUtils::format("txtScoreChair_%d", i);
|
|||
|
|
_pTxtResultScore[i] = static_cast<TextAtlas*>(_ResultPanel->getChildByName(strName));
|
|||
|
|
CC_ASSERT(_pTxtResultScore[i]!=nullptr);
|
|||
|
|
_pTxtResultScore[i]->setString("");
|
|||
|
|
|
|||
|
|
strName = StringUtils::format("txtXiScoreChair_%d", i);
|
|||
|
|
_pTxtXiScore[i] = static_cast<TextAtlas*>(_ResultPanel->getChildByName(strName));
|
|||
|
|
CC_ASSERT(_pTxtXiScore[i] != nullptr);
|
|||
|
|
_pTxtXiScore[i]->setString("");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>;
|
|||
|
|
_ButtonPanel = static_cast<Layout*>(_MainPanel->getChildByName("ButtonPanel"));
|
|||
|
|
CC_ASSERT(_ButtonPanel != nullptr);
|
|||
|
|
|
|||
|
|
// <><CEA2><EFBFBD><EFBFBD><EFBFBD>밴ť;
|
|||
|
|
_btnInvite = static_cast<Button*>(_ButtonPanel->getChildByName("btnInvite"));
|
|||
|
|
CC_ASSERT(_btnInvite != nullptr);
|
|||
|
|
_btnInvite->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><>ɢ<EFBFBD><C9A2><EFBFBD>䰴ť;
|
|||
|
|
_btnDismiss = static_cast<Button*>(_ButtonPanel->getChildByName("btnDismiss"));
|
|||
|
|
CC_ASSERT(_btnDismiss != nullptr);
|
|||
|
|
_btnDismiss->setVisible(false);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ð<EFBFBD>ť;
|
|||
|
|
auto btnSetting = static_cast<Button*>(_ButtonPanel->getChildByName("btnSetting"));
|
|||
|
|
CC_ASSERT(btnSetting != nullptr);
|
|||
|
|
btnSetting->addClickEventListener([this](Ref*){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
TipNode* pNode = SetScene::create();
|
|||
|
|
CC_ASSERT(pNode != nullptr);
|
|||
|
|
this->addChild(pNode, ZO_ANI);
|
|||
|
|
pNode->pushScene();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20>뿪<EFBFBD><EBBFAA>ť;
|
|||
|
|
_btnLeave = static_cast<Button*>(_ButtonPanel->getChildByName("btnLeave"));
|
|||
|
|
CC_ASSERT(_btnLeave != nullptr);
|
|||
|
|
//_btnLeave->setVisible(false);
|
|||
|
|
|
|||
|
|
_btnLeave->addClickEventListener([=](Ref* pSender){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
GamePlayer* pGamePlayer = getSelfGamePlayer();
|
|||
|
|
|
|||
|
|
auto callback_ok = [=](){
|
|||
|
|
|
|||
|
|
if (pGamePlayer != nullptr)
|
|||
|
|
{
|
|||
|
|
CMD_GR_UserStandUp request;
|
|||
|
|
memset(&request, 0, sizeof(request));
|
|||
|
|
|
|||
|
|
request.wTableID = pGamePlayer->GetTableID();
|
|||
|
|
request.wChairID = pGamePlayer->GetChairID();
|
|||
|
|
request.cbForceLeave = true;
|
|||
|
|
|
|||
|
|
m_kGameMission.SendSocketData(MDM_GR_USER, SUB_GR_USER_STANDUP, &request, sizeof(request));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this->runAction(Sequence::createWithTwoActions(DelayTime::create(0.2f), CallFunc::create([=]{
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(LEAVE_GAME);
|
|||
|
|
})));
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
std::string strPop = "<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ҫ<EFBFBD>뿪<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
if (m_cbGameStatus != ZJH_GS_FREE)
|
|||
|
|
{
|
|||
|
|
strPop = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>,ǿ<><C7BF><EFBFBD>˳<EFBFBD><CBB3>ᱻ<EFBFBD>۷<EFBFBD>,ȷ<><C8B7>Ҫǿ<D2AA><C7BF><EFBFBD><EFBFBD>?";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
PopScene::Instance().show(utility::a_u8(strPop), callback_ok, nullptr);
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
_btnVoice = static_cast<Button*>(_ButtonPanel->getChildByName("btnVoice"));
|
|||
|
|
CC_ASSERT(_btnVoice != nullptr);
|
|||
|
|
_btnVoice->addTouchEventListener(CC_CALLBACK_2(ZJHGameScene::OnButtonVoiceTouched, this));
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>찴ť;
|
|||
|
|
_btnChat = static_cast<Button*>(_ButtonPanel->getChildByName("btnChat"));
|
|||
|
|
CC_ASSERT(_btnChat != nullptr);
|
|||
|
|
_btnChat->addClickEventListener([this](Ref*){
|
|||
|
|
YSAudioEngine::Instance().playBtnClickEffect();
|
|||
|
|
|
|||
|
|
const std::vector<std::string>& chatList = getShortChatList();
|
|||
|
|
auto chatLayer = ChatLayer::create(chatList);
|
|||
|
|
CC_ASSERT(chatLayer != nullptr);
|
|||
|
|
this->addChild(chatLayer, ZO_ANI);
|
|||
|
|
chatLayer->pushScene();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC>ť;
|
|||
|
|
_btnStartGame = static_cast<Button*>(_ButtonPanel->getChildByName("btnStartGame"));
|
|||
|
|
CC_ASSERT(_btnStartGame != nullptr);
|
|||
|
|
_btnStartGame->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC>Ϸ;
|
|||
|
|
_btnStartGame->addClickEventListener([=](Ref* pSender) {
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
SendUserReady();
|
|||
|
|
|
|||
|
|
_btnStartGame->setEnabled(false);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_OperBtnsPanel = static_cast<Layout*>(_MainPanel->getChildByName("OperBtnsPanel"));
|
|||
|
|
CC_ASSERT(_OperBtnsPanel != nullptr);
|
|||
|
|
_OperBtnsPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
_btnGiveUp = static_cast<Button*>(_OperBtnsPanel->getChildByName("btnGiveUp"));
|
|||
|
|
CC_ASSERT(_btnGiveUp != nullptr);
|
|||
|
|
_btnGiveUp->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onGiveUpButtonClick, this));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ư<EFBFBD>ť;
|
|||
|
|
_btnCompare = static_cast<Button*>(_OperBtnsPanel->getChildByName("btnCompare"));
|
|||
|
|
CC_ASSERT(_btnCompare != nullptr);
|
|||
|
|
_btnCompare->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onCompareButtonClick, this));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtCompareChip = static_cast<Text*>(_btnCompare->getChildByName("txtNum"));
|
|||
|
|
CC_ASSERT(_txtCompareChip != nullptr);
|
|||
|
|
|
|||
|
|
// <20><>ע<EFBFBD><D7A2>ť;
|
|||
|
|
_btnAddChip = static_cast<Button*>(_OperBtnsPanel->getChildByName("btnAddChip"));
|
|||
|
|
CC_ASSERT(_btnAddChip != nullptr);
|
|||
|
|
_btnAddChip->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onAddChipButtonClick, this));
|
|||
|
|
|
|||
|
|
// <20><>ע<EFBFBD><D7A2>ť;
|
|||
|
|
_btnFollow = static_cast<Button*>(_OperBtnsPanel->getChildByName("btnFollow"));
|
|||
|
|
CC_ASSERT(_btnFollow != nullptr);
|
|||
|
|
_btnFollow->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onFollowButtonClick, this));
|
|||
|
|
|
|||
|
|
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtFollowChip = static_cast<Text*>(_btnFollow->getChildByName("txtNum"));
|
|||
|
|
CC_ASSERT(_txtFollowChip != nullptr);
|
|||
|
|
|
|||
|
|
// <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>;
|
|||
|
|
_AddChipPanel = static_cast<Layout*>(_MainPanel->getChildByName("AddChipPanel"));
|
|||
|
|
CC_ASSERT(_AddChipPanel != nullptr);
|
|||
|
|
_AddChipPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
// ȡ<><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ť;
|
|||
|
|
_btnAddCancel = static_cast<Button*>(_AddChipPanel->getChildByName("btnAddCancel"));
|
|||
|
|
CC_ASSERT(_btnAddCancel != nullptr);
|
|||
|
|
_btnAddCancel->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onAddCancelButtonClick, this));
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 4; i++)
|
|||
|
|
{
|
|||
|
|
std::string strName = StringUtils::format("btnAddChip%d", i+1);
|
|||
|
|
Button* btnAdd = static_cast<Button*>(_AddChipPanel->getChildByName(strName));
|
|||
|
|
CC_ASSERT(btnAdd != nullptr);
|
|||
|
|
btnAdd->setTag(i+2);
|
|||
|
|
btnAdd->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onAddChipBtnsClick, this));
|
|||
|
|
|
|||
|
|
_aryAddChip[i] = btnAdd;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ̯<><CCAF>;
|
|||
|
|
_txtTip = static_cast<Text*>(_MainPanel->getChildByName("txtTip"));
|
|||
|
|
CC_ASSERT(_txtTip != nullptr);
|
|||
|
|
_txtTip->setVisible(true);
|
|||
|
|
_txtTip->setString("");
|
|||
|
|
|
|||
|
|
// ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ;
|
|||
|
|
_sprSelectUserTip = static_cast<Sprite*>(_MainPanel->getChildByName("sprSelectUserTip"));
|
|||
|
|
CC_ASSERT(_sprSelectUserTip != nullptr);
|
|||
|
|
_sprSelectUserTip->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
|||
|
|
_ptSendCardPos = _MainPanel->getChildByName("imgCard")->getPosition();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ͼƬ;
|
|||
|
|
_imgAllChips = static_cast<ImageView*>(_MainPanel->getChildByName("imgAllChips"));
|
|||
|
|
CC_ASSERT(_imgAllChips!=nullptr);
|
|||
|
|
_imgAllChips->setVisible(false);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD>ı<EFBFBD>;
|
|||
|
|
_txtAllChips = static_cast<Text*>(_imgAllChips->getChildByName("txtNum"));
|
|||
|
|
CC_ASSERT(_txtAllChips!=nullptr);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־;
|
|||
|
|
m_pVoiceNode = (Node*)m_rootNode->getChildByName("VoiceNode");
|
|||
|
|
CC_ASSERT(m_pVoiceNode != nullptr);
|
|||
|
|
m_pVoiceNode->setVisible(false);
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
std::string strName = StringUtils::format("panelChair_%d", i);
|
|||
|
|
Layout* layout = static_cast<Layout*>(_MainPanel->getChildByName(strName));
|
|||
|
|
CC_ASSERT(layout!=nullptr);
|
|||
|
|
|
|||
|
|
m_aryPlayer[i] = new ZJHGamePlayer(i, layout);
|
|||
|
|
|
|||
|
|
layout->addClickEventListener([i, this](Ref* pSender){
|
|||
|
|
CC_ASSERT(pSender != nullptr);
|
|||
|
|
if (nullptr == pSender) return;
|
|||
|
|
|
|||
|
|
if ((m_aryPlayer[i] != nullptr) && m_aryPlayer[i]->getUserItem(false) != nullptr)
|
|||
|
|
{
|
|||
|
|
PlayerScene* playerScene = PlayerScene::create();
|
|||
|
|
playerScene->showPlayerInfo(m_aryPlayer[i]);
|
|||
|
|
this->addChild(playerScene, ZO_TRUSTEE);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
m_aryPlayer[i]->setCompareClickCallback([this](uint16 wChairID){
|
|||
|
|
// ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>;
|
|||
|
|
for (int j = 0; j < ZJH_GAME_PLAYER; j++)
|
|||
|
|
{
|
|||
|
|
if ((j != ZJH_VIEW_SELF_ID) && (_aryGamingStatus[j]!=ZJH_ST_GAMING_NULL))
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[j]->setCompareVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
uint16 wMyChairID = getSelfChairID();
|
|||
|
|
if ((_wCurrentUser==wMyChairID) && (cbMyStatus == ZJH_ST_GAMING_HIDDEN || cbMyStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_COMPARE_CARD, wChairID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_sprSelectUserTip->setVisible(false);
|
|||
|
|
showOperatePanel(false, ZJH_OPERATE_PANEL);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (i==ZJH_VIEW_SELF_ID)
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[i]->setLookCardClickCallback(CC_CALLBACK_1(ZJHGameScene::onLookCardButtonClick, this));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pLocalPlayer = m_aryPlayer[ZJH_VIEW_SELF_ID];
|
|||
|
|
|
|||
|
|
auto exitCallFunc = [=](Ref*){
|
|||
|
|
auto callback = [=](){
|
|||
|
|
onClickExitGameButton(nullptr);
|
|||
|
|
|
|||
|
|
this->runAction(Sequence::createWithTwoActions(DelayTime::create(0.2f), CallFunc::create([=]{
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(LEAVE_GAME);
|
|||
|
|
})));
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
PopScene::Instance().show(utility::a_u8("<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ҫ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), callback, nullptr);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
_btnInvite->addClickEventListener(CC_CALLBACK_1(ZJHGameScene::onInviteButtonClick, this));
|
|||
|
|
|
|||
|
|
// <20><>ɢ<EFBFBD><C9A2><EFBFBD>亯<EFBFBD><E4BAAF>;
|
|||
|
|
auto callback = [this](){
|
|||
|
|
onEventAgreeDismissRoom(true);
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
_btnDismiss->addClickEventListener([=](Ref* pSender) {
|
|||
|
|
// <20><>ɢ;
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
std::string strTip;
|
|||
|
|
if (0 == m_PrivateRoomInfo.dwPlayCout && false == m_PrivateRoomInfo.bStartGame)
|
|||
|
|
{
|
|||
|
|
strTip = "<EFBFBD>ƾֿ<EFBFBD>ʼǰ<EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD><EFBFBD>䲻<EFBFBD>۷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD>";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strTip = "<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ɢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
PopScene::Instance().show(utility::a_u8(strTip.c_str()), callback, nullptr);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// ˽<>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
_OpenResultScene = ZJHOpenResultScene::create();
|
|||
|
|
addChild(_OpenResultScene);
|
|||
|
|
_OpenResultScene->setVisible(false);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>ؼ<EFBFBD><D8BC>ļ<EFBFBD><C4BC><EFBFBD> ;
|
|||
|
|
auto keyListener = EventListenerKeyboard::create();
|
|||
|
|
//<2F>ͻص<CDBB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;
|
|||
|
|
keyListener->onKeyReleased = [=](EventKeyboard::KeyCode keyCode, Event * pEvent){
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>;
|
|||
|
|
if (keyCode == EventKeyboard::KeyCode::KEY_ESCAPE)
|
|||
|
|
{
|
|||
|
|
exitCallFunc(nullptr);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
//<2F><><EFBFBD>ӵ<EFBFBD><D3B5>¼<EFBFBD><C2BC>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD> ;
|
|||
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this);
|
|||
|
|
|
|||
|
|
SpriteFrameCache* pSpriteFrameCache = SpriteFrameCache::getInstance();
|
|||
|
|
pSpriteFrameCache->addSpriteFramesWithFile("Games/ZJH/Cards/PinLargeCard1.plist");
|
|||
|
|
pSpriteFrameCache->addSpriteFramesWithFile("Games/ZJH/Cards/PinLargeCard2.plist");
|
|||
|
|
|
|||
|
|
loadShortChat("Games/DDZ/ShortChat/ChatInfo.json");
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>;
|
|||
|
|
resetScene();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
ResetAllData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>;
|
|||
|
|
void ZJHGameScene::resetScene(bool bAll/* = false*/)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UI;
|
|||
|
|
for (uint8 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[i]->resetUI(bAll);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_ChipPanel->removeAllChildren();
|
|||
|
|
_aryChipNode.clear();
|
|||
|
|
|
|||
|
|
_sprSelectUserTip->setVisible(false);
|
|||
|
|
|
|||
|
|
_OperBtnsPanel->setVisible(false);
|
|||
|
|
_AddChipPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
_ResultPanel->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::resetData()
|
|||
|
|
{
|
|||
|
|
m_cbGameStatus = ZJH_GS_FREE;
|
|||
|
|
|
|||
|
|
_wBankerUser = INVALID_CHAIR;
|
|||
|
|
_lCurChipScore = 0;
|
|||
|
|
_wCurrentUser = INVALID_CHAIR;
|
|||
|
|
_dwOperateCode = 0;
|
|||
|
|
_lTotalChipScore = 0;
|
|||
|
|
|
|||
|
|
_bHasShowLookCard = false;
|
|||
|
|
_bComparingCard = false;
|
|||
|
|
_bGameEnd = false;
|
|||
|
|
|
|||
|
|
zeromemory(&_cmdCompareCard, sizeof(_cmdCompareCard));
|
|||
|
|
zeromemory(&_cmdGameEnd, sizeof(_cmdGameEnd));
|
|||
|
|
|
|||
|
|
for (uint8 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
_aryGamingStatus[i] = ZJH_ST_GAMING_NULL;
|
|||
|
|
_aryUserChipScore[i] = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
zeromemory(_aryHandCardData, sizeof(_aryHandCardData));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>൱<EFBFBD><E0B5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뿪);
|
|||
|
|
void ZJHGameScene::ResetAllData()
|
|||
|
|
{
|
|||
|
|
resetScene();
|
|||
|
|
|
|||
|
|
resetData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::ResetTable()
|
|||
|
|
{
|
|||
|
|
resetScene(true);
|
|||
|
|
|
|||
|
|
resetData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>;
|
|||
|
|
const std::string ZJHGameScene::getShortChatSoundPath(uint8 cbGender, int nIndex)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>;
|
|||
|
|
std::string strFilePath = "Games/DDZ/ShortChat/";
|
|||
|
|
if (cbGender == enMan)
|
|||
|
|
{
|
|||
|
|
strFilePath += StringUtils::format("man/%d.mp3", nIndex);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strFilePath += StringUtils::format("woman/%d.mp3", nIndex);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return strFilePath;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
void ZJHGameScene::initNet()
|
|||
|
|
{
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_GAME_START, this, ZJHGameScene::onSubGameStart);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_START_CHIP, this, ZJHGameScene::onSubStartChip);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_GIVE_UP, this, ZJHGameScene::onSubGiveUp);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_USER_CHIP, this, ZJHGameScene::onSubUserChip);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_LOOK_CARD, this, ZJHGameScene::onSubLookCard);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_COMPARE_CARD, this, ZJHGameScene::onSubCompareCard);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_GAME_END, this, ZJHGameScene::onSubGameEnd);
|
|||
|
|
addNetCBDefine(ZJH_SUB_S_CHEAT_CARD, this, ZJHGameScene::onSubCheatCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool ZJHGameScene::OnEventSceneMessage(uint8 cbGameStatus, bool bLookonUser, void* pData, int nDataSize)
|
|||
|
|
{
|
|||
|
|
m_cbGameStatus = cbGameStatus;
|
|||
|
|
|
|||
|
|
switch (cbGameStatus)
|
|||
|
|
{
|
|||
|
|
case ZJH_GS_FREE:
|
|||
|
|
{
|
|||
|
|
return onGameSceneFree(pData, nDataSize);
|
|||
|
|
}
|
|||
|
|
case ZJH_GS_SEND_CARD:
|
|||
|
|
{
|
|||
|
|
return onGameSceneSendCard(pData, nDataSize);
|
|||
|
|
}
|
|||
|
|
case ZJH_GS_PLAYING:
|
|||
|
|
{
|
|||
|
|
return onGameScenePlaying(pData, nDataSize);
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ָ<EFBFBD><D6B8>ձճ<D5B1><D5B3><EFBFBD>;
|
|||
|
|
bool ZJHGameScene::onGameSceneFree(void* pData, int nDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(nDataSize == sizeof(ZJH_CMD_S_StatusFree));
|
|||
|
|
ZJH_CMD_S_StatusFree* pStatusFree = (ZJH_CMD_S_StatusFree*)pData;
|
|||
|
|
|
|||
|
|
initStatusFree(pStatusFree);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>;
|
|||
|
|
bool ZJHGameScene::onGameSceneSendCard(void* pData, int nDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(nDataSize == sizeof(ZJH_CMD_S_StatusSendCard));
|
|||
|
|
ZJH_CMD_S_StatusSendCard* pStatusSend = (ZJH_CMD_S_StatusSendCard*)pData;
|
|||
|
|
|
|||
|
|
initStatusFree(&pStatusSend->stBase);
|
|||
|
|
|
|||
|
|
_wBankerUser = pStatusSend->wBankerUser;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
_aryGamingStatus[wViewID] = pStatusSend->aryGamingStatus[i];
|
|||
|
|
_aryUserChipScore[wViewID] = pStatusSend->aryUserChipScore[i];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint8 cbUserStatus = m_pLocalPlayer->GetUserStatus();
|
|||
|
|
if (pStatusSend->bSendOver && cbUserStatus == US_PLAYING)
|
|||
|
|
{
|
|||
|
|
sendSendCardOverMsg();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD>г<EFBFBD><D0B3><EFBFBD>;
|
|||
|
|
bool ZJHGameScene::onGameScenePlaying(void* pData, int nDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(nDataSize == sizeof(ZJH_CMD_S_StatusPlay));
|
|||
|
|
ZJH_CMD_S_StatusPlay* pStatusPlay = (ZJH_CMD_S_StatusPlay*)pData;
|
|||
|
|
|
|||
|
|
initStatusFree(&pStatusPlay->stBase);
|
|||
|
|
|
|||
|
|
_wBankerUser = pStatusPlay->wBankerUser;
|
|||
|
|
_wCurrentUser = pStatusPlay->wCurrentUser;
|
|||
|
|
|
|||
|
|
memcpy(_aryHandCardData, pStatusPlay->aryHandCardData, sizeof(_aryHandCardData));
|
|||
|
|
|
|||
|
|
uint16 wMyChairID = getSelfChairID();
|
|||
|
|
CC_ASSERT(wMyChairID<ZJH_GAME_PLAYER);
|
|||
|
|
|
|||
|
|
_lTotalChipScore = 0;
|
|||
|
|
for (int i = 0; i<ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
uint8 cbGamingStatus = pStatusPlay->aryGamingStatus[i];
|
|||
|
|
_aryGamingStatus[wViewID] = cbGamingStatus;
|
|||
|
|
_aryUserChipScore[wViewID] = pStatusPlay->aryUserChipScore[i];
|
|||
|
|
|
|||
|
|
if (cbGamingStatus != ZJH_ST_GAMING_NULL)
|
|||
|
|
{
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
CC_ASSERT(pPlayer!=nullptr);
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD>ƺ<EFBFBD>״̬;
|
|||
|
|
pPlayer->showBackCard();
|
|||
|
|
pPlayer->showHandStatus(cbGamingStatus);
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>;
|
|||
|
|
pPlayer->setAddChip(_lCurChipScore);
|
|||
|
|
pPlayer->setAllChip(_aryUserChipScore[wViewID]);
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (wMyChairID == i)
|
|||
|
|
{
|
|||
|
|
pPlayer->showCard(_aryHandCardData);
|
|||
|
|
|
|||
|
|
if (ZJH_ST_GAMING_HIDDEN == cbGamingStatus)
|
|||
|
|
{
|
|||
|
|
pPlayer->setLookCardVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
playChipAni(wViewID, _aryUserChipScore[wViewID]);
|
|||
|
|
|
|||
|
|
_lTotalChipScore += _aryUserChipScore[wViewID];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
setTotalChipNumber(_lTotalChipScore);
|
|||
|
|
|
|||
|
|
ZJHChipInfo mChipInfo;
|
|||
|
|
mChipInfo.cbCurRound = pStatusPlay->stBase.cbCurRound;
|
|||
|
|
mChipInfo.wCurrentUser = pStatusPlay->wCurrentUser;
|
|||
|
|
mChipInfo.lCurChipScore = pStatusPlay->stBase.lCurChipScore;
|
|||
|
|
mChipInfo.dwOperateCode = pStatusPlay->dwOperateCode;
|
|||
|
|
|
|||
|
|
procChipInfo(INVALID_CHAIR, &mChipInfo);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ZJHGameScene::initStatusFree(ZJHStatusBase* pStatusBase)
|
|||
|
|
{
|
|||
|
|
_lCellScore = pStatusBase->lCellScore;
|
|||
|
|
_cbCurRound = pStatusBase->cbCurRound;
|
|||
|
|
_cbMaxRound = pStatusBase->cbMaxRound;
|
|||
|
|
_lCurChipScore = pStatusBase->lCurChipScore;
|
|||
|
|
_lMaxChipScore = pStatusBase->lMaxChipScore;
|
|||
|
|
_wOperTimeOut = pStatusBase->wOperTimeOut;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ZJHGameScene::onSubGameStart(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(wDataSize == sizeof(ZJH_CMD_S_GameStart));
|
|||
|
|
ZJH_CMD_S_GameStart* pGameStart = (ZJH_CMD_S_GameStart*)pBuffer;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
ResetAllData();
|
|||
|
|
|
|||
|
|
m_cbGameStatus = ZJH_GS_PLAYING;
|
|||
|
|
|
|||
|
|
_cbCurRound = pGameStart->cbCurRound;
|
|||
|
|
_wBankerUser = pGameStart->wBankerUser;
|
|||
|
|
_lCurChipScore = pGameStart->lCurChipScore;
|
|||
|
|
|
|||
|
|
for (uint8 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
|
|||
|
|
_aryGamingStatus[wViewID] = pGameStart->aryGamingStatus[i];
|
|||
|
|
_aryUserChipScore[wViewID] = pGameStart->aryUserChipScore[i];
|
|||
|
|
|
|||
|
|
if (ZJH_ST_GAMING_HIDDEN == _aryGamingStatus[wViewID])
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wViewID]->setAddChip(0);
|
|||
|
|
m_aryPlayer[wViewID]->setAllChip(_aryUserChipScore[wViewID]);
|
|||
|
|
|
|||
|
|
playChipAni(wViewID, _aryUserChipScore[wViewID]);
|
|||
|
|
|
|||
|
|
_lTotalChipScore += _aryUserChipScore[wViewID];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
setTotalChipNumber(_lTotalChipScore);
|
|||
|
|
|
|||
|
|
startSendCardAni();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ͬIP<49><50>ʾ;
|
|||
|
|
IpTipScene::Instance().hide();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ʼ<EFBFBD><CABC>ע;
|
|||
|
|
void ZJHGameScene::onSubStartChip(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(wDataSize == sizeof(ZJH_CMD_S_StartChip));
|
|||
|
|
ZJH_CMD_S_StartChip* pStartChip = (ZJH_CMD_S_StartChip*)pBuffer;
|
|||
|
|
|
|||
|
|
procChipInfo(INVALID_CHAIR, pStartChip);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onSubGiveUp(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(sizeof(ZJH_CMD_S_GiveUp) == wDataSize);
|
|||
|
|
ZJH_CMD_S_GiveUp* pGiveUp = (ZJH_CMD_S_GiveUp*)pBuffer;
|
|||
|
|
|
|||
|
|
uint16 wViewID = SwitchViewChairID(pGiveUp->wGiveUpUser);
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
|
|||
|
|
_aryGamingStatus[wViewID] = ZJH_ST_GAMING_GIVEUP;
|
|||
|
|
pPlayer->showHandStatus(ZJH_ST_GAMING_GIVEUP);
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID == wViewID)
|
|||
|
|
{
|
|||
|
|
pPlayer->setLookCardVisible(false);
|
|||
|
|
|
|||
|
|
for (uint16 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (pGiveUp->wGiveUpUser == i)
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
uint8 cbPlayerStatus = _aryGamingStatus[wViewID];
|
|||
|
|
if ((cbPlayerStatus == ZJH_ST_GAMING_HIDDEN) || (cbPlayerStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wViewID]->setCompareVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_sprSelectUserTip->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
procChipInfo(wViewID, &pGiveUp->stChipInfo);
|
|||
|
|
|
|||
|
|
playEffect("GiveUp");
|
|||
|
|
playEffectEx(pPlayer->GetGender(), "fangqi");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onSubUserChip(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(sizeof(ZJH_CMD_S_ChipScore) == wDataSize);
|
|||
|
|
ZJH_CMD_S_ChipScore* pChipScore = (ZJH_CMD_S_ChipScore*)pBuffer;
|
|||
|
|
|
|||
|
|
uint16 wViewID = SwitchViewChairID(pChipScore->wChipUser);
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
|
|||
|
|
pPlayer->showOperateTip(pChipScore->dwOperateCode, pChipScore->lChipScore);
|
|||
|
|
pPlayer->setAddChip(pChipScore->lChipScore);
|
|||
|
|
pPlayer->setAllChip(pChipScore->lTtlChipScore);
|
|||
|
|
|
|||
|
|
playChipAni(wViewID, pChipScore->lChipScore);
|
|||
|
|
procChipInfo(wViewID, &pChipScore->stChipInfo);
|
|||
|
|
|
|||
|
|
_lTotalChipScore += pChipScore->lChipScore;
|
|||
|
|
setTotalChipNumber(_lTotalChipScore);
|
|||
|
|
|
|||
|
|
if ((pChipScore->dwOperateCode&ZJH_OPERATE_FOLLOW)>0)
|
|||
|
|
{
|
|||
|
|
playEffect("FollowChip");
|
|||
|
|
playEffectEx(pPlayer->GetGender(), "genzhu_0");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
playEffect("AddChip");
|
|||
|
|
playEffectEx(pPlayer->GetGender(), "jiazhu");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onSubLookCard(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(sizeof(ZJH_CMD_S_LookCard) == wDataSize);
|
|||
|
|
ZJH_CMD_S_LookCard* pLookCard = (ZJH_CMD_S_LookCard*)pBuffer;
|
|||
|
|
|
|||
|
|
uint16 wViewID = SwitchViewChairID(pLookCard->wLookUser);
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
|
|||
|
|
_aryGamingStatus[wViewID] = ZJH_ST_GAMING_LOOK;
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID==wViewID)
|
|||
|
|
{
|
|||
|
|
pPlayer->showCard(pLookCard->aryCardData);
|
|||
|
|
pPlayer->setLookCardVisible(false);
|
|||
|
|
|
|||
|
|
uint8 cbCardType = m_GameLogic.GetCardType(pLookCard->aryCardData, ZJH_MAX_COUNT);
|
|||
|
|
pPlayer->showCardTypeEx(cbCardType);
|
|||
|
|
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser == wSelfChairID)
|
|||
|
|
{
|
|||
|
|
procChipInfo(wViewID, &pLookCard->stChipInfo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pPlayer->showHandStatus(ZJH_ST_GAMING_LOOK);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
playEffect("LookCard");
|
|||
|
|
playEffectEx(pPlayer->GetGender(), "kanpai");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onSubCompareCard(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(wDataSize == sizeof(ZJH_CMD_S_CompareCard));
|
|||
|
|
ZJH_CMD_S_CompareCard* pCompare = (ZJH_CMD_S_CompareCard*)pBuffer;
|
|||
|
|
|
|||
|
|
_bComparingCard = true;
|
|||
|
|
memcpy(&_cmdCompareCard, pCompare, sizeof(ZJH_CMD_S_CompareCard));
|
|||
|
|
|
|||
|
|
uint16 wViewID = SwitchViewChairID(pCompare->wChairID);
|
|||
|
|
uint16 wCompareViewID = SwitchViewChairID(pCompare->wCompareUser);
|
|||
|
|
|
|||
|
|
ZJHGamePlayer* pOperPlayer = m_aryPlayer[wViewID];
|
|||
|
|
pOperPlayer->closeClock();
|
|||
|
|
pOperPlayer->showOperateTip(ZJH_OPERATE_COMPARE_CARD, pCompare->lChipScore);
|
|||
|
|
pOperPlayer->setAddChip(pCompare->lChipScore);
|
|||
|
|
pOperPlayer->setAllChip(pCompare->lTtlChipScore);
|
|||
|
|
|
|||
|
|
playChipAni(wViewID, pCompare->lChipScore);
|
|||
|
|
|
|||
|
|
_lTotalChipScore += pCompare->lChipScore;
|
|||
|
|
setTotalChipNumber(_lTotalChipScore);
|
|||
|
|
|
|||
|
|
_txtTip->setString("");
|
|||
|
|
|
|||
|
|
playEffectEx(pOperPlayer->GetGender(), "bipai");
|
|||
|
|
|
|||
|
|
_ComparePanel->setVisible(true);
|
|||
|
|
_armCompare->setVisible(true);
|
|||
|
|
ArmatureAnimation* pAniCompare = _armCompare->getAnimation();
|
|||
|
|
if (pAniCompare != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniCompare->play("Duel");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
Sprite* sprLeftHead = pOperPlayer->getHeadSprite();
|
|||
|
|
SpriteFrame* sprLeftFrame = sprLeftHead->getSpriteFrame();
|
|||
|
|
|
|||
|
|
_sprLeftHead->setSpriteFrame(sprLeftFrame->clone());
|
|||
|
|
_txtLeftNickName->setString(pOperPlayer->GetNickName());
|
|||
|
|
_sprLeftBackCard->setColor(Color3B(0xFF, 0xFF, 0xFF));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
ZJHGamePlayer* pComparePlayer = m_aryPlayer[wCompareViewID];
|
|||
|
|
Sprite* sprRightHead = pComparePlayer->getHeadSprite();
|
|||
|
|
SpriteFrame* sprRightFrame = sprRightHead->getSpriteFrame();
|
|||
|
|
|
|||
|
|
_sprRightHead->setSpriteFrame(sprRightFrame->clone());
|
|||
|
|
_txtRightNickName->setString(pComparePlayer->GetNickName());
|
|||
|
|
_sprRightBackCard->setColor(Color3B(0xFF, 0xFF, 0xFF));
|
|||
|
|
|
|||
|
|
auto callFunc = CallFunc::create([this]{
|
|||
|
|
if (_cmdCompareCard.bWin)
|
|||
|
|
{
|
|||
|
|
ArmatureAnimation* pAniRightLose = _armRightLose->getAnimation();
|
|||
|
|
if (pAniRightLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniRightLose->play("lose");
|
|||
|
|
}
|
|||
|
|
_armRightLose->setVisible(true);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ArmatureAnimation* pAniLeftLose = _armLeftLose->getAnimation();
|
|||
|
|
if (pAniLeftLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniLeftLose->play("lose");
|
|||
|
|
}
|
|||
|
|
_armLeftLose->setVisible(true);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
auto actSeq = Sequence::create(DelayTime::create(1.5f), callFunc, nullptr);
|
|||
|
|
_ComparePanel->runAction(actSeq);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::sendSendCardOverMsg()
|
|||
|
|
{
|
|||
|
|
SendSocketData(ZJH_SUB_C_SEND_OVER);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>;
|
|||
|
|
void ZJHGameScene::sendOperateMsg(uint32 dwCode, int lData/* = 0*/)
|
|||
|
|
{
|
|||
|
|
ZJH_CMD_C_UserOperate mUserOper;
|
|||
|
|
mUserOper.dwCode = dwCode;
|
|||
|
|
mUserOper.lData = lData;
|
|||
|
|
|
|||
|
|
SendSocketData(ZJH_SUB_C_USER_OPERATE, &mUserOper, sizeof(ZJH_CMD_C_UserOperate));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::showOperatePanel(bool bShow, uint8 cbPanelType)
|
|||
|
|
{
|
|||
|
|
if (bShow)
|
|||
|
|
{
|
|||
|
|
if (ZJH_OPERATE_PANEL==cbPanelType)
|
|||
|
|
{
|
|||
|
|
_AddChipPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
int nCompareChip = _lCurChipScore;
|
|||
|
|
// <20>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD>;
|
|||
|
|
if (_aryGamingStatus[ZJH_VIEW_SELF_ID] == ZJH_ST_GAMING_LOOK)
|
|||
|
|
{
|
|||
|
|
nCompareChip *= 2;
|
|||
|
|
}
|
|||
|
|
std::string strCompare = StringUtils::format("%d", nCompareChip);
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>;
|
|||
|
|
bool bEnabled = (_dwOperateCode&ZJH_OPERATE_GIVEUP) > 0;
|
|||
|
|
_btnGiveUp->setEnabled(bEnabled);
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Ը<EFBFBD>ע;
|
|||
|
|
bEnabled = (_dwOperateCode&ZJH_OPERATE_FOLLOW) > 0;
|
|||
|
|
_btnFollow->setEnabled(bEnabled);
|
|||
|
|
_txtFollowChip->setString(strCompare);
|
|||
|
|
|
|||
|
|
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>Լ<EFBFBD>ע;
|
|||
|
|
bEnabled = (_dwOperateCode&ZJH_OPERATE_ADD_CHIP) > 0;
|
|||
|
|
_btnAddChip->setEnabled(bEnabled);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>;
|
|||
|
|
bEnabled = (_dwOperateCode&ZJH_OPERATE_COMPARE_CARD) > 0;
|
|||
|
|
_btnCompare->setEnabled(bEnabled);
|
|||
|
|
|
|||
|
|
_txtCompareChip->setString(strCompare);
|
|||
|
|
|
|||
|
|
Size sizeOper = _OperBtnsPanel->getContentSize();
|
|||
|
|
_OperBtnsPanel->setPositionY(-sizeOper.height / 2);
|
|||
|
|
_OperBtnsPanel->setVisible(true);
|
|||
|
|
auto actMove = Speed::create(MoveBy::create(0.5f, Vec2(0, sizeOper.height)), 2.0f);
|
|||
|
|
_OperBtnsPanel->runAction(actMove);
|
|||
|
|
}
|
|||
|
|
else if (ZJH_ADD_CHIP_PANEL == cbPanelType)
|
|||
|
|
{
|
|||
|
|
_OperBtnsPanel->setVisible(false);
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 4; i++)
|
|||
|
|
{
|
|||
|
|
bool bEnabled = (_lCurChipScore < (i+2));
|
|||
|
|
_aryAddChip[i]->setEnabled(bEnabled);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Size sizeAdd = _AddChipPanel->getContentSize();
|
|||
|
|
_AddChipPanel->setPositionY(-sizeAdd.height / 2);
|
|||
|
|
_AddChipPanel->setVisible(true);
|
|||
|
|
auto actMove = Speed::create(MoveBy::create(0.5f, Vec2(0, sizeAdd.height)), 2.0f);
|
|||
|
|
_AddChipPanel->runAction(actMove);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_OperBtnsPanel->setVisible(false);
|
|||
|
|
_AddChipPanel->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::setTotalChipNumber(int nTotalNumber)
|
|||
|
|
{
|
|||
|
|
_imgAllChips->setVisible(true);
|
|||
|
|
_txtAllChips->setString(StringUtils::format("%d", nTotalNumber));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
void ZJHGameScene::onGiveUpButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
|
|||
|
|
auto callback = [=](){
|
|||
|
|
if (_aryGamingStatus[ZJH_VIEW_SELF_ID] != ZJH_ST_GAMING_NULL)
|
|||
|
|
{
|
|||
|
|
showOperatePanel(false);
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_GIVEUP);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
PopScene::Instance().show(utility::a_u8("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><EFBFBD>Ƿ<EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), callback, nullptr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD>ť;
|
|||
|
|
void ZJHGameScene::onCompareButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser==wSelfChairID || (cbMyStatus == ZJH_ST_GAMING_HIDDEN || cbMyStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
uint16 wLastPlayerChairID = INVALID_CHAIR;
|
|||
|
|
std::vector<uint16> aryPlayer;
|
|||
|
|
for (uint16 i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
if (ZJH_VIEW_SELF_ID == wViewID)
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint8 cbPlayerStatus = _aryGamingStatus[wViewID];
|
|||
|
|
if ((cbPlayerStatus == ZJH_ST_GAMING_HIDDEN) || (cbPlayerStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
//m_aryPlayer[wViewID]->setCompareVisible(true);
|
|||
|
|
aryPlayer.push_back(wViewID);
|
|||
|
|
wLastPlayerChairID = i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
size_t nLength = aryPlayer.size();
|
|||
|
|
if ((1 == nLength) && (wLastPlayerChairID != INVALID_CHAIR))
|
|||
|
|
{
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_COMPARE_CARD, wLastPlayerChairID);
|
|||
|
|
showOperatePanel(false, ZJH_OPERATE_PANEL);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
for (size_t i = 0; i < nLength; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = aryPlayer.at(i);
|
|||
|
|
m_aryPlayer[wViewID]->setCompareVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_sprSelectUserTip->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ť;
|
|||
|
|
void ZJHGameScene::onAddChipButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser == wSelfChairID && (cbMyStatus == ZJH_ST_GAMING_HIDDEN || cbMyStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
showOperatePanel(true, ZJH_ADD_CHIP_PANEL);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ť;
|
|||
|
|
void ZJHGameScene::onFollowButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser == wSelfChairID && (cbMyStatus == ZJH_ST_GAMING_HIDDEN || cbMyStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_FOLLOW);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ť;
|
|||
|
|
void ZJHGameScene::onAddCancelButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
showOperatePanel(true, ZJH_OPERATE_PANEL);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ť;
|
|||
|
|
void ZJHGameScene::onAddChipBtnsClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
Button* pButton = (Button*)pSender;
|
|||
|
|
int nChipScore = pButton->getTag();
|
|||
|
|
|
|||
|
|
if (nChipScore <= _lMaxChipScore && nChipScore > _lCurChipScore )
|
|||
|
|
{
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser == wSelfChairID && (cbMyStatus == ZJH_ST_GAMING_HIDDEN || cbMyStatus == ZJH_ST_GAMING_LOOK))
|
|||
|
|
{
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_ADD_CHIP, nChipScore);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD>ť;
|
|||
|
|
void ZJHGameScene::onLookCardButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
uint8 cbMyStatus = _aryGamingStatus[ZJH_VIEW_SELF_ID];
|
|||
|
|
if (cbMyStatus == ZJH_ST_GAMING_HIDDEN )
|
|||
|
|
{
|
|||
|
|
sendOperateMsg(ZJH_OPERATE_LOOK);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>밴ť<EBB0B4><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onInviteButtonClick(Ref* pSender)
|
|||
|
|
{
|
|||
|
|
playBtnClickEffect();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD>857252<35><32>8<EFBFBD>֣<EFBFBD><D6A3><EFBFBD>ׯ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>¥<EFBFBD><C2A5><EFBFBD><EFBFBD>ͷһЦ<D2BB><D0A6>ͬһ<CDAC>衣
|
|||
|
|
std::string strText = StringUtils::format("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:[%u] %d <20><>, %s.", m_PrivateRoomInfo.dwRoomNum, m_PrivateRoomInfo.dwPlayTotal, m_strGameRuleInfo.c_str());
|
|||
|
|
std::string strFriendUrl = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_FRIEND_RUL);
|
|||
|
|
std::string strUrl = StringUtils::format("%s?param=%d", strFriendUrl.c_str(), m_PrivateRoomInfo.dwRoomNum);
|
|||
|
|
MissionWeiXin::Instance().shareUrlWeiXin(strUrl, utility::a_u8("ը<EFBFBD><EFBFBD><EFBFBD><EFBFBD>") , utility::a_u8(strText));
|
|||
|
|
|
|||
|
|
//SelectShareScene::Instance().shareRoomInfo(strUrl, utility::a_u8("ը<><D5A8><EFBFBD><EFBFBD>"), strText, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::startSendCardAni()
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>;
|
|||
|
|
float fDelayTime = playSendCardAni() + 0.1f;
|
|||
|
|
uint8 cbUserStatus = m_pLocalPlayer->GetUserStatus();
|
|||
|
|
if (cbUserStatus == US_PLAYING)
|
|||
|
|
{
|
|||
|
|
auto callback = [=]() {
|
|||
|
|
//if (ZJH_ST_GAMING_HIDDEN==_aryGamingStatus[ZJH_VIEW_SELF_ID])
|
|||
|
|
//{
|
|||
|
|
// m_aryPlayer[ZJH_VIEW_SELF_ID]->setLookCardVisible(true);
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
sendSendCardOverMsg();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
runAction(Sequence::create(DelayTime::create(fDelayTime), CallFunc::create(callback), nullptr));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>;
|
|||
|
|
void ZJHGameScene::movementEventCallFunc(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (movementType == cocostudio::COMPLETE)
|
|||
|
|
{
|
|||
|
|
if ("Duel" == movementID)
|
|||
|
|
{
|
|||
|
|
compareCardEnd();
|
|||
|
|
}
|
|||
|
|
else if ("lose" == movementID)
|
|||
|
|
{
|
|||
|
|
if (_cmdCompareCard.bWin)
|
|||
|
|
{
|
|||
|
|
_sprRightBackCard->setColor(Color3B(0x7F, 0x7F, 0x7F));
|
|||
|
|
_sprRightFlag->setVisible(true);
|
|||
|
|
_sprRightFlag->setTexture("Games/ZJH/Table/lose.png");
|
|||
|
|
|
|||
|
|
_sprLeftFlag->setVisible(true);
|
|||
|
|
_sprLeftFlag->setTexture("Games/ZJH/Table/win.png");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_sprLeftBackCard->setColor(Color3B(0x7F, 0x7F, 0x7F));
|
|||
|
|
|
|||
|
|
_sprRightFlag->setVisible(true);
|
|||
|
|
_sprRightFlag->setTexture("Games/ZJH/Table/win.png");
|
|||
|
|
|
|||
|
|
_sprLeftFlag->setVisible(true);
|
|||
|
|
_sprLeftFlag->setTexture("Games/ZJH/Table/lose.png");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_ComparePanel->runAction(Sequence::create(DelayTime::create(0.8f), Hide::create(), nullptr));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::onSubGameEnd(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(wDataSize == sizeof(ZJH_CMD_S_GameEnd));
|
|||
|
|
ZJH_CMD_S_GameEnd* pGameEnd = (ZJH_CMD_S_GameEnd*)pBuffer;
|
|||
|
|
|
|||
|
|
_bGameEnd = true;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӺŶ<D3BA>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ͼID<49><44><EFBFBD><EFBFBD>ֹ˽<D6B9>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD>λ<EFBFBD>ñ<EFBFBD>ΪINVALID;
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
_aryChairToViewID[i] = wViewID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_bComparingCard)
|
|||
|
|
{
|
|||
|
|
memcpy(&_cmdGameEnd, pGameEnd, sizeof(_cmdGameEnd));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
procGameEnd(pGameEnd);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
void ZJHGameScene::onSubCheatCard(const void * pBuffer, uint16 wDataSize)
|
|||
|
|
{
|
|||
|
|
//У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(wDataSize == sizeof(ZJH_CMD_S_CheatCardInfo));
|
|||
|
|
ZJH_CMD_S_CheatCardInfo* pCheatCard = (ZJH_CMD_S_CheatCardInfo*)pBuffer;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
CC_ASSERT(wViewID != INVALID_CHAIR);
|
|||
|
|
uint8 cbGamingStatus = pCheatCard->aryGamingStatus[i];
|
|||
|
|
|
|||
|
|
if (cbGamingStatus != ZJH_ST_GAMING_NULL && cbGamingStatus != ZJH_ST_GAMING_GIVEUP)
|
|||
|
|
{
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
pPlayer->showCard(pCheatCard->aryHandCardData[i]);
|
|||
|
|
uint8 cbCardType = m_GameLogic.GetCardType(pCheatCard->aryHandCardData[i], ZJH_MAX_COUNT);
|
|||
|
|
pPlayer->showCardType(cbCardType);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::procChipInfo(uint16 wLastViewID, ZJHChipInfo* pChipInfo)
|
|||
|
|
{
|
|||
|
|
if (_cbCurRound != pChipInfo->cbCurRound)
|
|||
|
|
{
|
|||
|
|
_cbCurRound = pChipInfo->cbCurRound;
|
|||
|
|
_txtOpenCardRound->setString(StringUtils::format("%d/%d", _cbCurRound, _cbMaxRound));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_wCurrentUser = pChipInfo->wCurrentUser;
|
|||
|
|
_lCurChipScore = pChipInfo->lCurChipScore;
|
|||
|
|
_dwOperateCode = pChipInfo->dwOperateCode;
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID == wLastViewID)
|
|||
|
|
{
|
|||
|
|
showOperatePanel(false, ZJH_OPERATE_PANEL);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ر<EFBFBD><D8B1><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ( wLastViewID < ZJH_GAME_PLAYER )
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wLastViewID]->closeClock();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint16 wMyChairID = getSelfChairID();
|
|||
|
|
if (_wCurrentUser == wMyChairID)
|
|||
|
|
{
|
|||
|
|
showOperatePanel(true, ZJH_OPERATE_PANEL);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint16 wCurViewID = SwitchViewChairID(_wCurrentUser);
|
|||
|
|
if (wCurViewID< ZJH_GAME_PLAYER)
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wCurViewID]->openClock(_wOperTimeOut);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!_bHasShowLookCard && (_cbCurRound>_cbMinLookRound) && (ZJH_ST_GAMING_HIDDEN == _aryGamingStatus[ZJH_VIEW_SELF_ID]))
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[ZJH_VIEW_SELF_ID]->setLookCardVisible(true);
|
|||
|
|
_bHasShowLookCard = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::procGameEnd(ZJH_CMD_S_GameEnd* pGameEnd)
|
|||
|
|
{
|
|||
|
|
_txtTip->setString("");
|
|||
|
|
|
|||
|
|
uint16 wSelfChairID = getSelfChairID();
|
|||
|
|
SCORE lMyResultScore = pGameEnd->aryGameScore[wSelfChairID];
|
|||
|
|
|
|||
|
|
if (pGameEnd->isPrivateEnd)
|
|||
|
|
{
|
|||
|
|
_btnReady->setVisible(false);
|
|||
|
|
_btnPrivateEnd->setVisible(true);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_btnReady->setVisible(true);
|
|||
|
|
_btnPrivateEnd->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_ResultPanel->setVisible(true);
|
|||
|
|
ArmatureAnimation* pAniResult = _pArmatureResult->getAnimation();
|
|||
|
|
if (pAniResult != nullptr)
|
|||
|
|
{
|
|||
|
|
if (lMyResultScore > 0)
|
|||
|
|
{
|
|||
|
|
pAniResult->play("Win", -1, 0);
|
|||
|
|
playEffect("Win");
|
|||
|
|
}
|
|||
|
|
else if (lMyResultScore < 0)
|
|||
|
|
{
|
|||
|
|
pAniResult->play("Lose", -1, 0);
|
|||
|
|
playEffect("Loss");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pAniResult->play("Draw", -1, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_pArmatureResult->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѿ<EFBFBD><D1BF>ư<EFBFBD>ť;
|
|||
|
|
m_aryPlayer[ZJH_VIEW_SELF_ID]->setLookCardVisible(false);
|
|||
|
|
|
|||
|
|
uint16 wWinChairID = INVALID_CHAIR;
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
//uint16 wViewID = SwitchViewChairID(i);
|
|||
|
|
uint16 wViewID = _aryChairToViewID[i];
|
|||
|
|
CC_ASSERT(wViewID!=INVALID_CHAIR);
|
|||
|
|
uint8 cbGamingStatus = pGameEnd->aryGamingStatus[i];
|
|||
|
|
|
|||
|
|
if (cbGamingStatus != ZJH_ST_GAMING_NULL)
|
|||
|
|
{
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
pPlayer->hideHandStatus();
|
|||
|
|
pPlayer->hideCardTypeEx();
|
|||
|
|
pPlayer->closeClock();
|
|||
|
|
if (ZJH_ST_GAMING_GIVEUP==cbGamingStatus)
|
|||
|
|
{
|
|||
|
|
if (wSelfChairID==i)
|
|||
|
|
{
|
|||
|
|
pPlayer->showCard(pGameEnd->aryHandCardData[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pPlayer->showHandStatus(cbGamingStatus);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pPlayer->showCard(pGameEnd->aryHandCardData[i]);
|
|||
|
|
pPlayer->showCardType(pGameEnd->aryCardType[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
playResultScoreAni(wViewID, pGameEnd->aryGameScore[i]);
|
|||
|
|
playXiScoreAni(wViewID, pGameEnd->aryXiScore[i]);
|
|||
|
|
|
|||
|
|
if (pGameEnd->aryGameScore[i]>0)
|
|||
|
|
{
|
|||
|
|
wWinChairID = i;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (INVALID_CHAIR != wWinChairID)
|
|||
|
|
{
|
|||
|
|
//uint16 wWinViewID = SwitchViewChairID(wWinChairID);
|
|||
|
|
uint16 wWinViewID = _aryChairToViewID[wWinChairID];
|
|||
|
|
CC_ASSERT(wWinViewID != INVALID_CHAIR);
|
|||
|
|
const Vec2 ptHeadPos = m_aryPlayer[wWinViewID]->getHeadPos();
|
|||
|
|
//float endPosX = ptHeadPos.x - _ChipPanel->getPositionX();
|
|||
|
|
//float endPosY = ptHeadPos.y - _ChipPanel->getPositionY();
|
|||
|
|
Vec2 ptPos = _ChipPanel->convertToNodeSpace(ptHeadPos);
|
|||
|
|
|
|||
|
|
size_t nCount = _aryChipNode.size();
|
|||
|
|
for (size_t i = 0; i < nCount; i++)
|
|||
|
|
{
|
|||
|
|
ZJHChipNode* pChipNode = _aryChipNode.at(i);
|
|||
|
|
Action* act = Sequence::create(MoveTo::create(0.3f, ptPos), RemoveSelf::create(), nullptr);
|
|||
|
|
pChipNode->runAction(act);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_cbGameStatus = ZJH_GS_FREE;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::compareCardEnd()
|
|||
|
|
{
|
|||
|
|
_ComparePanel->stopAllActions();
|
|||
|
|
_ComparePanel->setVisible(false);
|
|||
|
|
|
|||
|
|
// ֹͣ<CDA3><D6B9><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>;
|
|||
|
|
ArmatureAnimation* pAniCompare = _armCompare->getAnimation();
|
|||
|
|
if (pAniCompare != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniCompare->stop();
|
|||
|
|
}
|
|||
|
|
_armCompare->setVisible(false);
|
|||
|
|
|
|||
|
|
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ<EFBFBD><D2B1><EFBFBD>ʧ<EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>;
|
|||
|
|
ArmatureAnimation* pAniLeftLose = _armLeftLose->getAnimation();
|
|||
|
|
if (pAniLeftLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniLeftLose->stop();
|
|||
|
|
}
|
|||
|
|
_sprLeftFlag->setVisible(false);
|
|||
|
|
_armLeftLose->setVisible(false);
|
|||
|
|
|
|||
|
|
// ֹͣ<CDA3>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ұ<EFBFBD><D2B1><EFBFBD>ʧ<EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>;
|
|||
|
|
ArmatureAnimation* pAniRightLose = _armRightLose->getAnimation();
|
|||
|
|
if (pAniRightLose != nullptr)
|
|||
|
|
{
|
|||
|
|
pAniRightLose->stop();
|
|||
|
|
}
|
|||
|
|
_sprRightFlag->setVisible(false);
|
|||
|
|
_armRightLose->setVisible(false);
|
|||
|
|
|
|||
|
|
|
|||
|
|
uint16 wViewID = INVALID_CHAIR;
|
|||
|
|
uint16 wCompareViewID = INVALID_CHAIR;
|
|||
|
|
|
|||
|
|
if (_bGameEnd)
|
|||
|
|
{
|
|||
|
|
wViewID = _aryChairToViewID[_cmdCompareCard.wChairID];
|
|||
|
|
wCompareViewID = _aryChairToViewID[_cmdCompareCard.wCompareUser];
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
wViewID = SwitchViewChairID(_cmdCompareCard.wChairID);
|
|||
|
|
wCompareViewID = SwitchViewChairID(_cmdCompareCard.wCompareUser);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CC_ASSERT((wViewID != INVALID_CHAIR) && (wCompareViewID != INVALID_CHAIR));
|
|||
|
|
|
|||
|
|
if (_cmdCompareCard.bWin)
|
|||
|
|
{
|
|||
|
|
_aryGamingStatus[wCompareViewID] = ZJH_ST_GAMING_LOSE;
|
|||
|
|
m_aryPlayer[wCompareViewID]->showHandStatus(ZJH_ST_GAMING_LOSE);
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID == wCompareViewID)
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wCompareViewID]->setLookCardVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_aryGamingStatus[wViewID] = ZJH_ST_GAMING_LOSE;
|
|||
|
|
m_aryPlayer[wViewID]->showHandStatus(ZJH_ST_GAMING_LOSE);
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID == wViewID)
|
|||
|
|
{
|
|||
|
|
m_aryPlayer[wViewID]->setLookCardVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_bComparingCard = false;
|
|||
|
|
|
|||
|
|
if (_bGameEnd)
|
|||
|
|
{
|
|||
|
|
procGameEnd(&_cmdGameEnd);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
procChipInfo(wViewID, &_cmdCompareCard.stChipInfo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::OnEventUserEnter(GamePlayer * pPlayer)
|
|||
|
|
{
|
|||
|
|
if (pPlayer->GetChairID() == getSelfChairID())
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>ť״̬;
|
|||
|
|
uint8 cbUserStatus = pPlayer->GetUserStatus();
|
|||
|
|
if (cbUserStatus >= US_READY || m_cbGameStatus>ZJH_GS_FREE)
|
|||
|
|
{
|
|||
|
|
_btnStartGame->setEnabled(false);
|
|||
|
|
|
|||
|
|
//_ResultPanel->setVisible(false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//_btnStartGame->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>״̬<D7B4>ı<EFBFBD>;
|
|||
|
|
void ZJHGameScene::OnEventUserStatus(GamePlayer * pPlayer)
|
|||
|
|
{
|
|||
|
|
OnEventUserEnter(pPlayer);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>;
|
|||
|
|
float ZJHGameScene::playSendCardAni()
|
|||
|
|
{
|
|||
|
|
float fDelaySendTime = 0.1f;
|
|||
|
|
auto pSpriteFrameCache = SpriteFrameCache::getInstance();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_MAX_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
for (int j = 0; j < ZJH_GAME_PLAYER; j++)
|
|||
|
|
{
|
|||
|
|
uint16 wViewID = SwitchViewChairID(j);
|
|||
|
|
|
|||
|
|
if (ZJH_ST_GAMING_HIDDEN==_aryGamingStatus[wViewID])
|
|||
|
|
{
|
|||
|
|
std::string strName = StringUtils::format("SendCardSprite%d", j);
|
|||
|
|
auto pCardSprite = Sprite::createWithSpriteFrameName("L_0x00.png");
|
|||
|
|
CC_ASSERT(pCardSprite!=nullptr);
|
|||
|
|
|
|||
|
|
int nTag = i * 100 + j;
|
|||
|
|
pCardSprite->setTag(nTag);
|
|||
|
|
pCardSprite->setName(strName);
|
|||
|
|
pCardSprite->setPosition(_ptSendCardPos);
|
|||
|
|
_MainPanel->addChild(pCardSprite);
|
|||
|
|
|
|||
|
|
CC_ASSERT(wViewID < ZJH_GAME_PLAYER);
|
|||
|
|
if (wViewID < ZJH_GAME_PLAYER)
|
|||
|
|
{
|
|||
|
|
moveSentCardSprite(pCardSprite, wViewID, i, fDelaySendTime);
|
|||
|
|
}
|
|||
|
|
fDelaySendTime += 0.06f;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return fDelaySendTime;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ZJHGameScene::moveSentCardSprite(Sprite* pCardSprite, uint16 wViewID, uint8 cbIndex, float fDelayTime)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(wViewID<ZJH_GAME_PLAYER);
|
|||
|
|
|
|||
|
|
const Vec2& ptCardPos = m_aryPlayer[wViewID]->getHandCardPos(cbIndex);
|
|||
|
|
Vec2 ptEndPos = ptCardPos;
|
|||
|
|
|
|||
|
|
auto pAction = Spawn::create(MoveTo::create(0.15f, ptEndPos), RotateBy::create(0.15f, 180), nullptr);
|
|||
|
|
|
|||
|
|
auto callback = [=](Node* pNode) {
|
|||
|
|
// <20>滻<EFBFBD><E6BBBB><EFBFBD><EFBFBD>;
|
|||
|
|
int nTag = pNode->getTag();
|
|||
|
|
int nCardIndex = nTag / 100;
|
|||
|
|
|
|||
|
|
m_aryPlayer[wViewID]->addOneCard(0, nCardIndex);
|
|||
|
|
|
|||
|
|
pNode->removeFromParent();
|
|||
|
|
|
|||
|
|
if (ZJH_VIEW_SELF_ID==wViewID)
|
|||
|
|
{
|
|||
|
|
playSendCardEffect();
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
pCardSprite->runAction(Sequence::create(DelayTime::create(fDelayTime), pAction, CallFuncN::create(callback), nullptr));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ӳ<EFBFBD><D3B3>붯<EFBFBD><EBB6AF>;
|
|||
|
|
void ZJHGameScene::playChipAni(uint16 wViewID, int nCount, bool bAction/* = true*/)
|
|||
|
|
{
|
|||
|
|
playEffect("jiaEffect");
|
|||
|
|
|
|||
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD>뾫<EFBFBD><EBBEAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
const Vec2 ptHeadPos = m_aryPlayer[wViewID]->getHeadPos();
|
|||
|
|
Vec2 ptStartPos = _ChipPanel->convertToNodeSpace(ptHeadPos);
|
|||
|
|
//float startPosX = ptHeadPos.x - _ChipPanel->getPositionX();
|
|||
|
|
//float startPosY = ptHeadPos.y - _ChipPanel->getPositionY();
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
int aryChipGroup[5] = { 5, 4, 3, 2, 1 };
|
|||
|
|
for (int i = 0; i < 5; i++)
|
|||
|
|
{
|
|||
|
|
int nNum = nCount / aryChipGroup[i];
|
|||
|
|
if (nNum > 0)
|
|||
|
|
{
|
|||
|
|
for (int k = 0; k < nNum; k++)
|
|||
|
|
{
|
|||
|
|
auto pChipNode = ZJHChipNode::create(aryChipGroup[i]);
|
|||
|
|
float fChipWidth = pChipNode->getContentSize().width;
|
|||
|
|
float fChipHeight = pChipNode->getContentSize().height;
|
|||
|
|
_ChipPanel->addChild(pChipNode);
|
|||
|
|
|
|||
|
|
float endPosX = (fChipWidth / 2) + (_ChipPanel->getContentSize().width - fChipWidth)*cocos2d::rand_0_1();
|
|||
|
|
float endPosY = (fChipHeight / 2) + (_ChipPanel->getContentSize().height - fChipHeight)*cocos2d::rand_0_1();
|
|||
|
|
if (bAction)
|
|||
|
|
{
|
|||
|
|
pChipNode->setPosition(ptStartPos);
|
|||
|
|
pChipNode->runAction(MoveTo::create(0.3f, Vec2(endPosX, endPosY)));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pChipNode->setPosition(Vec2(endPosX, endPosY));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_aryChipNode.push_back(pChipNode);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
nCount %= aryChipGroup[i];
|
|||
|
|
|
|||
|
|
if (0==nCount)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ž<EFBFBD><C5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>;
|
|||
|
|
void ZJHGameScene::playResultScoreAni(int nIndex, SCORE lScore)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(nIndex < ZJH_GAME_PLAYER);
|
|||
|
|
|
|||
|
|
auto pAction1 = ScaleTo::create(0.15f, 0.8f);
|
|||
|
|
auto pAction2 = ScaleTo::create(0.18f, 1.5f);
|
|||
|
|
auto pAction3 = ScaleTo::create(0.12f, 1.2f);
|
|||
|
|
|
|||
|
|
TextAtlas* txtResult = _pTxtResultScore[nIndex];
|
|||
|
|
|
|||
|
|
if (0 != lScore)
|
|||
|
|
{
|
|||
|
|
txtResult->setVisible(true);
|
|||
|
|
txtResult->setScale(0);
|
|||
|
|
|
|||
|
|
if (lScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtResult->setProperty(StringUtils::format("/%d", lScore), "Games/ZJH/Table/imgPositiveFont.png", 26, 35, "/");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtResult->setProperty(StringUtils::format("/%d", std::abs(lScore)), "Games/ZJH/Table/imgNegativeFont.png", 26, 35, "/");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
txtResult->runAction(Sequence::create(pAction1, pAction2, pAction3, nullptr));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtResult->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ϲǮ<CFB2><C7AE><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>;
|
|||
|
|
void ZJHGameScene::playXiScoreAni(int nIndex, SCORE lScore)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(nIndex < ZJH_GAME_PLAYER);
|
|||
|
|
|
|||
|
|
auto pAction1 = ScaleTo::create(0.15f, 0.8f);
|
|||
|
|
auto pAction2 = ScaleTo::create(0.18f, 1.5f);
|
|||
|
|
auto pAction3 = ScaleTo::create(0.12f, 1.2f);
|
|||
|
|
|
|||
|
|
TextAtlas* txtResult = _pTxtXiScore[nIndex];
|
|||
|
|
|
|||
|
|
if (0 != lScore)
|
|||
|
|
{
|
|||
|
|
txtResult->setVisible(true);
|
|||
|
|
txtResult->setScale(0);
|
|||
|
|
|
|||
|
|
if (lScore >= 0)
|
|||
|
|
{
|
|||
|
|
txtResult->setProperty(StringUtils::format(".%d", lScore), "Games/ZJH/Result/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtResult->setProperty(StringUtils::format("/%d", std::abs(lScore)), "Games/ZJH/Result/num_win.png", 38, 55, ".");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
txtResult->runAction(Sequence::create(pAction1, pAction2, pAction3, nullptr));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtResult->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ҽ<EFBFBD><D2BD>Ҹı<D2B8>;
|
|||
|
|
void ZJHGameScene::OnUserScore(GamePlayer* pPlayer)
|
|||
|
|
{
|
|||
|
|
CC_ASSERT(pPlayer!=nullptr);
|
|||
|
|
if (pPlayer == nullptr) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(pPlayer->GetTableID() != INVALID_TABLE && pPlayer->GetChairID() != INVALID_CHAIR);
|
|||
|
|
if (pPlayer->GetTableID() == INVALID_TABLE || pPlayer->GetChairID() == INVALID_CHAIR) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CC_ASSERT(pPlayer->GetTableID() == getSelfGamePlayer()->GetTableID());
|
|||
|
|
if (pPlayer->GetTableID() != getSelfGamePlayer()->GetTableID()) return;
|
|||
|
|
|
|||
|
|
cocos2d::log(a_u8c("<EFBFBD>û<EFBFBD>%s<><73>score = %d"), pPlayer->GetNickName().c_str(), pPlayer->GetUserScore());
|
|||
|
|
|
|||
|
|
((ZJHGamePlayer*)pPlayer)->updateScore();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
Vec2 ZJHGameScene::GetPlayerPosByUserID(uint32 dwUserID)
|
|||
|
|
{
|
|||
|
|
ZJHGamePlayer* pPlayer = (ZJHGamePlayer*)getPlayerByUserID(dwUserID);
|
|||
|
|
|
|||
|
|
if (pPlayer == nullptr)
|
|||
|
|
{
|
|||
|
|
return Vec2();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//const Vec2& ptHeadPos = pPlayer->getHeadPos();
|
|||
|
|
//Vec2 ptWorldPos = pPlayer->convertToWorldSpace(ptHeadPos);
|
|||
|
|
|
|||
|
|
return pPlayer->getHeadPos();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>;
|
|||
|
|
GamePlayer* ZJHGameScene::CreatePlayer(IClientUserItem * pIClientUserItem)
|
|||
|
|
{
|
|||
|
|
if (pIClientUserItem->GetChairID() == INVALID_CHAIR)
|
|||
|
|
{
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pIClientUserItem->GetUserID() == UserInfo::Instance().getUserID())
|
|||
|
|
{
|
|||
|
|
m_pLocalPlayer->setUserItem(pIClientUserItem);
|
|||
|
|
return m_pLocalPlayer;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
WORD wViewID = SwitchViewChairID(pIClientUserItem->GetChairID());
|
|||
|
|
CC_ASSERT(wViewID!=INVALID_CHAIR);
|
|||
|
|
ZJHGamePlayer* pPlayer = m_aryPlayer[wViewID];
|
|||
|
|
pPlayer->setUserItem(pIClientUserItem);
|
|||
|
|
return pPlayer;
|
|||
|
|
}
|
|||
|
|
return NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>Ӻ<EFBFBD><D3BA><EFBFBD>ͼת<CDBC><D7AA>;
|
|||
|
|
WORD ZJHGameScene::SwitchViewChairID(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>;
|
|||
|
|
if (wChairID == INVALID_CHAIR) return INVALID_CHAIR;
|
|||
|
|
|
|||
|
|
WORD wSelfChairID = getSelfChairID();
|
|||
|
|
if (wSelfChairID == INVALID_CHAIR) return INVALID_CHAIR;
|
|||
|
|
|
|||
|
|
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
WORD wChairCount = ZJH_GAME_PLAYER;
|
|||
|
|
WORD wViewChairID = (wChairID + wChairCount - wSelfChairID + ZJH_VIEW_SELF_ID) % wChairCount;
|
|||
|
|
|
|||
|
|
return wViewChairID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD><EFBFBD>Ϸ GameFrameBase.cpp<70><70><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::upSelfPlayerInfo()
|
|||
|
|
{
|
|||
|
|
log("Self Enter!!");
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
uint8 ZJHGameScene::getCurPlayerCount()
|
|||
|
|
{
|
|||
|
|
uint8 cbPlayerCount = 0;
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = m_aryPlayer[i];
|
|||
|
|
if (pPlayer != nullptr && pPlayer->getUserItem(false) != nullptr)
|
|||
|
|
{
|
|||
|
|
cbPlayerCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return cbPlayerCount;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/************************************* <20><><EFBFBD><EFBFBD> ***********************************************************/
|
|||
|
|
// <20><>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
void ZJHGameScene::OnButtonVoiceTouched(Ref*, Widget::TouchEventType type)
|
|||
|
|
{
|
|||
|
|
if (Widget::TouchEventType::BEGAN == type)
|
|||
|
|
{
|
|||
|
|
// <20><>ͣ<EFBFBD><CDA3><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CocosDenshion::SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
|||
|
|
|
|||
|
|
if (m_pVoiceNode->isVisible())
|
|||
|
|
{
|
|||
|
|
m_pVoiceNode->setVisible(false);
|
|||
|
|
m_pVoiceNode->stopAllActions();
|
|||
|
|
|
|||
|
|
YvVoiceManager::GetInstance()->StopRecord();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pVoiceNode->setVisible(true);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>;
|
|||
|
|
auto action = CSLoader::createTimeline("Games/ZJH/VoiceNode.csb");
|
|||
|
|
action->gotoFrameAndPlay(0);
|
|||
|
|
m_pVoiceNode->runAction(action);
|
|||
|
|
|
|||
|
|
YvVoiceManager::GetInstance()->StartRecord();
|
|||
|
|
}
|
|||
|
|
else if ((Widget::TouchEventType::CANCELED == type) || (Widget::TouchEventType::ENDED == type))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD><C5B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
CocosDenshion::SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
|||
|
|
|
|||
|
|
if (!m_pVoiceNode->isVisible())
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pVoiceNode->setVisible(false);
|
|||
|
|
m_pVoiceNode->stopAllActions();
|
|||
|
|
|
|||
|
|
YvVoiceManager::GetInstance()->StopRecord();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ַ<EFBFBD><D6B7><EFBFBD>;
|
|||
|
|
std::string ZJHGameScene::getUserGender(int cbGender)
|
|||
|
|
{
|
|||
|
|
if (cbGender == 0)
|
|||
|
|
{
|
|||
|
|
return "man";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return "woman";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::playSendCardEffect()
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
pAudio->playEffect("Games/ZJH/Sound/Deal.mp3");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::playFastVoice(int cbGender, int voiceIndex)
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
std::string strGender = getUserGender(cbGender);
|
|||
|
|
std::string strAudioRes = StringUtils::format("Games/ZJH/Sound/FastVoice/%s/%d.mp3", strGender.c_str(), voiceIndex);
|
|||
|
|
log("the strAudioRes is== %s", strAudioRes.c_str());
|
|||
|
|
pAudio->playEffect(strAudioRes.c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч;
|
|||
|
|
void ZJHGameScene::playEffect(std::string strPath)
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
std::string strAudioRes = StringUtils::format("Games/ZJH/Sound/%s.mp3", strPath.c_str());
|
|||
|
|
pAudio->playEffect(strAudioRes.c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч;
|
|||
|
|
void ZJHGameScene::playEffectEx(int cbGender, std::string strPath)
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
std::string strGender = getUserGender(cbGender);
|
|||
|
|
std::string strAudioRes = StringUtils::format("Games/ZJH/Sound/%s/%s.mp3", strGender.c_str(), strPath.c_str());
|
|||
|
|
log("the strAudioRes is== %s", strAudioRes.c_str());
|
|||
|
|
pAudio->playEffect(strAudioRes.c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>Ч;
|
|||
|
|
void ZJHGameScene::playBtnClickEffect()
|
|||
|
|
{
|
|||
|
|
CocosDenshion::SimpleAudioEngine* pAudio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|||
|
|
pAudio->playEffect("Games/ZJH/Sound/ClickBtn.mp3");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/************************************* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ ***********************************************************/
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>Ϣ;
|
|||
|
|
void ZJHGameScene::OnSocketSubPrivateRoomInfo(CMD_GF_Private_Room_Info* pNetInfo)
|
|||
|
|
{
|
|||
|
|
m_PrivateRoomInfo = *pNetInfo;
|
|||
|
|
|
|||
|
|
m_dwRoomID = pNetInfo->dwRoomNum;
|
|||
|
|
|
|||
|
|
string strRoomID = StringUtils::format("%d", m_dwRoomID);
|
|||
|
|
_txtRoomID->setString(strRoomID);
|
|||
|
|
_txtRoomID->setVisible(true);
|
|||
|
|
|
|||
|
|
uint32 dwPlayCout = __max(pNetInfo->dwPlayCout+1, 1);
|
|||
|
|
dwPlayCout = __min(dwPlayCout, pNetInfo->dwPlayTotal);
|
|||
|
|
|
|||
|
|
m_dwPlayCout = dwPlayCout;
|
|||
|
|
|
|||
|
|
string strPlayCount = StringUtils::format("%u/%u", dwPlayCout, pNetInfo->dwPlayTotal);
|
|||
|
|
cocos2d::log("dwPlayCout = %d", pNetInfo->dwPlayCout);
|
|||
|
|
_txtJushu->setString(utility::a_u8(strPlayCount));
|
|||
|
|
_txtJushu->setVisible(true);
|
|||
|
|
|
|||
|
|
ShowGameRule(pNetInfo);
|
|||
|
|
|
|||
|
|
ZJHGamePlayer* pPlayer = (ZJHGamePlayer*)getPlayerByUserID(pNetInfo->dwCreateUserID);
|
|||
|
|
if (pPlayer != nullptr) pPlayer->setOwner(true);
|
|||
|
|
|
|||
|
|
if (pNetInfo->bStartGame)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>ѿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD><D8A1><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD>䡱<EFBFBD><E4A1B1>ť;
|
|||
|
|
_btnInvite->setVisible(false);
|
|||
|
|
_btnStartGame->setVisible(false);
|
|||
|
|
_btnDismiss->setVisible(true);
|
|||
|
|
_btnLeave->setVisible(false);
|
|||
|
|
|
|||
|
|
//˽<>˳<EFBFBD><CBB3>Ѿ<EFBFBD><D1BE><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>Ϣ;
|
|||
|
|
GamePlayer* pSelfPlayer = getSelfGamePlayer();
|
|||
|
|
if (!_bGameEnd && !_ResultPanel->isVisible() && (pSelfPlayer != nullptr) && (pSelfPlayer->GetUserStatus() == US_SIT) && (m_cbGameStatus == ZJH_GS_FREE))
|
|||
|
|
{
|
|||
|
|
SendUserReady();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GamePlayer* pPlayer = getSelfGamePlayer();
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ء<EFBFBD><D8A1><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD>䡱<EFBFBD><E4A1B1>ť;
|
|||
|
|
if (pPlayer != nullptr && pNetInfo->dwCreateUserID == pPlayer->GetUserID())
|
|||
|
|
{
|
|||
|
|
_btnLeave->setVisible(false);
|
|||
|
|
_btnDismiss->setVisible(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ϸδ<CFB7><CEB4>ʼ<EFBFBD><CABC>ʾ<CABE>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>ť;
|
|||
|
|
if (pNetInfo->dwPlayCout <= 0)
|
|||
|
|
{
|
|||
|
|
_btnInvite->setVisible(true);
|
|||
|
|
_btnStartGame->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::ShowGameRule(CMD_GF_Private_Room_Info* pNetInfo)
|
|||
|
|
{
|
|||
|
|
if (pNetInfo == nullptr) return;
|
|||
|
|
|
|||
|
|
std::string strGameSet = "";
|
|||
|
|
uint32 dwGameRule = m_PrivateRoomInfo.bGameRuleIdex;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleLookCardRound2) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>, ";
|
|||
|
|
_cbMinLookRound = 2;
|
|||
|
|
_txtLookCardRound->setString(utility::a_u8("<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>"));
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleLookCardRound3) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>, ";
|
|||
|
|
_cbMinLookRound = 3;
|
|||
|
|
_txtLookCardRound->setString(utility::a_u8("<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>"));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
_cbMinLookRound = 0;
|
|||
|
|
_txtLookCardRound->setString(utility::a_u8("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleCompareRound2) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "2<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
_txtCompareRound->setString("2");
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleCompareRound3) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "3<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
_txtCompareRound->setString("3");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "1<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
_txtCompareRound->setString("1");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleOpenCardRound10) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "10<EFBFBD>ַⶥ";
|
|||
|
|
_cbMaxRound = 10;
|
|||
|
|
_txtOpenCardRound->setString(StringUtils::format("%d/10", _cbCurRound));
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleOpenCardRound15) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "15<EFBFBD>ַⶥ";
|
|||
|
|
_cbMaxRound = 15;
|
|||
|
|
_txtOpenCardRound->setString(StringUtils::format("%d/15", _cbCurRound));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "5<EFBFBD>ַⶥ";
|
|||
|
|
_cbMaxRound = 5;
|
|||
|
|
_txtOpenCardRound->setString(StringUtils::format("%d/5", _cbCurRound));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//strGameSet += StringUtils::format("%d<>ֳ<EFBFBD>", _iBaseScore);
|
|||
|
|
m_strGameRuleInfo = strGameSet;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ˽<>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::OnSocketSubPrivateEnd(void* data, int dataSize)
|
|||
|
|
{
|
|||
|
|
m_bPrivateEnd = true;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD>;
|
|||
|
|
DismissScene::Instance().hide();
|
|||
|
|
|
|||
|
|
DataStream kDataStream(data, dataSize);
|
|||
|
|
ZJH_CMD_S_Private_End_Info kNetInfo;
|
|||
|
|
kNetInfo.StreamValue(kDataStream, false);
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC>;
|
|||
|
|
_aryResultItem.clear();
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2>ǻ<EFBFBD><C7BB>ֳ<EFBFBD>;
|
|||
|
|
bool bUnionScore = (m_PrivateRoomInfo.cbUnionGoldOpen == 1);
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (ZJH_ST_GAMING_NULL==kNetInfo.aryActiveStatus[i])
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
tagZJHOpenResultItem mItem;
|
|||
|
|
mItem.lTotalScore = kNetInfo.aryTotalScore[i];
|
|||
|
|
mItem.lWinScore = kNetInfo.aryWinScore[i];
|
|||
|
|
mItem.lXiScore = kNetInfo.aryXiScore[i];
|
|||
|
|
//if (bUnionScore)
|
|||
|
|
//{
|
|||
|
|
// mItem.lUnionScore = mItem.lTotalScore * m_PrivateRoomInfo.lScoreMultiple;
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
{
|
|||
|
|
mItem.lUnionScore = mItem.lTotalScore * m_PrivateRoomInfo.cbBaseScore;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GamePlayer* player = getPlayerByChairID(i);
|
|||
|
|
if (player!=nullptr)
|
|||
|
|
{
|
|||
|
|
std::string strName = player->GetNickName();
|
|||
|
|
strncpy(mItem.szNickName, strName.c_str(), countarray(mItem.szNickName) - 1);
|
|||
|
|
mItem.dwGameID = player->GetGameID();
|
|||
|
|
mItem.bOwner = (player->GetUserID() == m_PrivateRoomInfo.dwCreateUserID);
|
|||
|
|
|
|||
|
|
std::string strHttpHead = player->GetHeadHttp();
|
|||
|
|
strncpy(mItem.szHttpHead, strHttpHead.c_str(), countarray(mItem.szHttpHead) - 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_aryResultItem.push_back(mItem);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>Ỷ<EFBFBD>ֳ<EFBFBD>;
|
|||
|
|
if (bUnionScore)
|
|||
|
|
{
|
|||
|
|
int nCount = _aryResultItem.size();
|
|||
|
|
|
|||
|
|
// Ѱ<>Ҵ<EFBFBD>Ӯ<EFBFBD><D3AE>;
|
|||
|
|
SCORE lMaxScore = 0;
|
|||
|
|
for (size_t i = 0; i < nCount; i++)
|
|||
|
|
{
|
|||
|
|
tagZJHOpenResultItem* pData = &(_aryResultItem.at(i));
|
|||
|
|
|
|||
|
|
if (pData->lTotalScore > lMaxScore)
|
|||
|
|
{
|
|||
|
|
lMaxScore = pData->lTotalScore;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ͳ<>ƴ<EFBFBD>Ӯ<EFBFBD><D3AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
int iMaxScoreCount = 0;
|
|||
|
|
for (int j = 0; j < nCount; j++)
|
|||
|
|
{
|
|||
|
|
tagZJHOpenResultItem* pData = &(_aryResultItem.at(j));
|
|||
|
|
|
|||
|
|
if ((lMaxScore > 0) && (pData->lTotalScore == lMaxScore))
|
|||
|
|
{
|
|||
|
|
iMaxScoreCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (iMaxScoreCount > 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>;
|
|||
|
|
SCORE lGameGold = m_PrivateRoomInfo.lGameGold*m_PrivateRoomInfo.dwPlayCost;
|
|||
|
|
SCORE lRevenue = floor(lGameGold / iMaxScoreCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ͳ<>ƿ<EFBFBD>˰;
|
|||
|
|
for (int k = 0; k < nCount; k++)
|
|||
|
|
{
|
|||
|
|
tagZJHOpenResultItem* pData = &(_aryResultItem.at(k));
|
|||
|
|
if ((lMaxScore > 0) && (pData->lTotalScore == lMaxScore))
|
|||
|
|
{
|
|||
|
|
if (pData->lUnionScore > lRevenue)
|
|||
|
|
{
|
|||
|
|
pData->lUnionScore -= lRevenue;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pData->lUnionScore = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><DCBB><EFBFBD>
|
|||
|
|
pData->lAllUnionScore = pData->lUnionScore + m_PrivateScoreInfo.kScoreInfoArray[k];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ((ZJH_GS_FREE==m_cbGameStatus) && _ResultPanel->isVisible() == false)
|
|||
|
|
{
|
|||
|
|
_OpenResultScene->updateUIData(m_dwRoomID, &_aryResultItem, true);
|
|||
|
|
_OpenResultScene->setVisible(true);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
_btnPrivateEnd->setVisible(true);
|
|||
|
|
_btnReady->setVisible(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>;
|
|||
|
|
PrivateRoomEnd();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ZJHGameScene::onEventShowPrivate(cocos2d::EventCustom *event)
|
|||
|
|
{
|
|||
|
|
//if (m_pPrivateScene)
|
|||
|
|
//{
|
|||
|
|
// m_pPrivateScene->pushScene();
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɢ<EFBFBD><C9A2><EFBFBD><EFBFBD>;
|
|||
|
|
void ZJHGameScene::OnSocketSubPrivateDismissInfo(CMD_GF_Private_Dismiss_Info* pNetInfo)
|
|||
|
|
{
|
|||
|
|
std::string aryName[ZJH_GAME_PLAYER];
|
|||
|
|
BYTE aryResult[ZJH_GAME_PLAYER] = { 0 }; // 0 δѡ<CEB4><D1A1> 1 ͬ<><CDAC> 2 <20><>ͬ<EFBFBD><CDAC>;
|
|||
|
|
|
|||
|
|
bool bHasSelf = false;
|
|||
|
|
|
|||
|
|
uint32 dwMyChairID = getSelfChairID();
|
|||
|
|
for (uint32 i = 0; i < pNetInfo->dwDissUserCout; i++)
|
|||
|
|
{
|
|||
|
|
uint32 dwChairID = pNetInfo->dwDissChairID[i];
|
|||
|
|
GamePlayer* pPlayer = getPlayerByChairID(dwChairID);
|
|||
|
|
if (pPlayer != nullptr && dwChairID < ZJH_GAME_PLAYER)
|
|||
|
|
{
|
|||
|
|
aryResult[dwChairID] = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (dwMyChairID == dwChairID)
|
|||
|
|
{
|
|||
|
|
bHasSelf = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (uint32 i = 0; i < pNetInfo->dwNotAgreeUserCout; i++)
|
|||
|
|
{
|
|||
|
|
uint32 dwChairID = pNetInfo->dwNotAgreeChairID[i];
|
|||
|
|
GamePlayer* pPlayer = getPlayerByChairID(dwChairID);
|
|||
|
|
if (pPlayer != nullptr && dwChairID < ZJH_GAME_PLAYER)
|
|||
|
|
{
|
|||
|
|
aryResult[dwChairID] = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (dwMyChairID == dwChairID)
|
|||
|
|
{
|
|||
|
|
bHasSelf = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GamePlayer* players[ZJH_GAME_PLAYER];
|
|||
|
|
|
|||
|
|
for (int i = 0; i < ZJH_GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
players[i] = getPlayerByChairID(i);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
DismissScene::Instance().show(aryResult, players, !bHasSelf, ZJH_GAME_PLAYER);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void ZJHGameScene::OnSocketSubPrivateDismissResult(CMD_GF_Private_Dismiss_Result* pNetInfo)
|
|||
|
|
{
|
|||
|
|
if (pNetInfo->bSuccess && false == m_PrivateRoomInfo.bStartGame)
|
|||
|
|
{
|
|||
|
|
EventLeaveGame(nullptr);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
DismissScene::Instance().hide();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::string ZJHGameScene::getGameRule(uint32 dwGameRule)
|
|||
|
|
{
|
|||
|
|
std::string strGameSet = "";
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleLookCardRound2) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleLookCardRound3) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleCompareRound2) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "2<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleCompareRound3) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "3<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "1<EFBFBD>ֿɱ<EFBFBD><EFBFBD><EFBFBD>, ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if ((dwGameRule&eZJHGameRuleOpenCardRound10) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "10<EFBFBD>ַⶥ";
|
|||
|
|
}
|
|||
|
|
else if ((dwGameRule&eZJHGameRuleOpenCardRound15) > 0)
|
|||
|
|
{
|
|||
|
|
strGameSet += "15<EFBFBD>ַⶥ";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strGameSet += "5<EFBFBD>ַⶥ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return strGameSet;
|
|||
|
|
}
|