306 lines
9.2 KiB
C++
306 lines
9.2 KiB
C++
#pragma once
|
|
#include "cocos2d.h"
|
|
#include "ui/CocosGUI.h"
|
|
|
|
#include "GamePlayer.h"
|
|
#include "IndividualMission.h"
|
|
#include "GameMission.h"
|
|
#include "ChatScene.h"
|
|
#include "types.h"
|
|
|
|
#include "YvVoiceManager.hpp"
|
|
#include "YVTool.h"
|
|
#include "SystemNotice.h"
|
|
#include "SelectShareScene.h"
|
|
|
|
using namespace YVSDK;
|
|
|
|
#define addNetCBDefine(iSubCommand,pScence,pCallBack) \
|
|
addNetCB(iSubCommand,pScence,CC_CALLBACK_2(pCallBack,pScence),#pCallBack)
|
|
|
|
USING_NS_CC;
|
|
|
|
//性别枚举
|
|
enum enSex { enNull, enMan, enWoman };
|
|
|
|
#define Max_Zorder 100
|
|
|
|
// localZOrder 层级
|
|
enum ZOrder
|
|
{
|
|
ZO_DEFAULT = 0, // 默认
|
|
ZO_CARDMANAGER, // 麻将管理类
|
|
ZO_UPDOWN, // 上下翻
|
|
ZO_ANI, // 动画
|
|
ZO_TRUSTEE, // 托管
|
|
ZO_END, // 结算面板
|
|
ZO_PRIVATE, // 私人场面板
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// 语音结构;
|
|
struct tagCloudVoice
|
|
{
|
|
uint32 dwUserID;
|
|
std::string strFileID;
|
|
|
|
tagCloudVoice()
|
|
{
|
|
dwUserID = 0;
|
|
strFileID = "";
|
|
}
|
|
|
|
tagCloudVoice(const tagCloudVoice& c)
|
|
{
|
|
dwUserID = c.dwUserID;
|
|
strFileID = c.strFileID;
|
|
}
|
|
|
|
void StreamValue(DataStream& kData, bool bSend)
|
|
{
|
|
Stream_VALUE(dwUserID);
|
|
Stream_VALUE(strFileID);
|
|
}
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
class GameFrameBase
|
|
:public Scene
|
|
,public IClientKernelSink
|
|
,public IIndividualMissionSink
|
|
, public YVSDK::YVListern::YVUpLoadFileListern
|
|
{
|
|
public:
|
|
struct NET_CBInfo
|
|
{
|
|
NET_CBInfo():pSrc1(NULL)
|
|
{
|
|
|
|
}
|
|
|
|
int32 iIdex;
|
|
cocos2d::Ref* pSrc1;
|
|
std::string kCallFunName;
|
|
std::function<void(void*,int)> pCallBack;
|
|
};
|
|
|
|
typedef std::vector<NET_CBInfo> NET_CBInfoList;
|
|
|
|
public:
|
|
GameFrameBase();
|
|
~GameFrameBase();
|
|
|
|
virtual bool init(); // 场景初始化
|
|
virtual void onEnterTransitionDidFinish(); // 进场动画完成回调
|
|
virtual void onExit(); // 场景退出回调
|
|
|
|
virtual void ExitGame();
|
|
|
|
//继续游戏事件
|
|
void onEventContinueGame(EventCustom* event);
|
|
void onEventUserChat(EventCustom* event);
|
|
void onEventUserFace(EventCustom* event);
|
|
|
|
//退出按钮
|
|
void onClickExitGameButton(cocos2d::Ref*);
|
|
|
|
// 截图分享
|
|
void onButtonWeiXinImagic(Ref*);
|
|
|
|
// 定时获取网络延迟
|
|
void onGetNetWorkTime(float delta);
|
|
|
|
|
|
//控制接口
|
|
public:
|
|
//清理
|
|
virtual void clearInfo();
|
|
//关闭游戏
|
|
virtual void CloseGameClient();
|
|
//游戏重连
|
|
virtual void ReconnectServer();
|
|
//重置桌子信息(桌子上说有信息,包括玩家信息,防止玩家在邀请好友的时候,有玩家进出导致客户端收不到玩家状态信息未能更新桌面玩家信息)
|
|
virtual void ResetTable() = 0;
|
|
// 重置所有桌面数据(不包含玩家信息)
|
|
virtual void ResetAllData() = 0;
|
|
//视图椅子号
|
|
virtual WORD SwitchViewChairID(WORD wChairID)=0;
|
|
//获取快捷语音文件路径;
|
|
virtual const std::string getShortChatSoundPath(uint8 cbGender, int nIndex);
|
|
|
|
//游戏事件
|
|
public:
|
|
//旁观消息
|
|
virtual bool OnEventLookonMode(void* data, int dataSize);
|
|
//场景消息
|
|
virtual bool OnEventSceneMessage(uint8 cbGameStatus, bool bLookonUser, void* data, int dataSize);
|
|
//游戏消息
|
|
virtual bool OnEventGameMessage(int sub, void* data, int dataSize);
|
|
//发送函数
|
|
bool SendSocketData(uint16 wSubCmdID);
|
|
//发送函数
|
|
bool SendSocketData(uint16 wSubCmdID, void * data, uint16 dataSize);
|
|
//发送准备消息
|
|
bool SendUserReady();
|
|
//绑定网络消息
|
|
void addNetCB(int iIdex,cocos2d::Ref* pScence,std::function<void(void*,int)> pCallBack,std::string kCallName);
|
|
|
|
//用户事件
|
|
public:
|
|
//用户进入
|
|
virtual void OnEventUserEnter(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户进入
|
|
virtual void OnEventUserEnter(GamePlayer * pPlayer){};
|
|
//用户离开
|
|
virtual void OnEventUserLeave(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户离开;
|
|
virtual void OnEventUserLeave(GamePlayer * pPlayer){};
|
|
//用户积分
|
|
virtual void OnEventUserScore(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户状态
|
|
virtual void OnEventUserStatus(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户状态
|
|
virtual void OnEventUserStatus(GamePlayer * pPlayer){};
|
|
//用户属性
|
|
virtual void OnEventUserAttrib(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户头像
|
|
virtual void OnEventCustomFace(IClientUserItem * pIClientUserItem, bool bLookonUser);
|
|
//用户头像HTTP
|
|
virtual void onGPAccountInfoHttpIP(uint32 dwUserID, std::string strIP,std::string strHttp);
|
|
//用户位置
|
|
virtual void onEventUserLocation(IClientUserItem * pIClientUserItem, CMD_GF_S_UserLocation* pLocation);
|
|
|
|
//私人房
|
|
public:
|
|
virtual void OnSocketSubPrivateRoomInfo(CMD_GF_Private_Room_Info* pNetInfo)=0;
|
|
virtual void OnSocketSubPrivateEnd(void* data, int dataSize) = 0;
|
|
virtual void OnSocketSubPrivateDismissInfo(CMD_GF_Private_Dismiss_Info* pNetInfo) = 0;
|
|
virtual void OnSocketSubPrivateDismissResult(CMD_GF_Private_Dismiss_Result* pNetInfo) = 0;
|
|
virtual void OnSocketSubPrivateScoreInfo(CMD_GF_Private_Score_Info* pNetInfo);
|
|
|
|
virtual void onEventDismissRoom(cocos2d::EventCustom *event); // 解散房间
|
|
virtual void onEventAgreeDismissRoom(bool bAgree = true); // 同意解散房间
|
|
virtual void EventLeaveGame(cocos2d::EventCustom *event); // 离开游戏事件
|
|
virtual void PrivateRoomEnd(); // 私人场结束(子游戏掉线主动关闭网络);
|
|
virtual void onEventAutoUserReady(cocos2d::EventCustom *event); // 自由人数场玩家准备
|
|
|
|
public:
|
|
virtual bool OnSocketSubUserChat(void* data, int dataSize); //用户文字
|
|
virtual bool OnSocketSubUserFace(void* data, int dataSize); //用户表情
|
|
virtual bool RevTalkFile(void* data,int dataSize); //用户语音
|
|
virtual bool ShowUserFace(CMD_GF_S_UserExpression* pUserFace); //用户表情
|
|
|
|
virtual Animation* LoadFaceAnimations(uint16 wItemIndex);
|
|
virtual void showVoiceTip();
|
|
virtual void hideVoiceTip(const char *filePath);
|
|
virtual void SetSystemNode(ImageView* img); //设置公告控件
|
|
virtual bool OnSocketSubGameSystemMessage(void* data, int dataSize); //系统消息
|
|
virtual void ShowRollMessage(const std::string& message, int repeat = 0, bool bForever = false);
|
|
|
|
bool OnSocketSubNetWorkTime(void* data, int dataSize);
|
|
|
|
protected:
|
|
GamePlayer* getPoolPlayer(IClientUserItem * pIClientUserItem);
|
|
virtual GamePlayer* CreatePlayer(IClientUserItem * pIClientUserItem);
|
|
virtual void DeletePlayer(GamePlayer* pPlayer);
|
|
|
|
public:
|
|
virtual void upSelfPlayerInfo() = 0;
|
|
virtual void OnUserScore(GamePlayer* pPlayer) = 0; // 玩家积分
|
|
virtual Vec2 GetPlayerPosByUserID(uint32 wUserID) = 0;
|
|
|
|
public:
|
|
GamePlayer* getGamePlayerByUserItem(IClientUserItem * pIClientUserItem);
|
|
GamePlayer* getPlayerByChairID( uint16 wChairID );
|
|
GamePlayer* getPlayerByUserID( uint32 wUserID );
|
|
|
|
void addGamePlayerToList(GamePlayer* pPlayer);
|
|
void removeGamePlayerToList(GamePlayer* pPlayer);
|
|
GamePlayer* getSelfGamePlayer();
|
|
uint16 getSelfChairID();
|
|
|
|
// 隐藏所有玩家语音气泡;
|
|
void hideAllPlayerVoiceBubble();
|
|
|
|
//获取自已信息;
|
|
IClientUserItem * GetMeUserItem();
|
|
//获取同桌玩家;
|
|
IClientUserItem * GetTableUserItem(uint16 wChariID);
|
|
|
|
//设置连接服务器;
|
|
void SetServerItem(CGameServerItem* pServerItem);
|
|
|
|
//加载短语内容;
|
|
void loadShortChat(const std::string& strFilePath);
|
|
|
|
//获取快捷语列表;
|
|
const std::vector<std::string>& getShortChatList();
|
|
//获取快捷语文字;
|
|
std::string getShortChatInfoByIndex(int nIndex);
|
|
|
|
//录像处理;
|
|
public:
|
|
bool SetGameRecord(DataStream &kDataStream); // 设置游戏录像资源;
|
|
void SetMainGameID(DWORD dwGameID, bool isGameRecord); // 设置自己的视角;
|
|
void uiMenuInit(); // 菜单初始化;
|
|
bool StartRecord(WORD wGamePlayer); // 启动录像;
|
|
void LeftRecordAction(Ref* ref); // 左;
|
|
void RightRecordAction(Ref* ref); // 右;
|
|
|
|
virtual void NextRecordAction(float dt) = 0; // 子游戏实现录像处理;
|
|
virtual void StartGameRecord() = 0; // 子游戏中进行录像开始处理;
|
|
|
|
// 语音;
|
|
public:
|
|
// 上传监听;
|
|
virtual void onUpLoadFileListern(YVSDK::UpLoadFileRespond*);
|
|
|
|
// 语音播放完成;
|
|
void onPlayFinish();
|
|
|
|
protected:
|
|
GamePlayer* m_pSelfPlayer; // 自己信息
|
|
std::vector<GamePlayer*> m_kPlayers; // 玩家列表
|
|
std::vector<GamePlayer*> m_kPoolPlayer;
|
|
NET_CBInfoList m_kCBInfoList;
|
|
|
|
GameMission m_kGameMission; // 游戏网络连接
|
|
CMD_GF_C_PingTime m_PingTime; // PING
|
|
long long m_llNetWorkTime; // PING时间
|
|
|
|
public:
|
|
bool m_bPrivateEnd; // 私人场是否结束
|
|
ChatLayer* m_pChatLayer; // 聊天界面
|
|
Text* m_txtNetWorkTime; // 网络延迟时间
|
|
|
|
ImageView* m_SystemInfo; // 系统公告
|
|
SystemNotice* m_PlatformNotic;
|
|
CMD_GF_Private_Score_Info m_PrivateScoreInfo;
|
|
|
|
// 录像资源
|
|
protected:
|
|
Node* m_pMeunNOde; // 操作菜单
|
|
Button* m_btnExit; // 退出录像
|
|
Sprite* m_sprRepBg; // 功能按钮背景;
|
|
Button* m_btnBackWard; // 慢放
|
|
Button* m_btnForward; // 快放
|
|
Button* m_btnPlay; // 播放
|
|
Button* m_btnPause; // 停止
|
|
Text* m_txtRecordPercent; // 播放进度;
|
|
|
|
tagGameRecord m_GameRecord; // 游戏记录
|
|
int m_iActRecordIdex;
|
|
float m_RecordTime;
|
|
uint16 m_wRecordSelfChairID;
|
|
uint32 m_wMainGameID; // 主视角GAMEID
|
|
bool m_IsGameRecord; // 是否是录像模式;
|
|
|
|
float m_fLocationTimer; // 位置检测时间;
|
|
|
|
std::list<std::string> m_VoiceList; // 语音信息缓存;
|
|
std::map<std::string, WORD> m_voicechairid; // 语音包对应的座位号;
|
|
float m_fMusicVolume; // 背景音乐音量;
|
|
|
|
std::vector<std::string> m_vecShortChatList; // 快捷短语;
|
|
}; |