[手游新项目历程]第13天-游戏玩家怪物移动同步

本文探讨了游戏开发中的人物与怪物移动事件处理的相关机制,包括人物进入视野、移动通知、移动信息发送及怪物进入视野等关键事件。详细介绍了如何在不同场景下实现这些事件的响应与交互,涉及代码片段如`SetSceneId`、`updateplayer_tablesetx`、`CommMsg::ItemInfo_Attr`等,并展示了通过网络通信将角色移动信息传播给附近玩家的实现方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GAME_MSG_PLAYER_ENTER_VIEW			=		9002,					//人物进入视野
GAME_PLAYER_LOCATION_NOTIFY			=		9003,					//人物移动信息	
GAME_MSG_PLAYER_MOVE				=		1005,					//C -> C 人物移动信息	

  _snprintf(buf, sizeof(buf)-1, "%d", DbRet["GUID"]->GetLongLong() ); 
  
场景ID:1001 未加载!
地图资源没有加载, 玩家430000120|地图1001
SetSceneId

修改某个值
update player_table set x = 40

http://192.168.0.26/cq10/

for(Tint32 index = 0; index < attrLen; ++index)
{
	CommMsg::ItemInfo_Attr* attr = item.add_extraattrlist();
	attr->set_key(bagCell.m_DynamicExtraAttr[index].Key);
	Tint32 nValue = bagCell.m_DynamicExtraAttr[index].Value;
	attr->set_value(nValue);
}

Extralib::Timer::DateTime::GetCurSec()
void GamePlayer::SendEnterViewInfo( GamePlayer* pPlayer )

http://192.168.0.26/cq9/

void CSceneCell::SendCellEnterMsg( IRole* pPlayer, bool bIncludeNear )

bool Room::HandleOnMove( IRole * pRole )
void SyncCoord( ); //同步坐标到前端
std::set<IRole*> m_HandleMoveList;
bool Room::OnMove( IRole * pRole )
	
MonsterChangePosPlayData
((GamePlayer*)pRole)->GetGUID();

后进的没有先进的附近玩家
进场景获得附近玩家列表

vector<GamePlayer*> NearPlayers = GetNearPlayerList();

IntVector IRole::GetNearPlayersLua()
{
	IntVector roleidlist;
	CSceneCell* pSceneCell = GetSceneCell();
	if( !pSceneCell )
		return roleidlist;
	vector<GamePlayer*> vNear = pSceneCell->GetNearPlayerList();
	for(vector<GamePlayer*>::iterator itr=vNear.begin();itr!=vNear.end();itr++)
	{
		GamePlayer* pGamePlayer = *itr;
		roleidlist.Add(pGamePlayer->GetRoleId());
	}
	return roleidlist;
}

vector<GamePlayer*> GetNearPlayers();
void GamePlayer::SendEnterViewInfo( GamePlayer* pPlayer )
	
	
GAME_MSG_PLAYER_LEAVE_VIEW			=		143,					//人物离开视野
	
// 玩家离开地图返回
struct MsgRoleLeaveMapRes
{
	t_RoleID roleId_m;
};
	
共享内存 - 读写锁
GAME_MSG_MONSTER_ENTER_VIEW			=		141,					//怪物进入视野
	
struct MsgEnterViewMonsterInfo

GAME_MSG_MONSTER_LOCATION_RES		=		147,					//怪物移动信息
	
	
移动-》添加进移动列表
 for 移动列表
 {
	for 附近玩家列表
	{
		告诉他我移动了
	}
 }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值