本文整理汇总了C++中Projectile::getShootTick方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::getShootTick方法的具体用法?C++ Projectile::getShootTick怎么用?C++ Projectile::getShootTick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::getShootTick方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderAndUpdate
void Client::renderAndUpdate()
{
//render
worldRenderer.setupProjection();
if (worldModel.getPlayerObjs().exists(playerId))
{
Tickf currentTickf = getStepTick();
Tickf playerObjRenderTickf = currentTickf - static_cast<Tickf>(currentObjLag);
worldModel.updatePlayerObjsToTickData(playerObjRenderTickf);
(worldModel.getPlayerObjs())[playerId]->updateToTickData(currentTickf);
WorldModel::Projectiles::Iterator projectilesIt = worldModel.getProjectiles().begin();
WorldModel::Projectiles::Iterator projectilesEnd = worldModel.getProjectiles().end();
for(; projectilesIt != projectilesEnd; ++projectilesIt)
{
Projectile *projectile = projectilesIt->second;
assert(projectile);
Tickf projectileRenderTickf;
if (projectile->getShooterId() == static_cast<GameObjId>(playerId))
{
projectileRenderTickf = currentTickf;
}
else
{
projectileRenderTickf = Projectile::RENDER_LAG_MODS.getRenderTick(currentTickf, projectile, currentObjLag);
}
projectile->updateToTickData(projectileRenderTickf);
projectile->render = (projectileRenderTickf >= projectile->getShootTick());
}
worldRenderer.render(worldModel, players, (worldModel.getPlayerObjs())[playerId]);//, timeHandler.getStepTick());
}
requestRender = false;
//update
handleServerMessages();
}
示例2: handlePlayerShooting
void ServerWorldModel::handlePlayerShooting(PlayerId playerId, ServerPlayers &players)
{
int currentTick = getTimeHandler()->getTick();
Tickf currentTickf = static_cast<Tickf>(currentTick);
PlayerObj *playerObj = getPlayerObjs()[playerId];
// Copy userCmd, we must have a seperate copy to alter while original is intact.
UserCmd userCmd(playerObj->getUserCmd());
ClientIdGenerator *clientIdGenerator = players[playerId]->getIdGenerator();
int clientNShots = userCmd.nShots;
assert(userCmd.firstShotTick >= currentTickf);
assert(playerObj->getNextShootTick() >= currentTickf);
// remove projectiles if client created projectiles which we did't notice before
while (userCmd.firstProjectileId > clientIdGenerator->getNextId())
{
RemoveProjectile removeProjectile(clientIdGenerator->generateGameObjId());
players[playerId]->link.pushMessage(removeProjectile, getTimeHandler()->getTime(), getTimeHandler()->getTick());
}
assert(userCmd.firstProjectileId == clientIdGenerator->getNextId());
if (clientNShots > 0)
{
assert(userCmd.firstShotTick >= playerObj->getNextShootTick());
// Do any shooting
int serverNShots = 0;
Tickf shotTick;
Projectile::Type weapon = userCmd.weapon;
for(int i=0; i<clientNShots; ++i)
{
GameObjId projectileId = clientIdGenerator->generateGameObjId();
if (playerTryShoot(playerId, currentTick, i, projectileId, shotTick))
{
if (serverNShots == 0) userCmd.firstShotTick = shotTick;
Projectile *projectile = (getProjectiles())[projectileId];
std::cout << "server tick: " << getTimeHandler()->getTick() << " projectile shot, objLag = " << projectile->getObjLag() << std::endl;
// send projectile to all clients
AddProjectile addProjectile(projectileId, projectile->getType(), projectile->getPos(),
projectile->getAngle().getFloat(), projectile->getShooterId(),
projectile->getShootTick(), projectile->getObjLag());
pushMessageToAll(players, addProjectile, getTimeHandler()->getTime(), getTimeHandler()->getTick());
++serverNShots;
}
else
{
RemoveProjectile removeProjectile(projectileId);
players[playerId]->link.pushMessage(removeProjectile, getTimeHandler()->getTime(), getTimeHandler()->getTick());
}
}
userCmd.nShots = serverNShots;
// Safe to overwrite PlayerObj.userCmd now, write changes
playerObj->setUserCmd(&userCmd);
}
}