252 lines
7.1 KiB
C++
252 lines
7.1 KiB
C++
#pragma once
|
|
#include "cocos2d.h"
|
|
#include "cocostudio/CocoStudio.h"
|
|
#include "ui/CocosGUI.h"
|
|
|
|
#include "Singleton.h"
|
|
#include "GameFrameBase.h"
|
|
#include "PlatformHeader.h"
|
|
#include "PDK_Player.h"
|
|
#include "PDK_GameLogic.h"
|
|
#include "PDK_CMD.h"
|
|
#include "PDK_HandCardLayer.h"
|
|
#include "PDK_GameEndNode.h"
|
|
#include "PDK_PrivateEndNode.h"
|
|
|
|
USING_NS_CC;
|
|
using namespace cocostudio;
|
|
using namespace std;
|
|
using namespace ui;
|
|
|
|
namespace PDK_SPACE{
|
|
|
|
class PDKGameScene :public GameFrameBase
|
|
{
|
|
public:
|
|
//游戏类型ID;
|
|
//const static int KIND_ID = 210;
|
|
static std::string getGameRule(uint32 dwGameRule);
|
|
static int getRealChairCount(uint32 dwGameRule);
|
|
|
|
public:
|
|
//创建场景;
|
|
CREATE_FUNC(PDKGameScene);
|
|
|
|
//场景初始化;
|
|
virtual bool init();
|
|
//进场动画完成回调;
|
|
virtual void onEnterTransitionDidFinish();
|
|
//场景退出;
|
|
virtual void onExit();
|
|
|
|
public:
|
|
//椅子号视图转换;
|
|
virtual WORD SwitchViewChairID(WORD wChairID);
|
|
//更新玩家信息;
|
|
virtual void upSelfPlayerInfo();
|
|
|
|
//初始化场景;
|
|
void initScene();
|
|
//绑定网络消息;
|
|
void initNet();
|
|
|
|
//重置场景;
|
|
void resetScene(bool bAll=false);
|
|
//重置数据;
|
|
void resetData();
|
|
//重置数据;
|
|
void ResetAllData();
|
|
//重置桌子(相当于玩家离开);
|
|
virtual void ResetTable();
|
|
|
|
//获取快捷语音文件路径;
|
|
virtual const std::string getShortChatSoundPath(uint8 cbGender, int nIndex);
|
|
|
|
private:
|
|
//场景消息;
|
|
virtual bool OnEventSceneMessage(uint8 cbGameStatus, bool bLookonUser, void* pData, int nDataSize);
|
|
|
|
//恢复游戏场景;
|
|
bool onGameScenePlay(void* pData, int nDataSize);
|
|
//恢复叫分场景;
|
|
bool onGameSceneCall(void* pData, int nDataSize);
|
|
//恢复空闭场景;
|
|
bool onGameSceneFree(void* pData, int nDataSize);
|
|
//恢复发牌场景;
|
|
bool onGameSceneSend(void* pData, int nDataSize);
|
|
|
|
//游戏消息处理;
|
|
|
|
//游戏开始;
|
|
void onSubGameStart(const void * pBuffer, uint16 wDataSize);
|
|
//玩家叫分;
|
|
void onSubGameCallScore(const void * pBuffer, uint16 wDataSize);
|
|
//地主信息;
|
|
void onSubGameBankerInfo(const void * pBuffer, uint16 wDataSize);
|
|
//玩家出牌;
|
|
void onSubGameOutCard(const void * pBuffer, uint16 wDataSize);
|
|
//玩家不出;
|
|
void onSubGamePassCard(const void * pBuffer, uint16 wDataSize);
|
|
//设置基分;
|
|
void onSubGameSetBaseScore(const void * pBuffer, uint16 wDataSize);
|
|
//游戏结束;
|
|
void onSubGameEnd(const void * pBuffer, uint16 wDataSize);
|
|
//玩家托管;
|
|
void onSubGameTrustee(const void * pBuffer, uint16 wDataSize);
|
|
//开始叫分;
|
|
void onSubGameStartScore(const void * pBuffer, uint16 wDataSize);
|
|
|
|
//叫分消息;
|
|
void SendCallScore(bool bCallScore);
|
|
|
|
//按钮点击事件;
|
|
void onButtonTipClick(Ref*);
|
|
|
|
//更新叫分按钮;
|
|
void updateCallButtons();
|
|
//更新按钮状态;
|
|
void updateButtonsStatus(uint16 wCurChairID, uint8 cbLeftSeconds, bool bTurnOver = false);
|
|
//隐藏出牌按钮;
|
|
void hideOutCardButtons();
|
|
//检测出牌按钮;
|
|
void checkOutCardButton();
|
|
|
|
//发牌;
|
|
void moveSendCardSprite(Sprite* pCardSprite, uint16 wViewID, float fDelayTime);
|
|
//选牌回调;
|
|
void selectCardCallback(uint8* pCardData, uint8 cbCardCount);
|
|
//显示底牌;
|
|
void drawBackCardData();
|
|
//翻转底牌;
|
|
void flipBackCard();
|
|
//播放动画;
|
|
void playAnimate(uint8 cbCardType, uint16 wFromChair, uint16 wToChair);
|
|
//播放声音;
|
|
void playSoundEffect(const uint8 cbCardType, uint8 cbSex = 1, const uint8 cbData = 0);
|
|
|
|
//玩家进入;
|
|
virtual void OnEventUserEnter(GamePlayer * pPlayer);
|
|
//玩家状态改变;
|
|
virtual void OnEventUserStatus(GamePlayer * pPlayer);
|
|
//玩家金币改变;
|
|
virtual void OnUserScore(GamePlayer* pPlayer);
|
|
//玩家坐标;
|
|
virtual Vec2 GetPlayerPosByUserID(uint32 dwUserID);
|
|
//创建玩家;
|
|
virtual GamePlayer* CreatePlayer(IClientUserItem * pIClientUserItem);
|
|
|
|
// 同IP判断;
|
|
virtual void IsSameIp();
|
|
|
|
// 获取下家椅子号;
|
|
uint16 getNextChairID(WORD wChairID);
|
|
|
|
void SetChairs();
|
|
|
|
//私人场;
|
|
public:
|
|
//私人场信息;
|
|
virtual void OnSocketSubPrivateRoomInfo(CMD_GF_Private_Room_Info* pNetInfo);
|
|
//私人场结束;
|
|
virtual void OnSocketSubPrivateEnd(void* data, int dataSize);
|
|
//私人场解散信息;
|
|
virtual void OnSocketSubPrivateDismissInfo(CMD_GF_Private_Dismiss_Info* pNetInfo);
|
|
//私人场解散结果;
|
|
virtual void OnSocketSubPrivateDismissResult(CMD_GF_Private_Dismiss_Result* pNetInfo);
|
|
//自由人数场玩家状态;
|
|
virtual void OnSocketSubPrivateAutoUserStatus(tagAutoUserStatus* pNetInfo){}
|
|
//自由人数
|
|
virtual void OnSocketSubPrivateAutoUserReady(CMD_GR_Private_ReadyInfo* pNetInfo){}
|
|
|
|
//显示结算信息;
|
|
void onEventShowPrivate(cocos2d::EventCustom *event);
|
|
|
|
//按住语音按钮;
|
|
void OnButtonVoiceTouched(Ref*, Widget::TouchEventType);
|
|
|
|
//录像处理;
|
|
public:
|
|
virtual void StartGameRecord();
|
|
virtual void NextRecordAction(float dt);
|
|
|
|
private:
|
|
uint8 m_cbGameStatus; //游戏状态;
|
|
uint32 m_dwRoomID; //房间号;
|
|
bool m_aryActiveStatus[PDK_GAME_PLAYER]; //玩家手牌状态;
|
|
|
|
//私人场信息;
|
|
CMD_GF_Private_Room_Info m_PrivateRoomInfo;
|
|
|
|
Button* m_btnDismissRoom; //解散房间;
|
|
Button* m_btnWeiXin; //微信分享;
|
|
|
|
Text* m_txtPrivateRoomID; //房间号;
|
|
Text* m_txtPrivatePlayCount; //局数;
|
|
Text* m_txtCompareDesc; //规则;
|
|
|
|
Node* m_pVoiceNode; //语音标志;
|
|
|
|
//界面
|
|
Node* m_rootNode; //场景;
|
|
Button* m_pBtnLeave; //离开房间;
|
|
PDKPlayer* m_aryPlayer[PDK_GAME_PLAYER]; //玩家;
|
|
PDKPlayer* m_pLocalPlayer;
|
|
|
|
Button* m_pAryBtnCall; //叫分按钮;
|
|
Button* m_pBtnNoCall; //不叫按钮;
|
|
|
|
Button* m_pBtnReady; //准备按钮;
|
|
Button* m_pBtnPass; //不出按钮;
|
|
Button* m_pBtnTips; //提示按钮;
|
|
Button* m_pBtnOutCard; //出牌按钮;
|
|
|
|
Sprite* m_pSprTips; //提示文字;
|
|
|
|
uint8 m_cbTimeOutCard; //出牌时间;
|
|
uint8 m_cbTimeCallScore; //叫分时间;
|
|
uint8 m_cbTimeStartGame; //开始时间;
|
|
uint8 m_cbTimeHeadOutCard; //首次出牌时间;
|
|
|
|
uint8 m_cbBombCount; //炸弹次数;
|
|
uint8 m_cbCallScore; //叫分;
|
|
//int m_nCellScore; //基数;
|
|
|
|
uint16 m_wTurnWiner; //胜利玩家;
|
|
uint8 m_cbTurnCardCount; //出牌数目;
|
|
uint8 m_cbTurnCardData[PDK_MAX_COUNT]; //出牌数据;
|
|
|
|
uint16 m_wLastWiner; //最后一手牌玩家;
|
|
uint8 m_cbLastCardCount; //出牌数目;
|
|
uint8 m_cbLastCardData[PDK_MAX_COUNT]; //出牌数据;
|
|
|
|
bool m_bGameStart; //游戏是否开始;
|
|
uint16 m_wLandChairID; //地主玩家位置;
|
|
uint16 m_wCurChairID; //当前玩家位置;
|
|
uint8 m_cbMustOutCard; //必出牌;
|
|
|
|
uint8 m_aryHandCardData[PDK_MAX_COUNT]; //自已手中的牌;
|
|
uint8 m_arySendCardCount[PDK_GAME_PLAYER]; //每个玩家需要发牌数量;
|
|
uint8 m_aryHandCardCount[PDK_GAME_PLAYER]; //桌子上玩家牌的数量;
|
|
uint8 m_aryAllHandCardData[PDK_GAME_PLAYER][PDK_MAX_COUNT];
|
|
|
|
std::string m_strGameRuleInfo;
|
|
|
|
CPDKGameLogic m_GameLogic;
|
|
PDKGameEndNode* m_pResultLayer; // 结算面板;
|
|
PDKPrivateEndNode* m_pPrivateScene; // 私人场面板;
|
|
PDKHandCardLayer* m_pHandCardLayer; // 手牌控件;
|
|
|
|
// localZOrder 层级
|
|
enum ZOrder
|
|
{
|
|
ZO_DEFAULT = 0, // 默认
|
|
ZO_CARDMANAGER, // 麻将管理类
|
|
ZO_UPDOWN, // 上下翻
|
|
ZO_ANI, // 动画
|
|
ZO_TRUSTEE, // 托管
|
|
ZO_END, // 结算面板
|
|
ZO_PRIVATE, // 私人场面板
|
|
};
|
|
};
|
|
|
|
} |