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

📄 gamesection.h

📁 游戏框架
💻 H
字号:
// ***************************************************************
//  GameSection   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameSection.h
//	Created:	2007/07/18
//	Modified:	2007/07/18   17:20
//	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_SECTION_HEAD_FILE
#define GAME_SECTION_HEAD_FILE

#pragma once
#include "gameframe.h"

//***************************************************************
//	    游戏环节类,提供对自定义游戏按环节划分单元处理,是对游
//		戏开发细分的基础。每个游戏必须有一个以上的环节,只有当
//		前环节才会接收到游戏主体的所有消息,不处于当前环节是收
//		不到任何消息。
//	    该类为环节的切换提供了事件处理,可在环节过程中初始化或
//		释放某些资源,或作额外的处理。
//***************************************************************
class GAME_FRAME_CLASS CGameSection :
	public IGameSection
{
protected:
	//管理句柄集合
	LPFRAMEMANAGERHANDLE						m_lpFMHandles;
	//环节ID
	WORD										m_wSectionID;
	//资源是否已加载完毕
	bool										m_bIsLoaded;
	//游戏视图
	CGameView*									m_pGameView;

public:
	//构造函数
	CGameSection(WORD wSectionID = 0);
	//析构函数
	virtual ~CGameSection(void);

	//公共方法
public:
	//设置游戏框架指针
	virtual void __cdecl SetFrameManagerHandles(LPFRAMEMANAGERHANDLE lpFMH);
	//返回环节ID
	virtual WORD __cdecl GetSectionID();
	//返回视图指针
	virtual CGameView* __cdecl GetGameView();
	//设置环节ID
	virtual void __cdecl SetSectionID(WORD wSectionID);
	//环节切换是否有效
	virtual bool __cdecl IsValidSwitch(WORD wBeforeSectionID);
	//资源标记为已加载
	virtual void __cdecl SetLoaded(bool bFlag);
	//资源是否已加载
	virtual bool __cdecl IsLoaded();

	//资源事件
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(CGameSection))?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 + -