-
大小: 22.06MB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2023-07-03
- 語言: 其他
- 標(biāo)簽: 網(wǎng)絡(luò)游戲??后臺開發(fā)??
資源簡介
多人網(wǎng)絡(luò)開發(fā)技術(shù),有利于游戲開發(fā)的童鞋們了解多人網(wǎng)絡(luò)后臺開發(fā)技術(shù)
代碼片段和文件信息
#include?“RoboCatPCH.h“
shared_ptr?Command::StaticReadAndCreate(?InputMemoryBitStream&?inInputStream?)
{
CommandPtr?retVal;
int?type?=?CM_INVALID;
inInputStream.Read(?type?);
uint32_t?networkId?=?0;
inInputStream.Read(?networkId?);
uint64_t?playerId?=?0;
inInputStream.Read(?playerId?);
switch?(?type?)
{
case?CM_ATTACK:
retVal?=?std::make_shared();
retVal->mNetworkId?=?networkId;
retVal->mPlayerId?=?playerId;
retVal->Read(?inInputStream?);
break;
case?CM_MOVE:
retVal?=?std::make_shared();
retVal->mNetworkId?=?networkId;
retVal->mPlayerId?=?playerId;
retVal->Read(?inInputStream?);
break;
default:
LOG(?“Read?in?an?unknown?command?type??“?);
break;
}
return?retVal;
}
void?Command::Write(?OutputMemoryBitStream&?inOutputStream?)
{
inOutputStream.Write(?mCommandType?);
inOutputStream.Write(?mNetworkId?);
inOutputStream.Write(?mPlayerId?);
}
AttackCommandPtr?AttackCommand::StaticCreate(?uint32_t?inMyNetId?uint32_t?inTargetNetId?)
{
AttackCommandPtr?retVal;
GameobjectPtr?me?=?NetworkManager::sInstance->GetGameobject(?inMyNetId?);
GameobjectPtr?target?=?NetworkManager::sInstance->GetGameobject(?inTargetNetId?);
uint64_t?playerId?=?NetworkManager::sInstance->GetMyPlayerId();
//can?only?issue?commands?to?this?unit?if?I?own?it?and?it‘s?a?cat
//and?if?the?target?is?a?cat?that‘s?on?a?different?team
if?(?me?&&?me->GetClassId()?==?RoboCat::kClassId?&&
me->GetPlayerId()?==??playerId?&&
target?&&?target->GetClassId()?==?RoboCat::kClassId?&&
target->GetPlayerId()?!=?me->GetPlayerId()?)
{
retVal?=?std::make_shared();
retVal->mNetworkId?=?inMyNetId;
retVal->mPlayerId?=?playerId;
retVal->mTargetNetId?=?inTargetNetId;
}
return?retVal;
}
void?AttackCommand::Write(?OutputMemoryBitStream&?inOutputStream?)
{
Command::Write(?inOutputStream?);
inOutputStream.Write(?mTargetNetId?);
}
void?AttackCommand::Read(?InputMemoryBitStream&?inInputStream?)
{
inInputStream.Read(?mTargetNetId?);
}
void?AttackCommand::ProcessCommand()
{
GameobjectPtr?obj?=?NetworkManager::sInstance->GetGameobject(?mNetworkId?);
if?(?obj?&&?obj->GetClassId()?==?RoboCat::kClassId?&&
obj->GetPlayerId()?==?mPlayerId?)
{
RoboCat*?rc?=?obj->GetAsCat();
rc->EnterAttackState(?mTargetNetId?);
}
}
MoveCommandPtr?MoveCommand::StaticCreate(?uint32_t?inNetworkId?const?Vector3&?inTarget?)
{
MoveCommandPtr?retVal;
GameobjectPtr?go?=?NetworkManager::sInstance->GetGameobject(?inNetworkId?);
uint64_t?playerId?=?NetworkManager::sInstance->GetMyPlayerId();
//can?only?issue?commands?to?this?unit?if?I?own?it?and?it‘s?a?cat
if?(?go?&&?go->GetClassId()?==?RoboCat::kClassId?&&?
go->GetPlayerId()?==?playerId?)
{
retVal?=?std::make_shared();
retVal->mNetworkId?=?inNetworkId;
retVal->mPlayerId?=?playerId;
retVal->mTarget?=?inTarget;
}
return?retVal;
}
void?MoveCommand::Write(?OutputMemoryBitStream&?inOutputStream?)
{
Command::Write(?inOutputStream
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????129??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????14328??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????2244??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????270??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????4250??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件?????635996??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????22829??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????8669??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????????3??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????13543??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????????3??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件??????????3??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????215??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????1786??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????424??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????434??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????2418??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????465??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????2352??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????383??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????761??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件?????????65??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????578??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????271??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????4617??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????5136??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????504??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件????????628??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????1231??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
?????文件???????1485??2017-08-19?21:31??多人網(wǎng)絡(luò)\Multipla
............此處省略1364個文件信息
- 上一篇:arcsde全套教程
- 下一篇:31wan游戲平臺
評論
共有 條評論