本文整理汇总了C++中ActionNode类的典型用法代码示例。如果您正苦于以下问题:C++ ActionNode类的具体用法?C++ ActionNode怎么用?C++ ActionNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateActionNode
bool Engine::MultiplyAndPush(NextAction** actions, float forceRelevance, bool skipPrerequisites, Event event, const char* pushType)
{
bool pushed = false;
if (actions)
{
for (int j=0; j<10; j++) // TODO: remove 10
{
NextAction* nextAction = actions[j];
if (nextAction)
{
ActionNode* action = CreateActionNode(nextAction->getName());
InitializeAction(action);
float k = nextAction->getRelevance();
if (forceRelevance > 0.0f)
{
k = forceRelevance;
}
if (k > 0)
{
LogAction("PUSH:%s - %f (%s)", action->getName().c_str(), k, pushType);
queue.Push(new ActionBasket(action, k, skipPrerequisites, event));
pushed = true;
}
delete nextAction;
}
else
break;
}
delete actions;
}
return pushed;
}
示例2: simulationActionUpdate
void ActionObject::simulationActionUpdate(float dt)
{
if (_loop)
{
bool isEnd = true;
int nodeNum = _actionNodeList->count();
for ( int i = 0; i < nodeNum; i++ )
{
ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i);
if (actionNode->isActionDoneOnce() == false)
{
isEnd = false;
break;
}
}
if (isEnd)
{
this->play();
}
//CCLOG("ActionObject Update");
}
}
示例3:
BeliefNode *BeliefNode::getChild(Action const &action, Observation const &obs) const {
ActionNode *node = actionMap_->getActionNode(action);
if (node == nullptr) {
return nullptr;
}
return node->getChild(obs);
}
示例4: clear
ActionQueue& ActionQueue::operator =(const ActionQueue &rightSide)
{
clear();
ActionNode *otherNode;
front = NULL;
back = NULL;
otherNode = rightSide.front;
if(otherNode != NULL)
{
front = new ActionNode(otherNode->getData());
back = front;
otherNode = otherNode->getLink();
}
while(otherNode != NULL)
{
back->setLink(new ActionNode(otherNode->getData()));
back = back->getLink();
otherNode = otherNode->getLink();
}
length = rightSide.length;
return *this;
}
示例5: ActionNode
ActionQueue::ActionQueue(const ActionQueue &queueObject)
{
ActionNode *otherNode;
front = NULL;
back = NULL;
otherNode = queueObject.front;
if(otherNode != NULL)
{
front = new ActionNode(otherNode->getData());
back = front;
otherNode = otherNode->getLink();
}
while(otherNode != NULL)
{
back->setLink(new ActionNode(otherNode->getData()));
back = back->getLink();
otherNode = otherNode->getLink();
}
length = queueObject.length;
}
示例6: simulationActionUpdate
void ActionObject::simulationActionUpdate(float dt)
{
bool isEnd = true;
int nodeNum = m_ActionNodeList->count();
for ( int i = 0; i < nodeNum; i++ )
{
ActionNode* actionNode = (ActionNode*)m_ActionNodeList->objectAtIndex(i);
if (actionNode->isActionDoneOnce() == false)
{
isEnd = false;
break;
}
}
if (isEnd)
{
if (m_CallBack != NULL)
{
m_CallBack->execute();
}
if (m_loop)
{
this->play();
}
}
}
示例7: setUnitTime
void ActionObject::setUnitTime(float fTime)
{
m_fUnitTime = fTime;
int frameNum = m_ActionNodeList->count();
for ( int i = 0; i < frameNum; i++ )
{
ActionNode* actionNode = (ActionNode*)m_ActionNodeList->objectAtIndex(i);
actionNode->setUnitTime(m_fUnitTime);
}
}
示例8: setUnitTime
void ActionObject::setUnitTime(float fTime)
{
_fUnitTime = fTime;
int nodeNum = _actionNodeList->count();
for ( int i = 0; i < nodeNum; i++ )
{
ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i);
actionNode->setUnitTime(_fUnitTime);
}
}
示例9: initActions
void Object::initActions(){
StoredDataHandler *storedDataHandler = StoredDataHandler::sharedInstance();
// Store the SpriteIndexNodes related to this object
spriteIndexNodes = storedDataHandler->getSpriteIndexHashes(identifier, objectType, spriteBatchHandler, Object_Z_Order);
spriteIndexNodes->retain();
// Get the actions of this object
CCArray *actions = storedDataHandler->getActionHashes(identifier, objectType);
actionsHashes = CCDictionary::create();
actionsHashes->retain();
// Init sprite frame for all action
{
for (int i = 0; i < actions->count(); i++) {
ActionNode *node = (ActionNode *)actions->objectAtIndex(i);
CCArray *frames = node->spriteIndexes;
// The assumption is all the sprite frames in a action belong to the same texture
SpriteIndexNode *spriteIndexNode = this->getSpriteIndexNodeBySpriteIndex(node->getFirstSpriteIndex());
// Create sprite frame objects
CCArray *spriteFrame = CCArray::create();
for (int j = 0; j < frames->count(); j++) {
CCString *spriteIndexStr = (CCString *)frames->objectAtIndex(j);
int spriteIndex = spriteIndexStr->intValue();
spriteFrame->addObject(spriteIndexNode->getSpriteFrameByIndex(spriteIndex));
}
node->setFirstSpriteFrame((CCSpriteFrame*)spriteFrame->objectAtIndex(0));
// Create animation object
CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteFrame, node->delay);
CCFiniteTimeAction *action = NULL;
if (node->isRecursive) {
action = CCRepeatForever::create(CCAnimate::create(animation));
} else {
action = CCAnimate::create(animation);
}
node->setAnimation(action);
// Get AIActions in this action
CCArray *AIActions = storedDataHandler->getAIActionsInAction(identifier, node->name, objectType);
CCArray *actionArray = CCArray::create(node, spriteIndexNode->getSpriteBatchNode(), AIActions, NULL);
// Add (CCAction, CCSpriteBatchNode) into the action hash
actionsHashes->setObject(actionArray, node->name);
}
}
this->performIdleAnimation();
}
示例10: stop
void ActionObject::stop()
{
int frameNum = _actionNodeList->count();
for ( int i = 0; i < frameNum; i++ )
{
ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i);
actionNode->stopAction();
}
_pScheduler->unscheduleSelector(schedule_selector(ActionObject::simulationActionUpdate), this);
_bPause = false;
}
示例11: updateToFrameByTime
void ActionObject::updateToFrameByTime(float fTime)
{
_currentTime = fTime;
int nodeNum = _actionNodeList->count();
for ( int i = 0; i < nodeNum; i++ )
{
ActionNode* actionNode = (ActionNode*)_actionNodeList->getObjectAtIndex(i);
actionNode->updateActionToTimeLine(fTime);
}
}
示例12: setName
void ActionObject::initWithDictionary(JsonDictionary *dic,Object* root)
{
setName(DICTOOL->getStringValue_json(dic, "name"));
setLoop(DICTOOL->getBooleanValue_json(dic, "loop"));
setUnitTime(DICTOOL->getFloatValue_json(dic, "unittime"));
int actionNodeCount = DICTOOL->getArrayCount_json(dic, "actionnodelist");
for (int i=0; i<actionNodeCount; i++) {
ActionNode* actionNode = new ActionNode();
actionNode->autorelease();
JsonDictionary* actionNodeDic = DICTOOL->getDictionaryFromArray_json(dic, "actionnodelist", i);
actionNode->initWithDictionary(actionNodeDic,root);
actionNode->setUnitTime(getUnitTime());
_actionNodeList->addObject(actionNode);
CC_SAFE_DELETE(actionNodeDic);
}
}
示例13: performAnimation
void Object::performAnimation(string name, SEL_CallFunc func){
if (this->getCurrentObjectState() == ObjectStateDead && name.compare("Dead") != 0) {
return;
}
CCSpriteBatchNode *currentSpriteBatchNode = m_pobBatchNode;
CCSpriteBatchNode *newSpriteBatchNode = NULL;
// Get the action pair by key name
CCArray *actionPair = (CCArray *)actionsHashes->objectForKey(name);
// If the action pair does not exist, return early
if (!actionPair) {
return;
}
newSpriteBatchNode = (CCSpriteBatchNode *)actionPair->objectAtIndex(1);
ActionNode *actionNode = (ActionNode *)actionPair->objectAtIndex(0);
this->stopActionByTag(ACTION_ANIMATION_TAG);
// If required spriteBatchNode is different from current, replace it
if (currentSpriteBatchNode != newSpriteBatchNode) {
this->removeFromParentAndCleanup(false);
this->setTexture(actionNode->getFirstSpriteFrame()->getTexture());
this->setTextureRect(actionNode->getFirstSpriteFrame()->getRect());
newSpriteBatchNode->addChild(this);
}
if (func != NULL) {
CCAssert(dynamic_cast<CCRepeatForever*>(actionNode->getAnimation()) == NULL, "Not able to call function for CCRepeatForever action.");
// Create animation followed by a function call
CCSequence *seq = CCSequence::createWithTwoActions(actionNode->getAnimation(), CCCallFunc::create(this, func));
seq->setTag(ACTION_ANIMATION_TAG);
this->runAction(seq);
} else {
// Run the action
actionNode->getAnimation()->setTag(ACTION_ANIMATION_TAG);
this->runAction(actionNode->getAnimation());
}
// Run AI in this action
{
if (actionPair->count() > 2) {
CCArray *AIActions = (CCArray *)actionPair->objectAtIndex(2);
CCLOG("%s is running AI, total AIAction count: %d", identifier.c_str(), AIActions->count());
for (int i = 0; i < AIActions->count(); i++) {
CCAction *action = (CCAction*)AIActions->objectAtIndex(i);
this->runAction(action);
}
}
}
}
示例14: ActionNode
ActionChoiceWindow::ActionNode*
ActionChoiceWindow::ActionNode::createActionTree(const ActionVector& actions, ActionGroup* rootGroup)
{
ActionNode* root = new ActionNode(false);
root->setGroup(rootGroup);
set<ActionGroup*> groups;
ActionVector rest;
for (ActionVector::const_iterator iter = actions.begin(); iter != actions.end(); iter++)
{
Action* action = *iter;
ActionGroup* group = action->getGroup();
if (group == NULL || group == rootGroup )
rest.push_back(action);
else if (groups.find(group) == groups.end())
groups.insert(group);
}
if (actions.size() / 1.2 <= rest.size() + groups.size())
{
groups.clear();
rest = actions;
}
for (set<ActionGroup*>::iterator groupIter = groups.begin();
groupIter != groups.end(); groupIter++)
{
ActionVector actionsThisGroup;
ActionGroup* thisGroup = *groupIter;
for (ActionVector::const_iterator actionIter = actions.begin();
actionIter != actions.end(); actionIter++)
{
Action* action = *actionIter;
if (action->getGroup() == thisGroup)
actionsThisGroup.push_back(action);
}
if (actionsThisGroup.size() > 0)
{
ActionNode* actionNodeGroup = createActionTree(actionsThisGroup, thisGroup);
root->addChild(actionNodeGroup);
}
}
for (ActionVector::iterator iter = rest.begin(); iter != rest.end(); iter++)
{
ActionNode* node = new ActionNode(true);
node->setAction(*iter);
root->addChild(node);
}
return root;
}
示例15: getAllNodes
ActionChoiceWindow::NodeSet ActionChoiceWindow::ActionNode::getAllNodesNotBelow(
ActionNode* treeRoot, ActionChoiceWindow::ActionNode* targetNode)
{
NodeSet allNodes;
getAllNodes(treeRoot, allNodes);
NodeSet nodes;
for (NodeSet::iterator iter = allNodes.begin(); iter != allNodes.end(); iter++)
{
bool leaveOut = false;
if ((*iter)->getParent() == treeRoot ||
*iter == targetNode ||
(*iter)->getButton() == NULL)
{
leaveOut = true;
continue;
}
ActionNode* node = *iter;
while(node->getParent() != NULL)
{
node = node->getParent();
if (node == targetNode)
{
leaveOut = true;
continue;
}
}
if (!leaveOut)
nodes.insert(*iter);
}
return nodes;
}