⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamebody.h

📁 游戏框架
💻 H
字号:
// ***************************************************************
//  GameBody   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameBody.h
//	Created:	2007/07/18
//	Modified:	2007/07/18   17:26
//	Author:		William.Liang
//  Msn:		lwq49@msn.com
//  Email:		lwq49@21cn.com, lwq49@msn.com
//	Description:
//
//	Purpose:	
//  -------------------------------------------------------------
//  license:
//
//  The contents of this file are subject to the Mozilla Public
//  License Version 1.1 (the "License"); you may not use this file
//  except in compliance with the License. You may obtain a copy
//  of the License at http://www.mozilla.org/MPL/ Software dis-
//  tributed under the License is distributed on an "AS IS" 
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
//  plied. See the License for the specific language governing
//  rights and limitations under the License.
//
//  The Initial Developer of the Original Code is William.Liang .
//  Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#ifndef GAME_BODY_HEAD_FILE
#define GAME_BODY_HEAD_FILE

#pragma once
#include "gameframe.h"

//***************************************************************
//	    游戏主体,用户基于OGF框架开发所需要自行定义的一层。
//		该类是实现游戏划分、管理、逻辑处理的基础,在此可接收
//		鼠标、键盘、计时器、网络等事件的消息并处理。
//***************************************************************
class GAME_FRAME_CLASS CGameBody :
	public IGameBody
{
protected:
	//管理句柄集合
	LPFRAMEMANAGERHANDLE						m_lpFMHandles;
	//环节管理
	CListTemplate<IGameSection*, WORD>			m_pGameSections;
	//当前环节
	IGameSection*								m_pCurrentSection;
	//队列引擎
	CQueueServiceEvent*							m_pQueueServiceEvent;
	//布局管理
	IGameLayouter*								m_pGameLayouter;

public:
	//构造函数
	CGameBody(void);
	//析构函数
	virtual ~CGameBody(void);

public:
	//设置游戏框架指针
	virtual void __cdecl SetFrameManagerHandles(LPFRAMEMANAGERHANDLE lpFMH);
	//添加环节
	virtual bool __cdecl Add(IGameSection* pIGameSection, WORD wSectionID);
	//切换环节
	virtual bool __cdecl SwitchSection(WORD wSectionID);
	//返回环节
	virtual IGameSection* __cdecl GetSection(WORD wSectionID);
	//返回当前环节
	virtual IGameSection* __cdecl GetCurrentSection();
	//注册布局管理器
	virtual bool __cdecl RegisterLayouter(IGameLayouterSink* pGameLayouterSink=NULL);
	//返回布局管理器
	virtual IGameLayouter* __cdecl GetLayouter();

	//资源事件
public:
	//资源加载事件
	virtual void __cdecl OnLoading();
	//资源加载完毕
	virtual void __cdecl OnLoadingFinish();

public:
	//初始化事件
	virtual bool __cdecl OnInitialize();
	//结束事件
	virtual bool __cdecl OnUnInitialize();
	//进入环节事件
	virtual bool __cdecl OnSectionIn(WORD wBeforeSection);
	//离开环节事件
	virtual bool __cdecl OnSectionOut(WORD wAfterSection);

	//鼠标移动
	virtual bool __cdecl OnMouseMove(float x, float y, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseClick(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseDBClick(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseUp(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseDown(IGameObject* pGameObject, float x, float y, UINT nMessage, UINT nComboKey);
	//鼠标移入
	virtual bool __cdecl OnMouseIn(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标移出
	virtual bool __cdecl OnMouseOut(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标移过
	virtual bool __cdecl OnMouseOver(IGameObject* pGameObject, float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//键盘事件
	virtual bool __cdecl OnKeyPass(TCHAR nKey, UINT nFlag);
	//键盘事件
	virtual bool __cdecl OnKeyUp(UINT nKey, UINT nFlag);
	//键盘事件
	virtual bool __cdecl OnKeyDown(UINT nKey, UINT nFlag);
	//视图激活
	virtual bool __cdecl OnActionAreaActive(WORD wActionArea);
	//网络事件
	virtual void __cdecl OnNetworkEvent(COPYDATASTRUCT* lpCopyData);
	//游戏事件
	virtual void __cdecl OnGameEvent();
	//每帧事件
	virtual void __cdecl OnFrame();
	//预渲染事件
	virtual void __cdecl OnPreRender(WPARAM wParam=NULL);
	//渲染事件
	virtual void __cdecl OnRender(WPARAM wParam=NULL);
	//系统控件消息
	virtual void __cdecl OnControlMessage(IGameObject* pIGameObject, WPARAM wParam,LPARAM lParam);
	//用户消息
	virtual void __cdecl OnUserMessage(WPARAM wParam,LPARAM lParam);
	//Windows消息处理函数
	virtual void __cdecl OnWindowMsgProce(UINT Msg,WPARAM wParam,LPARAM lParam);

	//管理接口
public:
	//调度模块启动
	virtual bool __cdecl StartService(IUnknownEx * pIUnknownEx);
	//调度模块关闭
	virtual bool __cdecl StopService(IUnknownEx * pIUnknownEx);
	//事件处理接口
	virtual bool __cdecl OnAttemperEvent(WORD wIdentifier, void * pBuffer, WORD wDataSize, DWORD dwInsertTime);

	//事件接口
public:
	//定时器事件
	virtual bool __cdecl OnEventTimer(WORD wTimerID, WPARAM wBindParam);
	//动作结束事件
	virtual bool __cdecl OnEventAction(IGameObject* pIGameObject, WORD wActionID, DWORD dwRepeatTimes, WPARAM wBindParam);
	//数据库事件
	virtual bool __cdecl OnEventDataBase(void * pDataBuffer, WORD wDataSize, NTY_DataBaseEvent * pDataBaseEvent);
	//网络应答事件
	virtual bool __cdecl OnEventSocketAccept(NTY_SocketAcceptEvent * pSocketAcceptEvent);
	//网络读取事件
	virtual bool __cdecl OnEventSocketRead(CMD_Command Command, void * pDataBuffer, WORD wDataSize, NTY_SocketReadEvent * pSocketReadEvent);
	//网络关闭事件
	virtual bool __cdecl OnEventSocketClose(NTY_SocketCloseEvent * pSocketCloseEvent);
	//网络连接消息
	virtual bool __cdecl OnEventClientSocketConnect(int iErrorCode, LPCTSTR pszErrorDesc);
	//网络读取消息
	virtual bool __cdecl OnEventClientSocketRead(CMD_Command Command, void * pBuffer, WORD wDataSize);
	//网络关闭消息
	virtual bool __cdecl OnEventClientSocketClose();

	//Add By Randy at 8.27
	//HEG的焦点控制处理
public:
	//失去焦点回调函数
	virtual void  __cdecl OnFocusLostFunc(void);
	//重获焦点回调函数
	virtual void  __cdecl OnFocusGainFunc(void);

	//模板方法
public:
	//是否有效
	virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CGameBody))?true:false;};
	//释放对象
	virtual bool __cdecl Release();
	//接口查询
	virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer);
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -