243 lines
6.9 KiB
C++
243 lines
6.9 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 "DDZ_Player.h"
|
|
#include "DDZ_GameLogic.h"
|
|
#include "DDZ_CMD.h"
|
|
#include "DDZ_HandCardLayer.h"
|
|
#include "DDZ_GameEndNode.h"
|
|
#include "DDZ_PrivateEndNode.h"
|
|
|
|
USING_NS_CC;
|
|
using namespace cocostudio;
|
|
using namespace std;
|
|
using namespace ui;
|
|
|
|
namespace DDZ_SPACE{
|
|
|
|
class DDZGameScene :public GameFrameBase
|
|
{
|
|
public:
|
|
//游戏类型ID;
|
|
const static int KIND_ID = 200;
|
|
////游戏客户端版本;
|
|
//const static int DDZ_VERSION_CLIENT = PROCESS_VERSION(6, 0, 3);
|
|
////游戏人数;
|
|
//const static int DDZ_MAX_PLAYER = 3;
|
|
static std::string getGameRule(uint32 dwGameRule);
|
|
|
|
public:
|
|
//创建场景;
|
|
CREATE_FUNC(DDZGameScene);
|
|
|
|
//场景初始化;
|
|
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);
|
|
|
|
//游戏消息处理;
|
|
|
|
//游戏开始;
|
|
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 SendPassCall();
|
|
|
|
//按钮点击事件;
|
|
void onButtonTipClick(Ref*);
|
|
|
|
//更新叫分按钮;
|
|
void updateCallButtons(uint16 wCurChairID, uint8 cbLastCallScore);
|
|
//更新按钮状态;
|
|
void updateButtonsStatus(uint16 wCurChairID, uint8 cbLeftSeconds, bool bTurnOver = false);
|
|
//隐藏出牌按钮;
|
|
void hideOutCardButtons();
|
|
//检测出牌按钮;
|
|
void checkOutCardButton();
|
|
//更新倍数;
|
|
void updateMultipleText();
|
|
|
|
//发牌;
|
|
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 OnEventUserStatus(GamePlayer * pPlayer);
|
|
//玩家金币改变;
|
|
virtual void OnUserScore(GamePlayer* pPlayer);
|
|
//玩家坐标;
|
|
virtual Vec2 GetPlayerPosByUserID(uint32 dwUserID);
|
|
//创建玩家;
|
|
virtual GamePlayer* CreatePlayer(IClientUserItem * pIClientUserItem);
|
|
|
|
// 同IP判断;
|
|
virtual void IsSameIp();
|
|
|
|
//私人场;
|
|
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:
|
|
//私人场信息;
|
|
Button* m_btnDismissRoom; //解散房间;
|
|
Button* m_btnWeiXin; //微信分享;
|
|
CMD_GF_Private_Room_Info m_PrivateRoomInfo;
|
|
uint32 m_dwRoomID; //房间号;
|
|
Text* m_txtPrivateRoomID; //房间号;
|
|
Text* m_txtPrivatePlayCount; //局数;
|
|
//Text* m_txtPrivateMultiple; //倍数;
|
|
Node* m_pVoiceNode; // 语音标志;
|
|
|
|
//界面
|
|
Node* m_rootNode; //场景;
|
|
Button* m_pBtnLeave; //离开房间;
|
|
DDZPlayer* m_aryPlayer[DDZ_GAME_PLAYER]; //玩家;
|
|
DDZPlayer* m_pLocalPlayer;
|
|
|
|
TextAtlas* m_pTxtBaseScore; //基数;
|
|
TextAtlas* m_pTxtMultiple; //倍数;
|
|
|
|
Button* m_pAryBtnCall[3]; //叫分按钮;
|
|
Button* m_pBtnNoCall; //不叫按钮;
|
|
|
|
Button* m_pBtnReady; //准备按钮;
|
|
Button* m_pBtnPass; //不出按钮;
|
|
Button* m_pBtnTips; //提示按钮;
|
|
Button* m_pBtnOutCard; //出牌按钮;
|
|
|
|
Sprite* m_pSprTips; //提示文字;
|
|
Layout* m_pPanelTrustee; //提示托管面板;
|
|
Layout* m_pPanelBackCard; //底牌面板;
|
|
|
|
DDZHandCardLayer* m_pHandCardLayer;
|
|
|
|
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[DDZ_MAX_COUNT]; //出牌数据;
|
|
|
|
bool m_aryTrustee[DDZ_GAME_PLAYER]; //托管标志;
|
|
|
|
bool m_bGameStart; //游戏是否开始;
|
|
uint16 m_wLandChairID; //地主玩家位置;
|
|
uint16 m_wCurChairID; //当前玩家位置;
|
|
uint8 m_aryHandCardData[DDZ_MAX_COUNT]; //自已手中的牌;
|
|
uint8 m_aryBackCardData[DDZ_BACK_COUNT]; //底牌数据;
|
|
|
|
uint8 m_aryHandCardCount[DDZ_GAME_PLAYER]; //桌子上玩家牌的数量;
|
|
uint8 m_aryAllHandCardData[DDZ_GAME_PLAYER][DDZ_MAX_COUNT];
|
|
|
|
std::string m_strGameRuleInfo;
|
|
|
|
CDDZGameLogic m_GameLogic;
|
|
DDZGameEndNode* m_pResultLayer; // 结算面板;
|
|
DDZPrivateEndNode* m_pPrivateScene; // 私人场面板;
|
|
|
|
// localZOrder 层级
|
|
enum ZOrder
|
|
{
|
|
ZO_DEFAULT = 0, // 默认
|
|
ZO_CARDMANAGER, // 麻将管理类
|
|
ZO_UPDOWN, // 上下翻
|
|
ZO_ANI, // 动画
|
|
ZO_TRUSTEE, // 托管
|
|
ZO_END, // 结算面板
|
|
ZO_PRIVATE, // 私人场面板
|
|
};
|
|
};
|
|
|
|
} |