//------------------------------------------------------------------------------------- void SpaceAvatarSelect::buttonHit(OgreBites::Button* button) { if(button->getCaption().find("start") != Ogre::UTFString::npos) { if(g_selAvatarDBID == 0) { MessageBox( NULL, "SpaceAvatarSelect::no selected avatar!", "warning!", MB_OK); return; } kbe_lock(); kbe_callEntityMethod(kbe_playerID(), "selectAvatarGame", KBEngine::StringConv::val2str(g_selAvatarDBID).c_str()); kbe_unlock(); OgreApplication::getSingleton().changeSpace(new SpaceWorld(mRoot, mWindow, mInputManager, mTrayMgr)); } else if(button->getCaption() == "create avatar") { kbe_lock(); kbe_callEntityMethod(kbe_playerID(), "reqCreateAvatar", "[1, \"kbengine\"]"); kbe_unlock(); } else { for(KBEngine::uint32 i=0; i<g_avatars.size(); i++) { if(button->getCaption() == g_avatars[i]) { Ogre::String dbid = Ogre::StringUtil::split(button->getCaption(), "_")[1]; g_selAvatarDBID = KBEngine::StringConv::str2value<KBEngine::DBID>(dbid.c_str()); ((OgreBites::Button*)mTrayMgr->getWidget("start"))->setCaption(Ogre::String("start[") + dbid + Ogre::String("]")); } } } }
//------------------------------------------------------------------------------------- void EntitySimple::addTime(Real deltaTime) { if(blocktime_ <= 0.f) { Ogre::Vector3 currpos = getLastPosition(); if(kbe_playerID() != mID) { Ogre::Vector3 movement = destPos_ - currpos; float speed = mMoveSpeed * deltaTime; movement.y = 0.f; Real mlen = movement.length(); if(mlen < speed || (mLastAnimName != "Run" && mlen <= 1.0f)) { if (mLastAnimName == "Run") { float y = currpos.y; currpos = destPos_; currpos.y = y; playAnimation("Idle"); } } else { movement.normalise(); // Òƶ¯Î»Öà movement *= speed; currpos += movement; playAnimation("Run"); } } blocktime_ = 0.f; setPosition(currpos.x, currpos.y, currpos.z); KBEntity::addTime(deltaTime); } else { blocktime_ -= deltaTime; playAnimation("Block"); } if(mLastAnims) mLastAnims->addTime(deltaTime); }
//------------------------------------------------------------------------------------- void EntityComplex::addTime(Real deltaTime) { if(mBodyNode) { if(mCamera) updateBody(deltaTime); updateAnimations(deltaTime); } Ogre::Vector3 currpos; if(mCamera) { currpos = getPosition(); updateCamera(deltaTime); } else { currpos = getLastPosition(); if(kbe_playerID() != mID) { Ogre::Vector3 movement = destPos_ - currpos; float speed = mMoveSpeed * deltaTime; movement.y = 0.f; Real mlen = movement.length(); if(mlen < speed || (mBaseAnimID != ANIM_RUN_BASE && mlen <= 1.0f)) { if (mBaseAnimID == ANIM_RUN_BASE) { float y = currpos.y; currpos = destPos_; currpos.y = y; setBaseAnimation(ANIM_IDLE_BASE); if (mTopAnimID == ANIM_RUN_TOP) setTopAnimation(ANIM_IDLE_TOP); } } else { movement.normalise(); // 移动位置 movement *= speed; currpos += movement; if (mBaseAnimID == ANIM_IDLE_BASE) { setBaseAnimation(ANIM_RUN_BASE, true); if (mTopAnimID == ANIM_IDLE_TOP) { setTopAnimation(ANIM_RUN_TOP, true); } } } } } setPosition(currpos.x, currpos.y, currpos.z); KBEntity::addTime(deltaTime); if(pWeaponTrailLeft_) pWeaponTrailLeft_->onUpdate(deltaTime); if(pWeaponTrailRight_) pWeaponTrailRight_->onUpdate(deltaTime); }