/*! \author Luxor */ void cChar::walkNextStep() { if ( isFrozen() ) return; if ( !hasPath() ) return; if ( !path->pathFound() ) path->exec(); sLocation pos = path->getNextPos(); if ( pos == getPosition() ) return; if ( isWalkable( pos, WALKFLAG_DYNAMIC|WALKFLAG_CHARS, this ) == illegal_z ) { safedelete( path ); return; } pCreatureInfo creature = creatures.getCreature( getId() ); if( creature!=NULL ) { if( creature->canFly() && ( fly_steps>0 ) ) if ( chance( 20 ) ) playAction( 0x13 ); // Flying animation } uint8_t dirXY = getDirFromXY(pos); dir = dirXY & 0x07; MoveTo( pos ); sendToPlayers( this, dirXY ); setNpcMoveTime(); }
void GameCharacterShape::playAction(const std::string& actionName, bool loop, ActionFrameEventCallback eventCallBack) { // @_@ 需要检查一下是否有指定动画 std::vector<std::string> tmpNames = _armature->getAnimation()->getAnimationData()->movementNames; for (int i = 0; i < tmpNames.size(); i++) { if (tmpNames[i] == actionName) { if (isNotInAnimation() || _currentAnimationName != actionName) { _armature->getAnimation()->play(actionName, -1, loop ? 9999999 : 0); _currentAnimationName = actionName; _frameEventCallBack = eventCallBack; // 设置帧事件的回调函数 _armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(GameCharacterShape::onFrameEvent)); } return; } } // 如果没有动画可以播放,就播放一个一定存在的动画idle playAction(IDLE_ACTION); }
double QL::repeatLastAction(int toAct, int numTimes, bool toTrain) { double lastScore = 0; for(int i = 0; i < numTimes && !gameOver(); ++i) { lastScore += playAction(toAct); } saveGrayScrn(); return lastScore; }
double QL::initSeq() { double netScore = 0; for(int i = 0; i < numFrmStack && !gameOver(); ++i) { netScore += playAction(ind2Act[rand()%numAction]); saveGrayScrn(); } return netScore; }
void SoundEntity::Entity_Action(const Atlas::Objects::Operation::RootOperation& act) { const std::list<std::string> &p = act->getParents(); std::list<std::string>::const_iterator I = p.begin(); if (I != p.end()) { const std::string& name = *I; playAction(name); } }
void SongControl::showGui() { if (_gui) _gui->deleteMe(); _gui = safe_new(Frame(_gui_parent, 0, 0, 0, 0, 1)); safe_new(Button(_gui, 0, 0, "Play", playAction())); safe_new(Button(_gui, 0, 0, "Stop", stopAction())); safe_new(Button(_gui, 0, 0, "Plus", increaseTempoAction())); safe_new(Button(_gui, 0, 0, "Minus", decreaseTempoAction())); _gui->packHorizontally(5); }
void gkActionActuator::execute(void) { if (!m_isInit) { m_isInit = true; doInit(); } if (!m_action) return; if (isPulseOff()) { m_ignorePulseOn = false; } else { if (m_mode == AA_LOOP_STOP) { if (!m_isPlaying) playAction(); } else //if (m_mode == AA_PLAY || m_mode == AA_LOOP_END) { if (!m_ignorePulseOn) { if (!m_isPlaying || m_reset) playAction(); } } } if (m_isPlaying) m_object->playAnimation(m_action, m_blend); }
void gkActionActuator::update(void) { if (!m_isPlaying) return; if (m_state != m_link->getState()) { stateChanged(); return; } gkScalar t = getElapsedTime() + m_start; bool end = t >= m_end; bool off = isPulseOff(); if (off) m_ignorePulseOn = false; if (m_mode == AA_LOOP_END) { if (end) { stopAction(); if (!off) playAction(); } } else if (m_mode == AA_LOOP_STOP) { if (off) stopAction(); else if (end) resetAction(false); } else //if (m_mode == AA_PLAY) { if (end) stopAction(); } }
void cMobile::playMoveAnimation(uint duration, bool running) { uchar action = 0; if (bodyType() == HUMAN) { // Armed movement position if (equipment[LAYER_RIGHTHAND]) { action = running ? 3 : 1; } else if (running) { action = 2; } // Warmode only got a walking animation if (warmode && !running) { action = 15; } } // Mounted movement if (bodyType() == HUMAN && equipment[LAYER_MOUNT]) { action = running ? 24 : 23; } playAction(action, duration); }