1285 lines
30 KiB
C++
1285 lines
30 KiB
C++
|
|
#include "WN_CardManager.h"
|
|||
|
|
|
|||
|
|
#include "cocos2d.h"
|
|||
|
|
#include "ui/CocosGUI.h"
|
|||
|
|
#include "cocostudio/CocoStudio.h"
|
|||
|
|
|
|||
|
|
#include "YSAudioEngine.h"
|
|||
|
|
#include "PopScene.h"
|
|||
|
|
|
|||
|
|
using namespace WNMJ_SPACE;
|
|||
|
|
|
|||
|
|
/////////////////////////////// <20>齫<EFBFBD><E9BDAB><EFBFBD><EFBFBD> ///////////////////////////////////////////
|
|||
|
|
|
|||
|
|
WN_CardManager::WN_CardManager()
|
|||
|
|
{
|
|||
|
|
m_IsGameRecord = false;
|
|||
|
|
m_bOutCardStatus = false;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WN_CardManager::~WN_CardManager()
|
|||
|
|
{
|
|||
|
|
memset(m_cbOutCarCount, 0x0, sizeof(m_cbOutCarCount));
|
|||
|
|
memset(m_cbWeaveCount, 0x0, sizeof(m_cbWeaveCount));
|
|||
|
|
memset(m_cbHandCardCount, 0x0, sizeof(m_cbHandCardCount));
|
|||
|
|
|
|||
|
|
for (int i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
ClearCardList(i);
|
|||
|
|
|
|||
|
|
for (int l = 0; l < MAX_WEAVE; l++)
|
|||
|
|
{
|
|||
|
|
if (m_pWeaveCard[i][l])
|
|||
|
|
{
|
|||
|
|
m_pWeaveCard[i][l]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pWeaveCard[i][l] = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = m_pOutCardSprite.begin(); it != m_pOutCardSprite.end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
card->removeFromParentAndCleanup(true);
|
|||
|
|
card = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pOutCardSprite.clear();
|
|||
|
|
|
|||
|
|
for (int j = 0; j < 2; j++)
|
|||
|
|
{
|
|||
|
|
if (m_pKingCardSprite[j])
|
|||
|
|
{
|
|||
|
|
m_pKingCardSprite[j]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pKingCardSprite[j] = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_pCurrentOutCard)
|
|||
|
|
{
|
|||
|
|
m_pCurrentOutCard->removeFromParent();
|
|||
|
|
m_pCurrentOutCard = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool WN_CardManager::init()
|
|||
|
|
{
|
|||
|
|
if (!Layer::init()) {
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ô<EFBFBD>С;
|
|||
|
|
this->setContentSize(Size(1136, 640));
|
|||
|
|
|
|||
|
|
memset(m_cbOutCarCount, 0x0, sizeof(m_cbOutCarCount));
|
|||
|
|
memset(m_pWeaveCard, 0x0, sizeof(m_pWeaveCard));
|
|||
|
|
memset(m_cbWeaveCount, 0x0, sizeof(m_cbWeaveCount));
|
|||
|
|
memset(m_pKingCardSprite, 0x0, sizeof(m_pKingCardSprite));
|
|||
|
|
memset(m_cbHandCardCount, 0x0, sizeof(m_cbHandCardCount));
|
|||
|
|
zeromemory(m_pLastHandCard, sizeof(m_pLastHandCard));
|
|||
|
|
zeromemory(m_bActiveStatus, sizeof(m_bActiveStatus));
|
|||
|
|
|
|||
|
|
m_pCurrentOutCard = nullptr;
|
|||
|
|
m_wCurrentUser = INVALID_CHAIR;
|
|||
|
|
m_wRealChairCount = GAME_PLAYER;
|
|||
|
|
|
|||
|
|
// <20><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pNoticelayer = WN_NotifyDlg::create();
|
|||
|
|
m_pNoticelayer->setVisible(false);
|
|||
|
|
this->addChild(m_pNoticelayer, MAX_REPERTORY);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::ResetAll()
|
|||
|
|
{
|
|||
|
|
SetCurrentUser(INVALID_CHAIR);
|
|||
|
|
|
|||
|
|
memset(m_cbOutCarCount, 0x0, sizeof(m_cbOutCarCount));
|
|||
|
|
memset(m_cbWeaveCount, 0x0, sizeof(m_cbWeaveCount));
|
|||
|
|
memset(m_cbHandCardCount, 0x0, sizeof(m_cbHandCardCount));
|
|||
|
|
zeromemory(m_bActiveStatus, sizeof(m_bActiveStatus));
|
|||
|
|
|
|||
|
|
m_wRealChairCount = GAME_PLAYER;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (m_pLastHandCard[i])
|
|||
|
|
{
|
|||
|
|
m_pLastHandCard[i]->removeFromParent();
|
|||
|
|
m_pLastHandCard[i] = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ClearCardList(i);
|
|||
|
|
|
|||
|
|
for (int l = 0; l < MAX_WEAVE; l++)
|
|||
|
|
{
|
|||
|
|
if (m_pWeaveCard[i][l])
|
|||
|
|
{
|
|||
|
|
m_pWeaveCard[i][l]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pWeaveCard[i][l] = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_cbHandCardCount[i] = 0;
|
|||
|
|
m_cbOutCarCount[i] = 0;
|
|||
|
|
m_cbWeaveCount[i] = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = m_pOutCardSprite.begin(); it != m_pOutCardSprite.end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
card->removeFromParentAndCleanup(true);
|
|||
|
|
card = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pOutCardSprite.clear();
|
|||
|
|
|
|||
|
|
if (m_pCurrentOutCard)
|
|||
|
|
{
|
|||
|
|
m_pCurrentOutCard->removeFromParent();
|
|||
|
|
m_pCurrentOutCard = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_pNoticelayer)
|
|||
|
|
{
|
|||
|
|
CCLOG("WN_NotifyDlg HideNotifyDlg...WN_CardManager::ResetAll()");
|
|||
|
|
m_pNoticelayer->HideNotifyDlg();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int j = 0; j < 2; j++)
|
|||
|
|
{
|
|||
|
|
if (m_pKingCardSprite[j])
|
|||
|
|
{
|
|||
|
|
m_pKingCardSprite[j]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pKingCardSprite[j] = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
|
void WN_CardManager::SetActiveStatus(bool bActiveStatus[], WORD wArrViewChairID[], WORD wRealChairCount)
|
|||
|
|
{
|
|||
|
|
m_wRealChairCount = wRealChairCount;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
WORD wViewChairID = wArrViewChairID[i];
|
|||
|
|
if (wViewChairID == INVALID_CHAIR) continue;
|
|||
|
|
|
|||
|
|
m_bActiveStatus[wViewChairID] = bActiveStatus[i];
|
|||
|
|
//m_wRealChairCount++; // ͳ<><CDB3><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SetCurrentUser(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
m_wCurrentUser = wChairID;
|
|||
|
|
if (m_pNoticelayer)
|
|||
|
|
{
|
|||
|
|
m_pNoticelayer->m_wCurrentUser = wChairID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_bOutCardStatus = (m_wCurrentUser == SELF_VIEW_CHAIRID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ģʽ;
|
|||
|
|
void WN_CardManager::SetGameRecord(bool isGameRecord)
|
|||
|
|
{
|
|||
|
|
m_IsGameRecord = isGameRecord;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ø<C3B8><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SetNoticeData(CMD_S_OperateNotify &OperateNotify)
|
|||
|
|
{
|
|||
|
|
if (m_pNoticelayer)
|
|||
|
|
{
|
|||
|
|
CCLOG("WN_NotifyDlg SetNoticeData...WN_CardManager::SetNoticeData()");
|
|||
|
|
m_pNoticelayer->SetNoticeData(&OperateNotify);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void WN_CardManager::HideNoticeDlg()
|
|||
|
|
{
|
|||
|
|
if (m_pNoticelayer)
|
|||
|
|
{
|
|||
|
|
CCLOG("WN_NotifyDlg HideNotifyDlg...WN_CardManager::HideNoticeDlg()");
|
|||
|
|
m_pNoticelayer->HideNotifyDlg();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>Ƿ<EFBFBD><C7B7>и<D0B8><DFBC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool WN_CardManager::IsHaveOperateCard(DWORD dwUserAction)
|
|||
|
|
{
|
|||
|
|
if ((dwUserAction&WIK_WN_CHI) != 0 || (dwUserAction&WIK_WN_PENG) != 0 || (dwUserAction&WIK_WN_GANG) != 0 || (dwUserAction&WIK_WN_CHI_HU) != 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ;
|
|||
|
|
bool WN_CardManager::CheckOperateCard(uint8 cbOperateCard)
|
|||
|
|
{
|
|||
|
|
if (!WN_CGameLogic::IsValidCard(cbOperateCard))
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Dz<EFBFBD><C7B2><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ﻹ<EFBFBD><EFBBB9>һ<EFBFBD><D2BB>);
|
|||
|
|
for (int i = 0; i < MAX_WEAVE; i++)
|
|||
|
|
{
|
|||
|
|
if (m_pWeaveCard[SELF_VIEW_CHAIRID][i] && (m_pWeaveCard[SELF_VIEW_CHAIRID][i]->m_dwOperateCode == WIK_WN_PENG)
|
|||
|
|
&& (m_pWeaveCard[SELF_VIEW_CHAIRID][i]->m_cbCardData == cbOperateCard))
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>У<EFBFBD><D0A3>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>);
|
|||
|
|
uint8 cbCardCount = 0;
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = m_SelfHandCardList.begin(); it != m_SelfHandCardList.end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card && (card->GetCardData() == cbOperateCard))
|
|||
|
|
{
|
|||
|
|
cbCardCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_pLastHandCard[SELF_VIEW_CHAIRID] && (m_pLastHandCard[SELF_VIEW_CHAIRID]->GetCardData() == cbOperateCard))
|
|||
|
|
{
|
|||
|
|
cbCardCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD>
|
|||
|
|
if (cbCardCount == 4)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
//// <20><><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ;
|
|||
|
|
//else if (cbCardCount == 3)
|
|||
|
|
//{
|
|||
|
|
// if (m_pCurrentOutCard && (m_pCurrentOutCard->GetCardData() == cbOperateCard))
|
|||
|
|
// {
|
|||
|
|
// return true;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
//// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>δ<EFBFBD><CEB4><EFBFBD>´<EFBFBD><C2B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѹܲ<D1B8><DCB2><EFBFBD>;
|
|||
|
|
//// <20><><EFBFBD>ܣ<EFBFBD><DCA3>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
//for (int l = 0; l < MAX_WEAVE; l++)
|
|||
|
|
//{
|
|||
|
|
// if (m_pWeaveCard[SELF_VIEW_CHAIRID][l] && (m_pWeaveCard[SELF_VIEW_CHAIRID][l]->m_dwOperateCode == WIK_WN_PENG))
|
|||
|
|
// {
|
|||
|
|
// for (std::list<WN_SparrowCard*>::iterator it = m_SelfHandCardList.begin(); it != m_SelfHandCardList.end(); it++)
|
|||
|
|
// {
|
|||
|
|
// WN_SparrowCard* card = *it;
|
|||
|
|
// if (card && (card->GetCardData() == m_pWeaveCard[SELF_VIEW_CHAIRID][l]->m_cbCardData))
|
|||
|
|
// {
|
|||
|
|
// return m_pWeaveCard[SELF_VIEW_CHAIRID][l]->m_cbCardData;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
//// <20><><EFBFBD>ܣ<EFBFBD><DCA3>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>;
|
|||
|
|
//uint8 cbIndexArr[MAX_INDEX] = {0};
|
|||
|
|
//for (std::list<WN_SparrowCard*>::iterator it = m_SelfHandCardList.begin(); it != m_SelfHandCardList.end(); it++)
|
|||
|
|
//{
|
|||
|
|
// WN_SparrowCard* card = *it;
|
|||
|
|
// if (card)
|
|||
|
|
// {
|
|||
|
|
// uint8 cbIndex = WN_CGameLogic::getInstance()->SwitchToCardIndex(card->GetCardData());
|
|||
|
|
// cbIndexArr[cbIndex]++;
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
//for (int i = 0; i < MAX_INDEX; i++)
|
|||
|
|
//{
|
|||
|
|
// if (cbIndexArr[i] == 4)
|
|||
|
|
// {
|
|||
|
|
// return WN_CGameLogic::getInstance()->SwitchToCardData(i);
|
|||
|
|
// }
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/******************************* <20>齫<EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD> *****************************************/
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
float WN_CardManager::SetAllCard(uint8 cbCardData[], WORD wStartID)
|
|||
|
|
{
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ұ<EFBFBD><D2B0>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (int i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
if (!m_bActiveStatus[i]) continue;
|
|||
|
|
|
|||
|
|
// û<>˷<EFBFBD>13<31><33><EFBFBD><EFBFBD>
|
|||
|
|
for (int j = 0; j < MAX_COUNT - 1; j++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = nullptr;
|
|||
|
|
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
if (i == SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
uint8 CardValue = cbCardData[j];
|
|||
|
|
if (WN_CGameLogic::getInstance()->IsValidCard(CardValue))
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(CardValue, SP_SELFSTAND);
|
|||
|
|
card->addClickEventListener(CC_CALLBACK_2(WN_CardManager::onSendCardEvent, this));
|
|||
|
|
card->setPosition(GetCardPoint(i, j));
|
|||
|
|
this->addChild(card);
|
|||
|
|
|
|||
|
|
m_SelfHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ӡ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
log("DEBUG CARD game start my card_%d = 0x%0x ", j, CardValue);
|
|||
|
|
}
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
else if (i == 0)
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(0xff, SP_OPPSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(i, j));
|
|||
|
|
this->addChild(card);
|
|||
|
|
|
|||
|
|
m_OppHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
else if (i == 3)
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(0xff, SP_LSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(i, j));
|
|||
|
|
this->addChild(card, j + SP_LSTAND);
|
|||
|
|
|
|||
|
|
m_LeftHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(0xff, SP_RSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(i, j));
|
|||
|
|
this->addChild(card, SP_RSTAND + MAX_COUNT - j);
|
|||
|
|
|
|||
|
|
m_RightHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_cbHandCardCount[i]++;
|
|||
|
|
|
|||
|
|
//if (card)card->setVisible(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SortSelfCard();
|
|||
|
|
|
|||
|
|
return 0.0f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
float WN_CardManager::SendAllCard(WORD wStartID)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ƴ<EFBFBD>ׯ<EFBFBD>ҿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>4<EFBFBD>ţ<EFBFBD>Ȼ<EFBFBD><C8BB>ÿ<EFBFBD>˷<EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
float fDelaytimer = 0.0f; // <20>ӳ<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
|
|||
|
|
for (int i = 0; i < GAME_PLAYER; i++)
|
|||
|
|
{
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(i);
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = __list->begin(); it != __list->end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
card->setVisible(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return fDelaytimer;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Point WN_CardManager::GetCardPoint(WORD wChairID, uint8 cbIndex)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|||
|
|
Point pos = GetWaveCardPoint(wChairID);
|
|||
|
|
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
if (wChairID == SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x + NCMJ_SELF_HAND_CARD_WIDHT*cbIndex;
|
|||
|
|
pos.y = pos.y;
|
|||
|
|
}
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
else if (wChairID == 0)
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x - NCMJ_OPP_HAND_CARD_WIDHT*cbIndex;
|
|||
|
|
pos.y = pos.y;
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
else if (wChairID == 3)
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x;
|
|||
|
|
pos.y = pos.y - NCMJ_LR_HAND_CARD_HIGHT*cbIndex;
|
|||
|
|
}
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x;
|
|||
|
|
pos.y = pos.y + NCMJ_LR_HAND_CARD_HIGHT*cbIndex;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return pos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD>ң<EFBFBD>ǰ<EFBFBD><C7B0>ץ<EFBFBD><D7A5>
|
|||
|
|
void WN_CardManager::SendCard(uint8 cbCardData, WORD wGetCardUser)
|
|||
|
|
{
|
|||
|
|
// <20><>ӡ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
log("DEBUG CARD send card wGetCardUser = %d, card = 0x%0x ", wGetCardUser, cbCardData);
|
|||
|
|
|
|||
|
|
WN_SparrowCard* pCard = nullptr;
|
|||
|
|
pCard = WN_SparrowCard::createWithDirection(cbCardData, (EN_SPARROW_TYPE)wGetCardUser);
|
|||
|
|
if (pCard == nullptr) return;
|
|||
|
|
|
|||
|
|
// ¼<><C2BC>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_IsGameRecord)
|
|||
|
|
{
|
|||
|
|
pCard->ShowCardValue(cbCardData);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_pLastHandCard[wGetCardUser] != nullptr)
|
|||
|
|
{
|
|||
|
|
m_pLastHandCard[wGetCardUser]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pLastHandCard[wGetCardUser] = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
m_pLastHandCard[wGetCardUser] = pCard; // δѡ<CEB4><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA>IJ<EFBFBD><C4B2>ι<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int localZOrder = 0;
|
|||
|
|
Point pos;
|
|||
|
|
|
|||
|
|
switch (wGetCardUser)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
{
|
|||
|
|
int _ind = m_OppHandCardList.size();
|
|||
|
|
pos = GetCardPoint(wGetCardUser, _ind);
|
|||
|
|
pos.x = pos.x - NCMJ_OPP_HAND_CARD_WIDHT / 3;
|
|||
|
|
localZOrder = 0;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 3:
|
|||
|
|
{
|
|||
|
|
int _ind = m_LeftHandCardList.size();
|
|||
|
|
pos = GetCardPoint(wGetCardUser, _ind);
|
|||
|
|
pos.y = pos.y - NCMJ_LR_HAND_CARD_HIGHT / 3;
|
|||
|
|
localZOrder = (MAX_COUNT - 1) + SP_LSTAND;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 2:
|
|||
|
|
{
|
|||
|
|
int _ind = m_SelfHandCardList.size();
|
|||
|
|
pos = GetCardPoint(wGetCardUser, _ind);
|
|||
|
|
pos.x = pos.x + NCMJ_SELF_HAND_CARD_WIDHT / 3;
|
|||
|
|
localZOrder = 0;
|
|||
|
|
|
|||
|
|
pCard->addClickEventListener(CC_CALLBACK_2(WN_CardManager::onSendCardEvent, this));
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 1:
|
|||
|
|
{
|
|||
|
|
int _ind = m_RightHandCardList.size();
|
|||
|
|
pos = GetCardPoint(wGetCardUser, _ind);
|
|||
|
|
pos.y = pos.y + NCMJ_LR_HAND_CARD_HIGHT / 3;
|
|||
|
|
localZOrder = SP_RSTAND + 1;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
default:
|
|||
|
|
ASSERT(false);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pCard->setPosition(pos);
|
|||
|
|
this->addChild(pCard, localZOrder);
|
|||
|
|
|
|||
|
|
auto moveto = MoveTo::create(0.2f, pos);
|
|||
|
|
auto ani = EaseBackOut::create(moveto);
|
|||
|
|
pCard->runAction(ani);
|
|||
|
|
|
|||
|
|
log("send card pos.x = %f, pos.y = %f, z = %d", pos.x, pos.y, localZOrder);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SortSelfCard(WORD wChairID/* = SELF_VIEW_CHAIRID*/)
|
|||
|
|
{
|
|||
|
|
function<bool(WN_SparrowCard*, WN_SparrowCard*)> funSort;
|
|||
|
|
funSort = [](WN_SparrowCard* cardA, WN_SparrowCard* cardB){
|
|||
|
|
if (cardA->GetCardData() < cardB->GetCardData())
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(wChairID);
|
|||
|
|
if (__list)
|
|||
|
|
{
|
|||
|
|
__list->sort(funSort);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
ResetHandCard(wChairID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool WN_CardManager::onSendCardEvent(cocos2d::Ref *pSender, Vec2 pos)
|
|||
|
|
{
|
|||
|
|
if (pSender == nullptr) return false;
|
|||
|
|
|
|||
|
|
//ImageView* btnRoot = (ImageView*)pSender;
|
|||
|
|
WN_SparrowCard* pCardSprite = (WN_SparrowCard*)pSender;
|
|||
|
|
if (pCardSprite == nullptr) return false;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (pos.y < (pCardSprite->getPositionY() + pCardSprite->getContentSize().height + TOP_CARD_HEIGHT - 5))
|
|||
|
|
{
|
|||
|
|
if (pCardSprite->getPositionY() < TOP_CARD_HEIGHT - 5)
|
|||
|
|
{
|
|||
|
|
pCardSprite->setPositionY(pCardSprite->getPositionY() + TOP_CARD_HEIGHT);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѵ<EFBFBD><D1B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = m_SelfHandCardList.begin(); it != m_SelfHandCardList.end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card != pCardSprite)
|
|||
|
|
{
|
|||
|
|
if (card->getPositionY() >= (TOP_CARD_HEIGHT - 5))
|
|||
|
|
{
|
|||
|
|
card->setPositionY(card->getPositionY() - TOP_CARD_HEIGHT);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>𣬵<EFBFBD><F0A3ACB5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>齫<EFBFBD>ջ<EFBFBD>
|
|||
|
|
if (m_wCurrentUser != SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
if (pCardSprite->getPositionY() > TOP_CARD_HEIGHT - 5)
|
|||
|
|
{
|
|||
|
|
pCardSprite->setPositionY(pCardSprite->getPositionY() - TOP_CARD_HEIGHT);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (m_bOutCardStatus)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>ִ<EFBFBD>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pNoticelayer->isVisible())
|
|||
|
|
{
|
|||
|
|
m_pNoticelayer->onEventGuo(nullptr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ֵ;
|
|||
|
|
uint8 cbCardData = pCardSprite->GetCardData();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ǹ<EFBFBD><C7B8><EFBFBD>;
|
|||
|
|
if (CheckOperateCard(cbCardData))
|
|||
|
|
{
|
|||
|
|
auto callback = [cbCardData, this](){
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_OutCard OutCard;
|
|||
|
|
OutCard.cbCardData = cbCardData;
|
|||
|
|
|
|||
|
|
EventCustom event(CUSTOM_EVENT_OUT_CARD);
|
|||
|
|
event.setUserData(&OutCard);
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
|
|||
|
|
|
|||
|
|
m_bOutCardStatus = false;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
PopScene::Instance().show(utility::a_u8("ȷ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), callback, nullptr);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CMD_C_OutCard OutCard;
|
|||
|
|
OutCard.cbCardData = cbCardData;
|
|||
|
|
|
|||
|
|
EventCustom event(CUSTOM_EVENT_OUT_CARD);
|
|||
|
|
event.setUserData(&OutCard);
|
|||
|
|
Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
|
|||
|
|
|
|||
|
|
m_bOutCardStatus = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
log("self out card %d", pCardSprite->GetCardData());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SubOutCard(uint8 cbCardData, WORD wOutCardUser, bool isShow/* = true*/)
|
|||
|
|
{
|
|||
|
|
if (wOutCardUser == INVALID_CHAIR) return;
|
|||
|
|
if (!WN_CGameLogic::getInstance()->IsValidCard(cbCardData)) return;
|
|||
|
|
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(wOutCardUser);
|
|||
|
|
if (__list)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pLastHandCard[wOutCardUser])
|
|||
|
|
{
|
|||
|
|
__list->push_back(m_pLastHandCard[wOutCardUser]);
|
|||
|
|
m_pLastHandCard[wOutCardUser] = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
uint8 cbDelCardData = cbCardData;
|
|||
|
|
// <20><>Ϸģʽ<C4A3><CABD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (!m_IsGameRecord && (wOutCardUser != SELF_VIEW_CHAIRID))
|
|||
|
|
{
|
|||
|
|
cbDelCardData = 0x0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = __list->begin(); it != __list->end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card && (card->GetCardData() == cbDelCardData))
|
|||
|
|
{
|
|||
|
|
card->removeFromParentAndCleanup(true);
|
|||
|
|
card = nullptr;
|
|||
|
|
|
|||
|
|
__list->remove(*it);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
SortSelfCard(wOutCardUser);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isShow)
|
|||
|
|
{
|
|||
|
|
ShowCurrentCard(wOutCardUser, cbCardData);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SubWeaveCard(CMD_S_OperateResult *pOperateResult)
|
|||
|
|
{
|
|||
|
|
if (m_pNoticelayer->isVisible())
|
|||
|
|
{
|
|||
|
|
CCLOG("WN_NotifyDlg HideNotifyDlg...WN_CardManager::SubWeaveCard()");
|
|||
|
|
m_pNoticelayer->HideNotifyDlg();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pOperateResult == nullptr) return;
|
|||
|
|
|
|||
|
|
if ((pOperateResult->dwOperateCode&WIK_WN_GANG) != 0)
|
|||
|
|
{
|
|||
|
|
SetGangWeave(pOperateResult);
|
|||
|
|
}
|
|||
|
|
else if ((pOperateResult->dwOperateCode&WIK_WN_PENG) != 0)
|
|||
|
|
{
|
|||
|
|
SetPengWeave(pOperateResult);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CCLOG("no operate code %d", pOperateResult->dwOperateCode);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
ResetHandCard(pOperateResult->wOperateUser);
|
|||
|
|
|
|||
|
|
// <20>ṩ<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƾ<EFBFBD><C6BE>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DelOutCard(pOperateResult->wProvideUser, pOperateResult->cbOperateCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void WN_CardManager::SetGangWeave(CMD_S_OperateResult *pOperateResult)
|
|||
|
|
{
|
|||
|
|
if (pOperateResult == nullptr) return;
|
|||
|
|
|
|||
|
|
if ((pOperateResult->dwOperateCode&WIK_WN_GANG) == 0) return;
|
|||
|
|
|
|||
|
|
WN_WeaveCard* pWeaveCard = nullptr;
|
|||
|
|
bool IsBuGang = false;
|
|||
|
|
|
|||
|
|
uint8 cbWeaveCount = m_cbWeaveCount[pOperateResult->wOperateUser];
|
|||
|
|
|
|||
|
|
// <20>ȿ<EFBFBD><C8BF>Ƿ<EFBFBD><C7B7>Dz<EFBFBD><C7B2><EFBFBD>
|
|||
|
|
for (uint8 i = 0; i < cbWeaveCount; i++)
|
|||
|
|
{
|
|||
|
|
if (m_pWeaveCard[pOperateResult->wOperateUser] != nullptr)
|
|||
|
|
{
|
|||
|
|
WN_WeaveCard* pTmpWeaveCard = m_pWeaveCard[pOperateResult->wOperateUser][i];
|
|||
|
|
|
|||
|
|
if ((pTmpWeaveCard != nullptr) && ((pTmpWeaveCard->m_dwOperateCode&WIK_WN_PENG) != 0) && (pTmpWeaveCard->m_cbCardData == pOperateResult->cbOperateCard))
|
|||
|
|
{
|
|||
|
|
pWeaveCard = pTmpWeaveCard;
|
|||
|
|
IsBuGang = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
if (nullptr != pWeaveCard)
|
|||
|
|
{
|
|||
|
|
pWeaveCard->SetBuGang(pOperateResult->cbOperateCard);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>:һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><C6BC>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF>Ըܣ<D4B8>ȴѡ<C8B4><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
|
|||
|
|
SubOutCard(pOperateResult->cbOperateCard, pOperateResult->wOperateUser, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pWeaveCard = WN_WeaveCard::create();
|
|||
|
|
if (pWeaveCard == nullptr) return;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
pWeaveCard->ShowCardData(pOperateResult->wOperateUser, pOperateResult->cbOperateCard, pOperateResult->dwOperateCode, pOperateResult->wProvideUser);
|
|||
|
|
|
|||
|
|
// λ<>ü<EFBFBD><C3BC><EFBFBD>
|
|||
|
|
Point pos = GetWaveCardPoint(pOperateResult->wOperateUser);
|
|||
|
|
pWeaveCard->setPosition(pos);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A>
|
|||
|
|
if (pOperateResult->wOperateUser == 1)
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard, SP_RSTAND + MAX_COUNT - cbWeaveCount);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pWeaveCard[pOperateResult->wOperateUser][cbWeaveCount] = pWeaveCard;
|
|||
|
|
m_cbWeaveCount[pOperateResult->wOperateUser]++;
|
|||
|
|
|
|||
|
|
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ܵ<EFBFBD>ʱ<EFBFBD><CAB1>ֻ<EFBFBD><D6BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>DZ<EFBFBD><C7B1>˳<EFBFBD><CBB3>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>ץ<EFBFBD>Ƹܣ<C6B8><DCA3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD>ƻᱻ<C6BB>·<EFBFBD><C2B7><EFBFBD><EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>)
|
|||
|
|
for (int i = 0; i < 3; i++)
|
|||
|
|
{
|
|||
|
|
SubOutCard(pOperateResult->cbOperateCard, pOperateResult->wOperateUser, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾһ<C9BE><D2BB>;
|
|||
|
|
if (pOperateResult->wProvideUser == pOperateResult->wOperateUser)
|
|||
|
|
{
|
|||
|
|
SubOutCard(pOperateResult->cbOperateCard, pOperateResult->wOperateUser, false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void WN_CardManager::SetPengWeave(CMD_S_OperateResult *pOperateResult)
|
|||
|
|
{
|
|||
|
|
if (pOperateResult == nullptr) return;
|
|||
|
|
|
|||
|
|
if ((pOperateResult->dwOperateCode&WIK_WN_PENG) == 0) return;
|
|||
|
|
|
|||
|
|
WN_WeaveCard* pWeaveCard = WN_WeaveCard::create();
|
|||
|
|
//pWeaveCard->SetCardData(pOperateResult);
|
|||
|
|
pWeaveCard->ShowCardData(pOperateResult->wOperateUser, pOperateResult->cbOperateCard, pOperateResult->dwOperateCode, pOperateResult->wProvideUser);
|
|||
|
|
|
|||
|
|
// λ<>ü<EFBFBD><C3BC><EFBFBD>
|
|||
|
|
Point pos = GetWaveCardPoint(pOperateResult->wOperateUser);
|
|||
|
|
pWeaveCard->setPosition(pos);
|
|||
|
|
|
|||
|
|
uint8 cbWeaveCount = m_cbWeaveCount[pOperateResult->wOperateUser];
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A>
|
|||
|
|
if (pOperateResult->wOperateUser == 1)
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard, SP_RSTAND + MAX_COUNT - cbWeaveCount);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pWeaveCard[pOperateResult->wOperateUser][cbWeaveCount] = pWeaveCard;
|
|||
|
|
m_cbWeaveCount[pOperateResult->wOperateUser]++;
|
|||
|
|
|
|||
|
|
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ֻ<EFBFBD><D6BB>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>DZ<EFBFBD><C7B1>˳<EFBFBD><CBB3><EFBFBD>)
|
|||
|
|
//DelHandCard(pOperateResult->wOperateUser, pOperateResult->cbOperateCard, 2);
|
|||
|
|
for (int i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
SubOutCard(pOperateResult->cbOperateCard, pOperateResult->wOperateUser, false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Point WN_CardManager::GetWaveCardPoint(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
uint8 cbWeaveCount = m_cbWeaveCount[wChairID];
|
|||
|
|
|
|||
|
|
// λ<>ü<EFBFBD><C3BC><EFBFBD>
|
|||
|
|
Point pos;
|
|||
|
|
pos.x = m_ptWeaveCard[wChairID].x;
|
|||
|
|
pos.y = m_ptWeaveCard[wChairID].y;
|
|||
|
|
|
|||
|
|
// <20>Լ<EFBFBD><D4BC>϶Լ<CFB6>
|
|||
|
|
if (0 == wChairID)
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x - NCMJ_WEAVE_OPP*cbWeaveCount;
|
|||
|
|
}
|
|||
|
|
else if (1 == wChairID)
|
|||
|
|
{
|
|||
|
|
pos.y = pos.y + NCMJ_WEAVE_RIGHT*cbWeaveCount; // λ<><CEBB>ƫ<EFBFBD><C6AB>
|
|||
|
|
}
|
|||
|
|
else if (2 == wChairID)
|
|||
|
|
{
|
|||
|
|
pos.x = pos.x + NCMJ_WEAVE_SELF*cbWeaveCount;
|
|||
|
|
}
|
|||
|
|
else if (3 == wChairID)
|
|||
|
|
{
|
|||
|
|
pos.y = pos.y - NCMJ_WEAVE_LEFT*cbWeaveCount; // λ<><CEBB>ƫ<EFBFBD><C6AB>
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return pos;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::DelOutCard(WORD wChairID, uint8 cbCardData)
|
|||
|
|
{
|
|||
|
|
// <20>ṩ<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ƾ<EFBFBD><C6BE>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if (m_pCurrentOutCard && m_pCurrentOutCard->GetCardData() == cbCardData)
|
|||
|
|
{
|
|||
|
|
m_pCurrentOutCard->removeFromParentAndCleanup(true);
|
|||
|
|
m_pCurrentOutCard = nullptr;
|
|||
|
|
m_cbOutCarCount[wChairID]--;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::ResetHandCard(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(wChairID);
|
|||
|
|
|
|||
|
|
if (__list)
|
|||
|
|
{
|
|||
|
|
uint8 cbWeaveCout = m_cbWeaveCount[wChairID];
|
|||
|
|
|
|||
|
|
int _Cout = 0; // <20>ǿ<EFBFBD><C7BF>Ƹ<EFBFBD><C6B8><EFBFBD>
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = __list->begin(); it != __list->end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
Point pos = GetCardPoint(wChairID, _Cout);
|
|||
|
|
card->setPosition(pos);
|
|||
|
|
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>
|
|||
|
|
if (wChairID == SP_RSTAND)
|
|||
|
|
{
|
|||
|
|
card->setLocalZOrder(SP_RSTAND + MAX_COUNT - _Cout - cbWeaveCout);
|
|||
|
|
}
|
|||
|
|
else if (wChairID == SP_LSTAND)
|
|||
|
|
{
|
|||
|
|
card->setLocalZOrder(cbWeaveCout + _Cout);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_Cout++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::ShowCurrentCard(WORD wChairID, uint8 cbCardData)
|
|||
|
|
{
|
|||
|
|
if (wChairID < 0 || wChairID >= GAME_PLAYER) return;
|
|||
|
|
if (!WN_CGameLogic::IsValidCard(cbCardData)) return;
|
|||
|
|
|
|||
|
|
log("DEBUG CARD wChairID = %d out card = 0x%0x", wChairID, cbCardData);
|
|||
|
|
|
|||
|
|
if (m_pCurrentOutCard != nullptr)
|
|||
|
|
{
|
|||
|
|
m_pCurrentOutCard->SetCurrentOutCard(false);
|
|||
|
|
m_pCurrentOutCard = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
WN_SparrowCard* pOutCard = WN_SparrowCard::createWithDirection(cbCardData, (EN_SPARROW_TYPE)(SP_O_OUT + wChairID));
|
|||
|
|
if (pOutCard == nullptr) return;
|
|||
|
|
|
|||
|
|
Point endpos = GetOutPoint(wChairID);
|
|||
|
|
pOutCard->setPosition(endpos);
|
|||
|
|
|
|||
|
|
m_pOutCardSprite.push_back(pOutCard);
|
|||
|
|
m_cbOutCarCount[wChairID]++;
|
|||
|
|
|
|||
|
|
if (wChairID == SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
auto localZ = NCMJ_MAX_DISCARD_COUNT * 4 - m_cbOutCarCount[SELF_VIEW_CHAIRID];
|
|||
|
|
this->addChild(pOutCard, localZ);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(pOutCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pOutCard->SetCurrentOutCard(true);
|
|||
|
|
|
|||
|
|
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|||
|
|
m_pCurrentOutCard = pOutCard;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::ShowAllHandCard(WORD wChairID, uint8 cbCardCount, const uint8 cbCardData[MAX_COUNT])
|
|||
|
|
{
|
|||
|
|
if (cbCardCount <= 0) return;
|
|||
|
|
|
|||
|
|
cocos2d::log("game end Chair = %d, Hand card number = %d", wChairID, cbCardCount);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
ClearCardList(wChairID);
|
|||
|
|
if (m_pLastHandCard[wChairID] != nullptr)
|
|||
|
|
{
|
|||
|
|
m_pLastHandCard[wChairID]->removeFromParentAndCleanup(true);
|
|||
|
|
m_pLastHandCard[wChairID] = nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>´<EFBFBD><C2B4><EFBFBD>;
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(wChairID);
|
|||
|
|
if (__list)
|
|||
|
|
{
|
|||
|
|
int __index = 0;
|
|||
|
|
uint8 cbWeaveCout = m_cbWeaveCount[wChairID];
|
|||
|
|
|
|||
|
|
for (int i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Чֵ;
|
|||
|
|
if (!WN_CGameLogic::IsValidCard(cbCardData[i]))
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WN_SparrowCard* card = nullptr;
|
|||
|
|
if (SELF_VIEW_CHAIRID == wChairID)
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(cbCardData[i], (EN_SPARROW_TYPE)wChairID);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
card = WN_SparrowCard::createWithDirection(0, (EN_SPARROW_TYPE)wChairID);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
card->ShowCardValue(cbCardData[i]);
|
|||
|
|
card->setPosition(GetCardPoint(wChairID, __index));
|
|||
|
|
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>
|
|||
|
|
if (wChairID == SP_RSTAND)
|
|||
|
|
{
|
|||
|
|
this->addChild(card, SP_RSTAND + MAX_COUNT - __index - cbWeaveCout);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(card);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
__list->push_back(card);
|
|||
|
|
__index++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::ShowLastCard(uint8 cbCardData, WORD wGetCardUser, uint8 cbDirection)
|
|||
|
|
{
|
|||
|
|
if (wGetCardUser == SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
SendCard(cbCardData, wGetCardUser);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendCard(0x00, wGetCardUser);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (m_pLastHandCard[wGetCardUser] != nullptr)
|
|||
|
|
{
|
|||
|
|
m_pLastHandCard[wGetCardUser]->ShowCardValue(cbCardData);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/****************************************** <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD> **********************************************************************/
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD>
|
|||
|
|
void WN_CardManager::SceneWeaveCard(WORD wViewChairID, uint8 cbWeaveCount, tagWeaveItem WeaveItemArray[MAX_WEAVE], WORD wArrViewChairID[GAME_PLAYER])
|
|||
|
|
{
|
|||
|
|
ASSERT(cbWeaveCount <= MAX_WEAVE);
|
|||
|
|
|
|||
|
|
for (int i = 0; i < cbWeaveCount; i++)
|
|||
|
|
{
|
|||
|
|
DWORD dwOperateCode = WeaveItemArray[i].wWeaveKind;
|
|||
|
|
|
|||
|
|
uint8 cbTmpWeaveCount = m_cbWeaveCount[wViewChairID];
|
|||
|
|
WN_WeaveCard* pWeaveCard = WN_WeaveCard::create();
|
|||
|
|
if (nullptr == pWeaveCard) continue;
|
|||
|
|
|
|||
|
|
// <20>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD>ͼװ<CDBC><D7B0>;
|
|||
|
|
WeaveItemArray[i].wProvideUser = wArrViewChairID[WeaveItemArray[i].wProvideUser];
|
|||
|
|
|
|||
|
|
pWeaveCard->ShowCardData(wViewChairID, WeaveItemArray[i].cbCenterCard, WeaveItemArray[i].wWeaveKind, WeaveItemArray[i].wProvideUser);
|
|||
|
|
|
|||
|
|
// λ<>ü<EFBFBD><C3BC><EFBFBD>
|
|||
|
|
Point pos = GetWaveCardPoint(wViewChairID);
|
|||
|
|
pWeaveCard->setPosition(pos);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD><5A>
|
|||
|
|
if (1 == wViewChairID)
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard, SP_RSTAND + MAX_COUNT - cbTmpWeaveCount);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(pWeaveCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pWeaveCard[wViewChairID][cbTmpWeaveCount] = pWeaveCard;
|
|||
|
|
m_cbWeaveCount[wViewChairID]++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void WN_CardManager::SceneHandCard(WORD wViewChairID, uint8 cbCardCount, uint8 cbCardData[])
|
|||
|
|
{
|
|||
|
|
uint8 cbAllCount = m_cbWeaveCount[wViewChairID] * 3 + cbCardCount;
|
|||
|
|
ASSERT((cbAllCount == MAX_COUNT) || (cbAllCount == MAX_COUNT - 1));
|
|||
|
|
if ((cbAllCount != MAX_COUNT) && (cbAllCount != MAX_COUNT - 1))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int _ind = m_cbWeaveCount[wViewChairID] * 3; // ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
for (int j = 0; j < cbCardCount; j++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
// <20>Լ<EFBFBD><D4BC>ƴ<EFBFBD><C6B4><EFBFBD>
|
|||
|
|
if (wViewChairID == 2)
|
|||
|
|
{
|
|||
|
|
uint8 CardValue = cbCardData[j];
|
|||
|
|
|
|||
|
|
WN_SparrowCard* card = WN_SparrowCard::createWithDirection(CardValue, SP_SELFSTAND);
|
|||
|
|
card->addClickEventListener(CC_CALLBACK_2(WN_CardManager::onSendCardEvent, this));
|
|||
|
|
card->setPosition(GetCardPoint(wViewChairID, j));
|
|||
|
|
this->addChild(card);
|
|||
|
|
|
|||
|
|
m_SelfHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
// <20>Լ<EFBFBD><D4BC><EFBFBD>
|
|||
|
|
else if (wViewChairID == 0)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = WN_SparrowCard::createWithDirection(0xff, SP_OPPSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(wViewChairID, j));
|
|||
|
|
this->addChild(card);
|
|||
|
|
|
|||
|
|
m_OppHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
else if (wViewChairID == 3)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = WN_SparrowCard::createWithDirection(0xff, SP_LSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(wViewChairID, j));
|
|||
|
|
this->addChild(card, j + _ind + SP_LSTAND);
|
|||
|
|
|
|||
|
|
m_LeftHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
// <20>ұ<EFBFBD><D2B1><EFBFBD>
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = WN_SparrowCard::createWithDirection(0xff, SP_RSTAND);
|
|||
|
|
card->setPosition(GetCardPoint(wViewChairID, j));
|
|||
|
|
this->addChild(card, SP_RSTAND + MAX_COUNT - j - _ind);
|
|||
|
|
|
|||
|
|
m_RightHandCardList.push_back(card);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD>
|
|||
|
|
void WN_CardManager::SceneOutCard(WORD wViewChairID, uint8 cbCardCount, uint8 cbOutCardData[])
|
|||
|
|
{
|
|||
|
|
if (wViewChairID == INVALID_CHAIR) return;
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
for (int i = 0; i < cbCardCount; i++)
|
|||
|
|
{
|
|||
|
|
if (!WN_CGameLogic::getInstance()->IsValidCard(cbOutCardData[i])) continue;
|
|||
|
|
|
|||
|
|
// <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|||
|
|
WN_SparrowCard* pOutCard = WN_SparrowCard::createWithDirection(cbOutCardData[i], (EN_SPARROW_TYPE)((int)SP_O_OUT + wViewChairID));
|
|||
|
|
if (pOutCard == nullptr) continue;
|
|||
|
|
|
|||
|
|
Point pos = GetOutPoint(wViewChairID);
|
|||
|
|
pOutCard->setPosition(pos);
|
|||
|
|
|
|||
|
|
if (wViewChairID == SELF_VIEW_CHAIRID)
|
|||
|
|
{
|
|||
|
|
auto localZ = NCMJ_MAX_DISCARD_COUNT * 2 - m_cbOutCarCount[SELF_VIEW_CHAIRID];
|
|||
|
|
this->addChild(pOutCard, localZ);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->addChild(pOutCard);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//m_pOutCardSprite[wViewChairID][m_cbOutCarCount[wViewChairID]++] = pOutCard;
|
|||
|
|
m_pOutCardSprite.push_back(pOutCard);
|
|||
|
|
m_cbOutCarCount[wViewChairID]++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Point WN_CardManager::GetOutPoint(WORD wViewChairID)
|
|||
|
|
{
|
|||
|
|
uint8 cbOutCardCount = m_cbOutCarCount[wViewChairID];
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
WORD wSelfDisCardCount = NCMJ_MAX_DISCARD_COUNT;
|
|||
|
|
WORD wOppDisCardCount = NCMJ_MAX_DISCARD_COUNT + 1;
|
|||
|
|
WORD wLRDisCardCount = NCMJ_LR_DISCARD_COUNT;
|
|||
|
|
int nROutCardY = m_ptOutCard[3].y;
|
|||
|
|
int nLOutCardY = m_ptOutCard[1].y;
|
|||
|
|
int nSOutCardX = m_ptOutCard[2].x;
|
|||
|
|
|
|||
|
|
//// 2<><32>;
|
|||
|
|
//if (m_wRealChairCount == 2)
|
|||
|
|
//{
|
|||
|
|
// wSelfDisCardCount = NCMJ_MAX_DISCARD_COUNT + 3;
|
|||
|
|
//}
|
|||
|
|
//else if (m_wRealChairCount == 3) // 3<><33>;
|
|||
|
|
//{
|
|||
|
|
// wSelfDisCardCount = NCMJ_MAX_DISCARD_COUNT + 3;
|
|||
|
|
// wLRDisCardCount = NCMJ_LR_DISCARD_COUNT + 4;
|
|||
|
|
|
|||
|
|
// // ƫ<><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
// nLOutCardY += NCMJ_LROUT_CARD_HIGHT * 4;
|
|||
|
|
// nROutCardY += NCMJ_LROUT_CARD_HIGHT * 4;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
if (m_wRealChairCount == 2)
|
|||
|
|
{
|
|||
|
|
// <20>Լ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ҿɼ<D2BF><C9BC><EFBFBD>;
|
|||
|
|
if (!m_bActiveStatus[0])
|
|||
|
|
{
|
|||
|
|
wLRDisCardCount = NCMJ_LR_DISCARD_COUNT + 4;
|
|||
|
|
// ƫ<><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
nLOutCardY += NCMJ_LROUT_CARD_HIGHT * 6 + NCMJ_LROUT_CARD_HIGHT / 2;
|
|||
|
|
nROutCardY += NCMJ_LROUT_CARD_HIGHT * 6 + NCMJ_LROUT_CARD_HIGHT / 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
wSelfDisCardCount = NCMJ_MAX_DISCARD_COUNT + 5;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>ʼλ<CABC><CEBB>;
|
|||
|
|
if (!m_bActiveStatus[3])
|
|||
|
|
{
|
|||
|
|
nSOutCardX -= NCMJ_OUT_CARD_WIDHT * 2;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (m_wRealChairCount == 3) // 3<EFBFBD><EFBFBD>;
|
|||
|
|
{
|
|||
|
|
wSelfDisCardCount = NCMJ_MAX_DISCARD_COUNT + 3;
|
|||
|
|
|
|||
|
|
// <20>Լ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ҿɼ<D2BF><C9BC><EFBFBD>;
|
|||
|
|
if (!m_bActiveStatus[0])
|
|||
|
|
{
|
|||
|
|
wLRDisCardCount = NCMJ_LR_DISCARD_COUNT + 4;
|
|||
|
|
// ƫ<><C6AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|||
|
|
nLOutCardY += NCMJ_LROUT_CARD_HIGHT * 6;
|
|||
|
|
nROutCardY += NCMJ_LROUT_CARD_HIGHT * 6;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD><D3BA>IJ<EFBFBD><C4B2>ι<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
int x = 0;
|
|||
|
|
int y = 0;
|
|||
|
|
|
|||
|
|
switch (wViewChairID)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>һ<EFBFBD><D2BB>
|
|||
|
|
x = m_ptOutCard[0].x - NCMJ_OUT_CARD_WIDHT * (cbOutCardCount % wOppDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
y = m_ptOutCard[0].y - NCMJ_OUT_CARD_HIGHT * (cbOutCardCount / wOppDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
x = m_ptOutCard[3].x + NCMJ_LROUT_CARD_WIDHT*(cbOutCardCount / wLRDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
y = nROutCardY - NCMJ_LROUT_CARD_HIGHT * (cbOutCardCount % wLRDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
x = nSOutCardX + NCMJ_OUT_CARD_WIDHT * (cbOutCardCount % wSelfDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
y = m_ptOutCard[2].y + NCMJ_OUT_CARD_HIGHT * (cbOutCardCount / wSelfDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
x = m_ptOutCard[1].x - NCMJ_LROUT_CARD_WIDHT*(cbOutCardCount / wLRDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
y = nLOutCardY - NCMJ_LROUT_CARD_HIGHT * (cbOutCardCount % wLRDisCardCount)*OUT_CARD_SCALE;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
ASSERT(false);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return Point(x, y);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
std::list<WN_SparrowCard*> * WN_CardManager::GetCardList(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
switch (wChairID)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
return &m_OppHandCardList;
|
|||
|
|
case 1:
|
|||
|
|
return &m_RightHandCardList;
|
|||
|
|
case 2:
|
|||
|
|
return &m_SelfHandCardList;
|
|||
|
|
case 3:
|
|||
|
|
return &m_LeftHandCardList;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return nullptr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void WN_CardManager::ClearCardList(WORD wChairID)
|
|||
|
|
{
|
|||
|
|
std::list<WN_SparrowCard*>* __list = GetCardList(wChairID);
|
|||
|
|
if (__list == nullptr) return;
|
|||
|
|
|
|||
|
|
for (std::list<WN_SparrowCard*>::iterator it = __list->begin(); it != __list->end(); it++)
|
|||
|
|
{
|
|||
|
|
WN_SparrowCard* card = *it;
|
|||
|
|
if (card)
|
|||
|
|
{
|
|||
|
|
card->removeFromParentAndCleanup(true);
|
|||
|
|
card = nullptr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
__list->clear();
|
|||
|
|
}
|