本文整理汇总了C++中ItemPtr::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr::getType方法的具体用法?C++ ItemPtr::getType怎么用?C++ ItemPtr::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemPtr
的用法示例。
在下文中一共展示了ItemPtr::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: walk
void Creature::walk(const Position& position, bool inverse)
{
// set walking state
bool sameWalk = m_walking && !m_inverseWalking && inverse;
m_walking = true;
m_inverseWalking = inverse;
int walkTimeFactor = 1;
// set new direction
if(m_position + Position(0, -1, 0) == position) {
setDirection(Otc::North);
m_walkOffset.y = 32;
}
else if(m_position + Position(1, 0, 0) == position) {
setDirection(Otc::East);
m_walkOffset.x = -32;
}
else if(m_position + Position(0, 1, 0) == position) {
setDirection(Otc::South);
m_walkOffset.y = -32;
}
else if(m_position + Position(-1, 0, 0) == position) {
setDirection(Otc::West);
m_walkOffset.x = 32;
}
else if(m_position + Position(1, -1, 0) == position) {
setDirection(Otc::NorthEast);
m_walkOffset.x = -32;
m_walkOffset.y = 32;
walkTimeFactor = 2;
}
else if(m_position + Position(1, 1, 0) == position) {
setDirection(Otc::SouthEast);
m_walkOffset.x = -32;
m_walkOffset.y = -32;
walkTimeFactor = 2;
}
else if(m_position + Position(-1, 1, 0) == position) {
setDirection(Otc::SouthWest);
m_walkOffset.x = 32;
m_walkOffset.y = -32;
walkTimeFactor = 2;
}
else if(m_position + Position(-1, -1, 0) == position) {
setDirection(Otc::NorthWest);
m_walkOffset.x = 32;
m_walkOffset.y = 32;
walkTimeFactor = 2;
}
else { // Teleport
// we teleported, dont walk or change direction
m_walking = false;
m_walkOffset.x = 0;
m_walkOffset.y = 0;
m_animation = 0;
}
if(!m_inverseWalking) {
m_walkOffset.x = 0;
m_walkOffset.y = 0;
}
if(m_walking) {
// get walk speed
int groundSpeed = 100;
ItemPtr ground = g_map.getTile(position)->getGround();
if(ground)
groundSpeed = ground->getType()->parameters[ThingType::GroundSpeed];
float walkTime = walkTimeFactor * 1000.0 * (float)groundSpeed / m_speed;
walkTime = (walkTime == 0) ? 1000 : walkTime;
m_walkTimePerPixel = walkTime / 32.0;
if(!sameWalk)
m_walkStartTicks = g_clock.ticks();
updateWalk();
}
}