268 lines
8.3 KiB
C++
268 lines
8.3 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 "TimeNode.h"
|
|
#include "DZ_GamePlayer.h"
|
|
#include "DZ_GameLogic.h"
|
|
#include "DZ_HandCardLayer.h"
|
|
#include "DZ_GameEndNode.h"
|
|
#include "DZ_PrivateEndNode.h"
|
|
#include "DZ_CMD.h"
|
|
|
|
USING_NS_CC;
|
|
using namespace cocostudio;
|
|
using namespace std;
|
|
using namespace ui;
|
|
|
|
namespace DZ_SPACE{
|
|
|
|
class DZGameScene :public GameFrameBase
|
|
{
|
|
public:
|
|
//游戏类型ID;
|
|
const static int KIND_ID = 430;
|
|
static std::string getGameRule(uint32 dwGameRule);
|
|
|
|
public:
|
|
//创建场景;
|
|
CREATE_FUNC(DZGameScene);
|
|
|
|
//场景初始化;
|
|
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 onGameSceneSendCard(void* pData, int nDataSize);
|
|
//恢复叫分场景;
|
|
bool onGameSceneCallScore(void* pData, int nDataSize);
|
|
//恢复空闭场景;
|
|
bool onGameSceneFree(void* pData, int nDataSize);
|
|
|
|
//游戏消息处理;
|
|
//游戏开始;
|
|
void onSubGameStart(const void * pBuffer, uint16 wDataSize);
|
|
//玩家叫分;
|
|
void onSubCallScore(const void * pBuffer, uint16 wDataSize);
|
|
//庄家信息;
|
|
void onSubBankerInfo(const void * pBuffer, uint16 wDataSize);
|
|
//庄家叫牌;
|
|
void onSubCallCard(const void * pBuffer, uint16 wDataSize);
|
|
|
|
//玩家出牌;
|
|
void onSubOutCard(const void * pBuffer, uint16 wDataSize);
|
|
//玩家不出;
|
|
void onSubPassCard(const void * pBuffer, uint16 wDataSize);
|
|
//游戏结束;
|
|
void onSubGameEnd(const void * pBuffer, uint16 wDataSize);
|
|
//玩家托管;
|
|
void onSubTrustee(const void * pBuffer, uint16 wDataSize);
|
|
//排名;
|
|
void onSubRanking(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 moveSendCardSprite(Sprite* pCardSprite, uint16 wViewID, float fDelayTime);
|
|
//选牌回调;
|
|
void selectCardCallback(uint8* pCardData, uint8 cbCardCount);
|
|
|
|
//播放动画;
|
|
void playAnimate(int cbCardType, uint16 wFromChair, uint16 wToChair);
|
|
//播放声音;
|
|
void playSoundEffect(const int cbCardType, uint8 cbSex = 1, const uint8 cbData = 0, const bool isOutCard = false);
|
|
|
|
//结束动画;
|
|
void PlayGameEndAni(DZ_GAME_END_TYPE enGameEndType, const std::function<void()>& callback);
|
|
|
|
// 玩家信息处理
|
|
public:
|
|
virtual void OnEventUserEnter(GamePlayer * pPlayer); //用户进入;
|
|
virtual void OnEventUserStatus(GamePlayer * pPlayer); //用户状态;
|
|
virtual void OnEventUserLeave(GamePlayer * pPlayer); //用户离开;
|
|
virtual void OnUserScore(GamePlayer* pPlayer); //玩家金币改变;
|
|
virtual Vec2 GetPlayerPosByUserID(uint32 dwUserID); //玩家坐标;
|
|
virtual GamePlayer* CreatePlayer(IClientUserItem * pIClientUserItem); //创建玩家;
|
|
virtual void IsSameIp(); //同IP判断;
|
|
void autoOutCard(); //自动出牌;
|
|
|
|
//解析分享内容;
|
|
void parseShareContent(std::string& strContent);
|
|
|
|
//私人场;
|
|
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_txtRoomIDTip; //房间号标题;
|
|
Text* m_txtPrivateRoomID; //房间号;
|
|
//ImageView* m_imgRule; //局数背景;
|
|
Text* m_txtPrivatePlayCount; //局数;
|
|
ImageView* m_imgGameRule; //规则背景;
|
|
Sprite* m_imgGameEndAni; //结束动画;
|
|
|
|
Text* m_txtGameRule1; //规则;
|
|
Text* m_txtGameRule2; //规则;
|
|
Text* m_txtGameRule3; //规则;
|
|
|
|
Node* m_pVoiceNode; //语音标志;
|
|
int m_nVoiceTimeID; //语音定时器ID;
|
|
|
|
//界面;
|
|
Node* m_rootNode; //场景;
|
|
Button* m_pBtnLeave; //离开房间;
|
|
Button* m_pBtnTrustee; //托管按钮;
|
|
Button* m_btnChat; //聊天;
|
|
Button* m_btnVoice; //语音;
|
|
DZ_GamePlayer* m_aryPlayer[DZ_GAME_PLAYER]; //玩家;
|
|
DZ_GamePlayer* m_pLocalPlayer;
|
|
|
|
Button* m_pBtnCallScore; //叫分按钮;
|
|
Button* m_pBtnPassCall; //不叫按钮;
|
|
|
|
Button* m_pBtnCallCard; //叫牌按钮;
|
|
Layout* m_pPanelTips; //提示面板;
|
|
Text* m_txtTip; //提示文字;
|
|
Layout* m_pPanelCallCard; //叫牌面板;
|
|
Layout* m_pPanelCallHandCard; //叫牌手牌面板;
|
|
Layout* m_pPanelCallFinished; //叫完牌面板;
|
|
DZHandCardLayer* m_pCallCardLayer; //叫牌手牌;
|
|
|
|
Button* m_pBtnReady; //准备按钮;
|
|
Button* m_pBtnPass; //不出按钮;
|
|
Button* m_pBtnTips; //提示按钮;
|
|
Button* m_pBtnOutCard; //出牌按钮;
|
|
Layout* m_pPanleMoveOutCard; //更多出牌;
|
|
Button* m_pbtnCancelTrustee; //托管按钮;
|
|
Sprite* m_pSprTips; //提示文字;
|
|
Layout* m_pPanelTrustee; //提示托管面板;
|
|
Button* m_pBtnSort; //排序;
|
|
|
|
DZHandCardLayer* m_pHandCardLayer; //手牌控件;
|
|
uint8 m_cbTimeOutCard; //出牌时间;
|
|
uint8 m_cbTimeCallScore; //叫分时间;
|
|
uint8 m_cbTimeStartGame; //开始时间;
|
|
uint8 m_cbTimeHeadOutCard; //首次出牌时间;
|
|
|
|
uint8 m_cbLastOutCardType; //最后一次出牌类型;
|
|
uint8 m_cbBombCount; //炸弹次数;
|
|
int m_nCellScore; //基数;
|
|
|
|
uint8 m_cbSearchOutCardIndex; //搜索出牌索引;
|
|
uint16 m_wTurnWiner; //胜利玩家;
|
|
DZ_CMD_C_OutCard m_TurnOutCard; //上家出牌;
|
|
DZ_CMD_C_OutCard m_SelfOutCard; //自己当前出牌信息,用于点击出牌按钮;
|
|
DZ_CMD_C_OutCard m_TipOutCard; //提示出牌;
|
|
|
|
bool m_aryTrustee[DZ_GAME_PLAYER]; //托管标志;
|
|
|
|
bool m_bNobodyCall; //没有玩家叫牌;
|
|
bool m_bGameStart; //游戏是否开始;
|
|
uint16 m_wLandChairID; //地主玩家位置;
|
|
uint16 m_wCurChairID; //当前玩家位置;
|
|
uint16 m_wFriendChairID; //伙伴椅子号;
|
|
int m_nSort; //排序方式;
|
|
|
|
uint8 m_aryHandCardData[DZ_MAX_COUNT]; //自已手中的牌;
|
|
uint8 m_aryAllHandCardData[DZ_GAME_PLAYER][DZ_MAX_COUNT];
|
|
|
|
uint8 m_aryHandCardCount[DZ_GAME_PLAYER]; //桌子上玩家牌的数量;
|
|
uint8 m_aryTempCardCount[DZ_GAME_PLAYER]; //游戏开始时玩家牌数;
|
|
|
|
std::string m_strGameRuleInfo;
|
|
|
|
DZ_CGameLogic m_GameLogic;
|
|
DZGameEndNode* m_pResultLayer; // 结算面板;
|
|
DZPrivateEndNode* m_pPrivateScene; // 私人场面板;
|
|
|
|
|
|
// localZOrder 层级;
|
|
enum DZ_ZOrder
|
|
{
|
|
DZ_ZO_DEFAULT = 0, // 默认;
|
|
DZ_ZO_CARDMANAGER, // 麻将管理类;
|
|
DZ_ZO_UPDOWN, // 上下翻;
|
|
DZ_ZO_ANI, // 动画;
|
|
DZ_ZO_TRUSTEE, // 托管;
|
|
DZ_ZO_END, // 结算面板;
|
|
DZ_ZO_PRIVATE, // 私人场面板;
|
|
};
|
|
};
|
|
|
|
} |