void COwnCharPlayer::setDifference(const Vector2 &dif) { m_difference = dif; if( (m_difference.squaredLength() > getWalkSpeed() * getWalkSpeed()) && !m_blocked ) { setPosition(getPosition2() - m_difference); m_difference = Vector2::ZERO; CWorld::instance()->getWorldContext()->sendCoords(getPosition2(),getRotation(),0); // CClientApp::instance()->getWorldConn()->sendCoords(getPosition2(),getRotation(),0); /// We must begin new move after this m_stop = true; m_blocked = true; m_sinceLastSendPos = 0; m_rotated = false; }; };
void Player::logic() { switch (mAction) { case STAND: case SIT: case DEAD: case HURT: break; case WALK: mFrame = (get_elapsed_time(mWalkTime) * 6) / getWalkSpeed(); if (mFrame >= 6) nextStep(); break; case ATTACK: int rotation = 0; std::string particleEffect = ""; int frames = 4; if (mEquippedWeapon && mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW) { frames = 5; } mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed; //attack particle effect if (mEquippedWeapon) particleEffect = mEquippedWeapon->getParticleEffect(); if (!particleEffect.empty() && mParticleEffects && mFrame == 1) { switch (mDirection) { case DOWN: rotation = 0; break; case LEFT: rotation = 90; break; case UP: rotation = 180; break; case RIGHT: rotation = 270; break; default: break; } Particle *p; p = particleEngine->addEffect("graphics/particles/" + particleEffect, 0, 0, rotation); controlParticle(p); } if (mFrame >= frames) nextStep(); break; } Being::logic(); }
void Monster::logic() { if (mAction != STAND) { mFrame = (get_elapsed_time(mWalkTime) * 4) / getWalkSpeed(); if (mFrame >= 4 && mAction != DEAD) nextStep(); } Being::logic(); }
void Role::updateMoving() { Vec2 pos = getPosition(); float x = pos.x; float y = pos.y; switch (mMovingState) { case MOVING_RUN: if (mIsFaceLeft) x -= getRunSpeed(); else x += getRunSpeed(); setPosition(Vec2(x, y)); break; case MOVING_WALK: if (mIsFaceLeft) x -= getWalkSpeed(); else x += getWalkSpeed(); setPosition(Vec2(x, y)); break; } }
Vec2 Role::getMovingScope() { float y = 0.0f; float x = 0.0f; switch (mMovingState) { case MOVING_WALK: x = getWalkSpeed(); break; case MOVING_RUN: x = getRunSpeed(); break; } return Vec2(x, y); }