1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453 |
- // -------------------------------------------------------------------------------
- // THIS FILE IS ORIGINALLY GENERATED BY THE DESIGNER.
- // YOU ARE ONLY ALLOWED TO MODIFY CODE BETWEEN '///<<< BEGIN' AND '///<<< END'.
- // PLEASE MODIFY AND REGENERETE IT IN THE DESIGNER FOR CLASS/MEMBERS/METHODS, ETC.
- // -------------------------------------------------------------------------------
- #include "RedBehaviacTree.h"
- ///<<< BEGIN WRITING YOUR CODE FILE_INIT
- #include "ReboltRedManager.h"
- #include <sstream>
- #include <iomanip>
- #include "ReboltRunDelegate.hpp"
- #include "InterstitialAdWaiter.hpp"
- #include "RewardedAdWaiter.hpp"
- #include "LoopWaiter.hpp"
- #include "PlayTimelineWaiter.hpp"
- #include "SubTreeWaiter.hpp"
- #include "LoopWaiter.hpp"
- #include "NotifyDevelopmentWaiter.hpp"
- #include "NodeAnimWaiter.hpp"
- #include "NodeAnimAsyncWaiter.hpp"
- #include "PlayTimeLineAsyncWaiter.hpp"
- ///<<< END WRITING YOUR CODE
- namespace red
- {
- ///<<< BEGIN WRITING YOUR CODE NAMESPACE_INIT
- ///<<< END WRITING YOUR CODE
- RedBehaviacTree::RedBehaviacTree()
- {
- temporaryVariablesBool = false;
- temporaryVariablesFloat = 0.0f;
- temporaryVariablesInt = 0;
- temporaryVariablesString = "";
- videoIsSuccess = false;
- ///<<< BEGIN WRITING YOUR CODE CONSTRUCTOR
- _isRunning = false;
- _localTreeFloatMap.clear();
- _localTreeStringMap.clear();
- _treeName = "";
- _reboltRunDelegate = nullptr;
- _runningSubtreeName = "";
- _getTreeStateSubtreeName = "";
- _getTreeStateRedPath = "";
- _argumentsBoolMap.clear();
- _argumentsStringMap.clear();
- _funLocalBoolMap.clear();
- _funLocalStringMap.clear();
- _runingAnimTag = 0;
- _canUpdateBySubTree = false;
- _waitableStateBase = nullptr;
- ///<<< END WRITING YOUR CODE
- }
- RedBehaviacTree::~RedBehaviacTree()
- {
- ///<<< BEGIN WRITING YOUR CODE DESTRUCTOR
- CC_SAFE_RELEASE_NULL(_waitableStateBase);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::addCustomDataVar(behaviac::string blockId, behaviac::string dataName, float content)
- {
- ///<<< BEGIN WRITING YOUR CODE addCustomDataVar
- onTreeStepStart(blockId, "addCustomDataVar");
- ReboltErrorInfo errorInfo;
- float lf = _reboltRedManager->getCustomFloat(dataName, errorInfo);
- processError(blockId, errorInfo);
- lf += content;
- lf = ((long long)(lf * 1000000)) / 1000000.0;
- _reboltRedManager->setCustomDataVar(dataName, to_string(lf));
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::addFunLocalBoolToMap(behaviac::string stringKey, bool content)
- {
- ///<<< BEGIN WRITING YOUR CODE addFunLocalBoolToMap
- _funLocalBoolMap[stringKey] = content;
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::addFunLocalStringToMap(behaviac::string stringKey, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE addFunLocalStringToMap
- _funLocalStringMap[stringKey] = content;
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::clearFunLocalMap()
- {
- ///<<< BEGIN WRITING YOUR CODE clearFunLocalMap
- _funLocalBoolMap.clear();
- _funLocalStringMap.clear();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::customFunc(behaviac::string blockId, behaviac::string funName)
- {
- ///<<< BEGIN WRITING YOUR CODE customFunc
- onTreeStepStart(blockId, "customFunc");
- _canUpdateBySubTree = false;
- auto waiter = redream::SubTreeWaiter::create(_reboltRedManager, this, _funLocalBoolMap, _funLocalStringMap, funName, _reboltRedManager);
- setWaitableStateBase(waiter);
- waiter->run();
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::findSubString(behaviac::string stringKey1, behaviac::string stringKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE findSubString
- std::string string1 = getLocalTreeString(stringKey1);
- std::string string2 = getLocalTreeString(stringKey2);
- if(string1.find(string2) == std::string::npos){
- return false;
- } else {
- return true;
- }
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::floatFormat(float number, int format)
- {
- ///<<< BEGIN WRITING YOUR CODE floatFormat
- std::string numberStr = to_string(number);
- std::string::size_type position = numberStr.find(".");
- std::string ret;
- int buwei = 0;
- if ( position != std::string::npos ){
- if (format == 0) {
- ret = numberStr.substr(0, position);
- } else {
- int decimalLenovo = (int)(numberStr.size() - (position + 1));
- if(decimalLenovo >= format){
- ret = numberStr.substr(0, position + format + 1);
- } else {
- ret = numberStr;
- buwei = format - decimalLenovo;
- }
- }
- } else {
- //没找到.
- if (format == 0) {
- ret = numberStr;
- } else {
- ret = numberStr + ".";
- buwei = format;
- }
- }
- if (buwei > 0){
- string bu(buwei,'0');
- ret = ret + bu;
- }
- // CCLOG("floatFormat [%f] [%d] [%s]", number, format, ret.c_str());
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::floatToString(float num)
- {
- ///<<< BEGIN WRITING YOUR CODE floatToString
- return to_string(num);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::getCoderFloat(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getCoderFloat
- ReboltErrorInfo errorInfo;
- float ret = _reboltRedManager->getCoderFloat(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::getCoderString(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getCoderString
- ReboltErrorInfo errorInfo;
- behaviac::string ret = _reboltRedManager->getCoderString(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::getCustomFloat(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getCustomFloat
- ReboltErrorInfo errorInfo;
- float ret = _reboltRedManager->getCustomFloat(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::getCustomString(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getCustomString
- ReboltErrorInfo errorInfo;
- behaviac::string ret = _reboltRedManager->getCustomString(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::getFunBoolVar(behaviac::string funcVarKey)
- {
- ///<<< BEGIN WRITING YOUR CODE getFunBoolVar
- auto it = _argumentsBoolMap.find(funcVarKey);
- if(it != _argumentsBoolMap.end()){
- return it->second;
- } else {
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("Bool函数参数[%s]没有被储存", funcVarKey.c_str());
- processError("", errorInfo);
- return false;
- }
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::getFunStringVar(behaviac::string funcVarKey)
- {
- ///<<< BEGIN WRITING YOUR CODE getFunStringVar
- auto it = _argumentsStringMap.find(funcVarKey);
- if(it != _argumentsStringMap.end()){
- return it->second;
- }else {
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("字符串函数参数[%s]没有被储存", funcVarKey.c_str());
- processError("", errorInfo);
- return "";
- }
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::getGlobalFloat(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getGlobalFloat
- ReboltErrorInfo errorInfo;
- float ret = _reboltRedManager->getGlobalFloat(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::getGlobalString(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getGlobalString
- ReboltErrorInfo errorInfo;
- behaviac::string ret = _reboltRedManager->getGlobalString(key, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getInterstitialAdsState(behaviac::string adName)
- {
- ///<<< BEGIN WRITING YOUR CODE getInterstitialAdsState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::getLocalTreeFloat(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getLocalTreeFloat
- auto it = _localTreeFloatMap.find(key);
- if(it != _localTreeFloatMap.end()){
- return it->second;
- } else {
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("数字临时变量[%s]没有被储存", key.c_str());
- processError("", errorInfo);
- return 0.0;
- }
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::getLocalTreeString(behaviac::string dataKey)
- {
- ///<<< BEGIN WRITING YOUR CODE getLocalTreeString
- auto it = _localTreeStringMap.find(dataKey);
- if(it != _localTreeStringMap.end()){
- return it->second;
- } else {
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("字符串临时变量[%s]没有被储存", dataKey.c_str());
- processError("", errorInfo);
- return "";
- }
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getLoopState(behaviac::string blockId)
- {
- ///<<< BEGIN WRITING YOUR CODE getLoopState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::getLoopTimes()
- {
- ///<<< BEGIN WRITING YOUR CODE getLoopTimes
- return _reboltLoopManager->getLoopTimes();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getNodeAnimState(behaviac::string nodeId, behaviac::string animPath)
- {
- ///<<< BEGIN WRITING YOUR CODE getNodeAnimState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getNotifyDevelopmentState(behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE getNotifyDevelopmentState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getRewardVideoAdsState(behaviac::string adName)
- {
- ///<<< BEGIN WRITING YOUR CODE getRewardVideoAdsState
- behaviac::EBTStatus result = (behaviac::EBTStatus)(_waitableStateBase->getRunningState().btState);
- if (result == behaviac::EBTStatus::BT_SUCCESS) {
- if ((redream::RewardedAdResult)(_waitableStateBase->getRunningState().customState) == redream::RewardedAdResult::GotReward) {
- videoIsSuccess = true;
- } else {
- videoIsSuccess = false;
- }
- setWaitableStateBase(nullptr);
- }
- return result;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getSubredTimeLineState(behaviac::string redPath, behaviac::string timeLineId)
- {
- ///<<< BEGIN WRITING YOUR CODE getSubredTimeLineState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getSubRedTreeState(behaviac::string redPath)
- {
- ///<<< BEGIN WRITING YOUR CODE getSubRedTreeState
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getTimeLineState(behaviac::string timeLineId)
- {
- ///<<< BEGIN WRITING YOUR CODE getTimeLineState
- onTreeStepStart("", "getTimeLineState");
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::EBTStatus RedBehaviacTree::getTreeState()
- {
- ///<<< BEGIN WRITING YOUR CODE getTreeState
- onTreeStepStart("", "getTreeState");
- return getWaitableState();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::globalListVarAdd(behaviac::string blockId, behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarAdd
- onTreeStepStart(blockId, "globalListVarAdd");
- _reboltRedManager->listVarAdd(dataName, content);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::globalListVarCount(behaviac::string dataName)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarCount
- return _reboltRedManager->listVarCount(dataName);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::globalListVarDeleteAll(behaviac::string blockId, behaviac::string dataName)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarDeleteAll
- onTreeStepStart(blockId, "globalListVarDeleteAll");
- _reboltRedManager->listVarDeleteAll(dataName);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::globalListVarDeleteOne(behaviac::string blockId, behaviac::string dataName, int index)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarDeleteOne
- onTreeStepStart(blockId, "globalListVarDeleteOne");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->listVarDeleteOne(dataName, index, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::globalListVarFindValueID(behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarFindValueID
- ReboltErrorInfo errorInfo;
- int ret = _reboltRedManager->listVarFindValueID(dataName, content, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::globalListVarHasValue(behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarHasValue
- return _reboltRedManager->listVarHasValue(dataName, content);
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::globalListVarIndexValue(behaviac::string dataName, int index)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarIndexValue
- ReboltErrorInfo errorInfo;
- std::string ret = _reboltRedManager->listVarIndexValue(dataName, index, errorInfo);
- processError("", errorInfo);
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::globalListVarInsertBefore(behaviac::string blockId, behaviac::string dataName, int index, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarInsertBefore
- onTreeStepStart(blockId, "globalListVarInsertBefore");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->listVarInsertBefore(dataName, index, content, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::globalListVarReplace(behaviac::string blockId, behaviac::string dataName, int index, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE globalListVarReplace
- onTreeStepStart(blockId, "globalListVarReplace");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->listVarReplace(dataName, index, content, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::hiddenNode(behaviac::string blockId, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE hiddenNode
- onTreeStepStart(blockId, "hiddenNode");
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if(node != nullptr){
- node->setVisible(false);
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::hiddenRedNode(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE hiddenRedNode
- onTreeStepStart(blockId, "hiddenRedNode");
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- if(node != nullptr){
- node->setVisible(false);
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::hiddenSelf(behaviac::string blockId)
- {
- ///<<< BEGIN WRITING YOUR CODE hiddenSelf
- onTreeStepStart(blockId, "hiddenSelf");
- _reboltRedManager->getRootNode()->setVisible(false);
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::isHiddenNode(behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE isHiddenNode
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return !node->isVisible();
- } else {
- return false;
- }
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::isHiddenRedNode(behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE isHiddenRedNode
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return !node->isVisible();
- } else {
- return false;
- }
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::messageSend(behaviac::string blockId, behaviac::string messageName, behaviac::string messageValue)
- {
- ///<<< BEGIN WRITING YOUR CODE messageSend
- onTreeStepStart(blockId, "messageSend");
- string messValue = getLocalTreeString(messageValue);
- _reboltRedManager->messageSend(messageName, messValue);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::nodeGetGlobalPosX(behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeGetGlobalPosX
- ReboltErrorInfo errorInfo;
- float posX = _reboltRedManager->getNodeGlobalPostionX(nodeId, errorInfo);
- processError("", errorInfo);
- return posX;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::nodeGetGlobalPosY(behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeGetGlobalPosY
- ReboltErrorInfo errorInfo;
- float posY = _reboltRedManager->getNodeGlobalPostionY(nodeId, errorInfo);
- processError("", errorInfo);
- return posY;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::nodeGetPosX(behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeGetPosX
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return node->getPositionX();
- } else {
- return 0;
- }
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::nodeGetPosY(behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeGetPosY
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return node->getPositionY();
- } else {
- return 0;
- }
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::nodeSetAnimAction(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeSetAnimAction
- onTreeStepStart(blockId, "nodeSetAnimAction");
- ReboltErrorInfo errorInfo;
- cocos2d::Vec2 startPos = Vec2(getLocalTreeFloat(posXKey), getLocalTreeFloat(posYKey));
- cocos2d::Vec2 endPos = Vec2(getLocalTreeFloat(posXKey2), getLocalTreeFloat(posYKey2));
- _reboltRedManager->nodeSetAnimAction(nodeId, animPath, startPos, endPos, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::nodeSetAnimActionWithCallBack(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string callbacktreeId, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeSetAnimActionWithCallBack
- onTreeStepStart(blockId, "nodeSetAnimActionWithCallBack");
- ReboltErrorInfo errorInfo;
- cocos2d::Vec2 startPos = Vec2(getLocalTreeFloat(posXKey), getLocalTreeFloat(posYKey));
- cocos2d::Vec2 endPos = Vec2(getLocalTreeFloat(posXKey2), getLocalTreeFloat(posYKey2));
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- redream::NodeAnimAsyncWaiter* waiter = redream::NodeAnimAsyncWaiter::create(_reboltRedManager, this, callbacktreeId, node, animPath, startPos, endPos);
- waiter->addToContainer(_reboltRedManager);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::nodeSetAnimWaitAction(behaviac::string blockId, behaviac::string nodeId, behaviac::string animPath, behaviac::string posXKey, behaviac::string posYKey, behaviac::string posXKey2, behaviac::string posYKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeSetAnimWaitAction
- onTreeStepStart(blockId, "nodeSetAnimWaitAction");
- _canUpdateBySubTree = false;
- ReboltErrorInfo errorInfo;
- cocos2d::Vec2 startPos = Vec2(getLocalTreeFloat(posXKey), getLocalTreeFloat(posYKey));
- cocos2d::Vec2 endPos = Vec2(getLocalTreeFloat(posXKey2), getLocalTreeFloat(posYKey2));
- std::string key = _reboltRedManager->getAnimFileKey(nodeId, animPath);
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if (node) {
- redream::NodeAnimWaiter* waiter = redream::NodeAnimWaiter::create(_reboltRedManager, this, node, animPath, startPos, endPos);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::nodeSetPos(behaviac::string blockId, behaviac::string nodeId, behaviac::string posXKey, behaviac::string posYKey)
- {
- ///<<< BEGIN WRITING YOUR CODE nodeSetPos
- onTreeStepStart(blockId, "nodeSetPos");
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if(node != nullptr){
- node->setPosition(getLocalTreeFloat(posXKey), getLocalTreeFloat(posYKey));
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopment(behaviac::string blockId, behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopment
- onTreeStepStart(blockId, "notifyDevelopment");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- ReboltErrorInfo errorInfo;
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, "", false, nullptr);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWait(behaviac::string blockId, behaviac::string key)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWait
- onTreeStepStart(blockId, "notifyDevelopmentWait");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- ReboltErrorInfo errorInfo;
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, "", true, nullptr);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParam(behaviac::string blockId, behaviac::string key, behaviac::string paramKey)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParam
- onTreeStepStart(blockId, "notifyDevelopmentWithParam");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, false, nullptr);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParamAndNode(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParamAndNode
- onTreeStepStart(blockId, "notifyDevelopmentWithParamAndNode");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, false, node);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParamAndNodeWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParamAndNodeWait
- onTreeStepStart(blockId, "notifyDevelopmentWithParamAndNodeWait");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, true, node);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParamAndSubredNode(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParamAndSubredNode
- onTreeStepStart(blockId, "notifyDevelopmentWithParamAndSubredNode");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- auto redManger = _reboltRedManager->getReboltRedManagerByPath(redPath, errorInfo);
- Node* node = nullptr;
- if(redManger){
- node = redManger->getNodeByKey(nodeId, errorInfo);
- }
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, false, node);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParamAndSubredNodeWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey, behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParamAndSubredNodeWait
- onTreeStepStart(blockId, "notifyDevelopmentWithParamAndSubredNodeWait");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- auto redManger = _reboltRedManager->getReboltRedManagerByPath(redPath, errorInfo);
- Node* node = nullptr;
- if(redManger){
- node = redManger->getNodeByKey(nodeId, errorInfo);
- }
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, true, node);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::notifyDevelopmentWithParamWait(behaviac::string blockId, behaviac::string key, behaviac::string paramKey)
- {
- ///<<< BEGIN WRITING YOUR CODE notifyDevelopmentWithParamWait
- onTreeStepStart(blockId, "notifyDevelopmentWithParamWait");
- _canUpdateBySubTree = false;
- std::string notify = getLocalTreeString(key);
- std::string param = getLocalTreeString(paramKey);
- ReboltErrorInfo errorInfo;
- redream::NotifyDevelopmentWaiter* waiter = redream::NotifyDevelopmentWaiter::create(_reboltRedManager, this, notify, param, true, nullptr);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::numberOperator(behaviac::string floatKey1, int type)
- {
- ///<<< BEGIN WRITING YOUR CODE numberOperator
- float f = getLocalTreeFloat(floatKey1);
- switch (type) {
- case NumOperatorType::NOT_abs:
- return fabs(f);
- case NumOperatorType::NOT_floor:
- return floor(f);
- case NumOperatorType::NOT_ceil:
- return ceil(f);
- case NumOperatorType::NOT_sqrt:
- return sqrt(f);
- case NumOperatorType::NOT_sin:
- return sin(f);
- case NumOperatorType::NOT_cos:
- return cos(f);
- case NumOperatorType::NOT_tan:
- return tan(f);
- case NumOperatorType::NOT_asin:
- return asin(f);
- case NumOperatorType::NOT_acos:
- return acos(f);
- case NumOperatorType::NOT_atan:
- return atan(f);
- case NumOperatorType::NOT_ln:
- return log(f);
- case NumOperatorType::NOT_log10:
- return log10(f);
- case NumOperatorType::NOT_exp:
- return exp(f);
- case NumOperatorType::NOT_pow10:
- return pow(10, f);
- default:
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("数学处理类型[%d],我不认识", type);
- processError("", errorInfo);
- break;
- }
- return 0.0f;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::numModOperator(behaviac::string floatKey1, behaviac::string floatKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE numModOperator
- float f2 = getLocalTreeFloat(floatKey2); //被除数
- if(f2 == 0){
- ReboltErrorInfo errorInfo;
- errorInfo.errorType = ReboltErrorTypeWarn;
- errorInfo.errorDes = StringUtils::format("被除数不能是0,亲");
- processError("", errorInfo);
- return 0.0f;
- }
- float f1 = getLocalTreeFloat(floatKey1); // 除数
- return fmod(f1, f2);
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::numRandOperator(behaviac::string floatKey1)
- {
- ///<<< BEGIN WRITING YOUR CODE numRandOperator
- // 四舍五入取整
- float f1 = getLocalTreeFloat(floatKey1);
- int ret = int(f1 + 0.5);
- return to_string(ret);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::onLoopEnd()
- {
- ///<<< BEGIN WRITING YOUR CODE onLoopEnd
- _reboltLoopManager->onLoopEnd();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playSubredTimeLine(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName)
- {
- ///<<< BEGIN WRITING YOUR CODE playSubredTimeLine
- onTreeStepStart(blockId, "playSubredTimeLine");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->playSubredTimeLine(redPath, actionName, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playSubredTimeLineWait(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName)
- {
- ///<<< BEGIN WRITING YOUR CODE playSubredTimeLineWait
- onTreeStepStart(blockId, "playSubredTimeLineWait");
- _canUpdateBySubTree = false;
- redream::PlayTimelineWaiter* waiter = redream::PlayTimelineWaiter::create(_reboltRedManager, this, std::stoi(actionName), _reboltRedManager->getSubREDAnimationManager(redPath));
- setWaitableStateBase(waiter);
- waiter->run();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playSubredTimeLineWithCallBack(behaviac::string blockId, behaviac::string redPath, behaviac::string actionName, behaviac::string callbacktreeId)
- {
- ///<<< BEGIN WRITING YOUR CODE playSubredTimeLineWithCallBack
- onTreeStepStart(blockId, "playSubredTimeLineWithCallBack");
- ReboltErrorInfo errorInfo;
- redream::PlayTimeLineAsyncWaiter* waiter = redream::PlayTimeLineAsyncWaiter::create(_reboltRedManager, this, callbacktreeId, std::stoi(actionName), _reboltRedManager->getSubREDAnimationManager(redPath));
- waiter->addToContainer(_reboltRedManager);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playTimeLine(behaviac::string blockId, behaviac::string actionName)
- {
- ///<<< BEGIN WRITING YOUR CODE playTimeLine
- onTreeStepStart(blockId, "playTimeLine");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->playTimeLine(actionName, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playTimeLineWait(behaviac::string blockId, behaviac::string actionName)
- {
- ///<<< BEGIN WRITING YOUR CODE playTimeLineWait
- onTreeStepStart(blockId, "playTimeLineWait");
- _canUpdateBySubTree = false;
- redream::PlayTimelineWaiter* waiter = redream::PlayTimelineWaiter::create(_reboltRedManager, this, std::stoi(actionName), _reboltRedManager->getREDAnimationManager());
- setWaitableStateBase(waiter);
- waiter->run();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playTimeLineWithCallBack(behaviac::string blockId, behaviac::string actionName, behaviac::string callbacktreeId)
- {
- ///<<< BEGIN WRITING YOUR CODE playTimeLineWithCallBack
- onTreeStepStart(blockId, "playTimeLineWithCallBack");
- ReboltErrorInfo errorInfo;
- redream::PlayTimeLineAsyncWaiter* waiter = redream::PlayTimeLineAsyncWaiter::create(_reboltRedManager, this, callbacktreeId, std::stoi(actionName), _reboltRedManager->getREDAnimationManager());
- waiter->addToContainer(_reboltRedManager);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::playWiseSound(behaviac::string blockId, behaviac::string bnkPathKey, behaviac::string eventNameKey)
- {
- ///<<< BEGIN WRITING YOUR CODE playWiseSound
- onTreeStepStart(blockId, "playWiseSound");
- std::string bnkPath = getLocalTreeString(bnkPathKey);
- std::string eventName = getLocalTreeString(eventNameKey);
- ReboltErrorInfo errorInfo;
- _reboltRedManager->playWiseSound(bnkPath, eventName, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::randOperator(behaviac::string floatKey1, behaviac::string floatKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE randOperator
- // 随机数
- float min = getLocalTreeFloat(floatKey1);
- float max = getLocalTreeFloat(floatKey2);
- if(min > max){
- float local = min;
- min = max;
- max = local;
- }
- float ret = min + ((1.0 * rand() / RAND_MAX)* (max - min));
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::redCustomFunc(behaviac::string blockId, behaviac::string redPath, behaviac::string funName)
- {
- ///<<< BEGIN WRITING YOUR CODE redCustomFunc
- onTreeStepStart(blockId, "redCustomFunc");
- _canUpdateBySubTree = false;
- ReboltErrorInfo errorInfo;
- auto waiter = redream::SubTreeWaiter::create(_reboltRedManager, this, _funLocalBoolMap, _funLocalStringMap, funName, _reboltRedManager->getReboltRedManagerByPath(redPath, errorInfo));
- processError(blockId, errorInfo);
- setWaitableStateBase(waiter);
- waiter->run();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::redProgressBar(behaviac::string blockId, behaviac::string barName, float number)
- {
- ///<<< BEGIN WRITING YOUR CODE redProgressBar
- onTreeStepStart(blockId, "redProgressBar");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->redProgressBar(barName, number, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::rewardVideoIsLoad(behaviac::string adName)
- {
- ///<<< BEGIN WRITING YOUR CODE rewardVideoIsLoad
- return _reboltRedManager->rewardVideoIsLoad(adName);
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::sceneNodeGetGlobalPosX(behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneNodeGetGlobalPosX
- ReboltErrorInfo errorInfo;
- float posX = _reboltRedManager->getSubredNodeGlobalPostionX(redPath, nodeId, errorInfo);
- processError("", errorInfo);
- return posX;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::sceneNodeGetGlobalPosY(behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneNodeGetGlobalPosY
- ReboltErrorInfo errorInfo;
- float posY = _reboltRedManager->getSubredNodeGlobalPostionY(redPath, nodeId, errorInfo);
- processError("", errorInfo);
- return posY;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::sceneNodeGetPosX(behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneNodeGetPosX
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return node->getPositionX();
- } else {
- return 0;
- }
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::sceneNodeGetPosY(behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneNodeGetPosY
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- processError("", errorInfo);
- if(node != nullptr){
- return node->getPositionY();
- } else {
- return 0;
- }
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::sceneNodeSetPos(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string posXKey, behaviac::string posYKey)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneNodeSetPos
- onTreeStepStart(blockId, "sceneNodeSetPos");
- ReboltErrorInfo errorInfo;
- cocos2d::Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- if(node != nullptr){
- node->setPosition(getLocalTreeFloat(posXKey), getLocalTreeFloat(posYKey));
- }
- processError("", errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::sceneProgressBar(behaviac::string blockId, behaviac::string redPath, behaviac::string barName, float number)
- {
- ///<<< BEGIN WRITING YOUR CODE sceneProgressBar
- onTreeStepStart(blockId, "sceneProgressBar");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->subredProgressBar(redPath, barName, number, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setButtonEnable(behaviac::string blockId, behaviac::string nodeId, bool isEnable)
- {
- ///<<< BEGIN WRITING YOUR CODE setButtonEnable
- onTreeStepStart(blockId, "setButtonEnable");
- ReboltErrorInfo errorInfo;
- auto button = _reboltRedManager->getControlByKey(nodeId, errorInfo);
- if(button) button->setEnabled(isEnable);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setCoderDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE setCoderDataVar
- onTreeStepStart(blockId, "setCoderDataVar");
- _reboltRedManager->setCoderDataVar(dataName, content);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setCustomDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE setCustomDataVar
- onTreeStepStart(blockId, "setCustomDataVar");
- _reboltRedManager->setCustomDataVar(dataName, content);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setGlobalDataVar(behaviac::string blockId, behaviac::string dataName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE setGlobalDataVar
- onTreeStepStart(blockId, "setGlobalDataVar");
- _reboltRedManager->setGlobalDataVar(dataName, content);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setLabelTitle(behaviac::string blockId, behaviac::string labelName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE setLabelTitle
- onTreeStepStart(blockId, "setLabelTitle");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->setLabelTitle(labelName, content, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setNodeRotation(behaviac::string blockId, behaviac::string nodeId, float rotation)
- {
- ///<<< BEGIN WRITING YOUR CODE setNodeRotation
- onTreeStepStart(blockId, "setNodeRotation");
- ReboltErrorInfo errorInfo;
- auto node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if(node) node->setRotation(rotation);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setNodeScale(behaviac::string blockId, behaviac::string nodeId, behaviac::string scaleXKey, behaviac::string scaleYKey)
- {
- ///<<< BEGIN WRITING YOUR CODE setNodeScale
- onTreeStepStart(blockId, "setNodeScale");
- ReboltErrorInfo errorInfo;
- auto node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if(node) node->setScale(getLocalTreeFloat(scaleXKey), getLocalTreeFloat(scaleYKey));
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSceneLabelTitle(behaviac::string blockId, behaviac::string redPath, behaviac::string labelName, behaviac::string content)
- {
- ///<<< BEGIN WRITING YOUR CODE setSceneLabelTitle
- onTreeStepStart(blockId, "setSceneLabelTitle");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->setSubredLabelTitle(redPath, labelName, content, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSpriteImage(behaviac::string blockId, behaviac::string nodeId, behaviac::string imagePath)
- {
- ///<<< BEGIN WRITING YOUR CODE setSpriteImage
- onTreeStepStart(blockId, "setSpriteImage");
- ReboltErrorInfo errorInfo;
- std::string image = getLocalTreeString(imagePath);
- _reboltRedManager->setSpriteImage(nodeId, image, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSpritePlist(behaviac::string blockId, behaviac::string nodeId, behaviac::string plistPath, behaviac::string frameName)
- {
- ///<<< BEGIN WRITING YOUR CODE setSpritePlist
- onTreeStepStart(blockId, "setSpritePlist");
- ReboltErrorInfo errorInfo;
- std::string plist = getLocalTreeString(plistPath);
- std::string frame = getLocalTreeString(frameName);
- _reboltRedManager->setSpritePlist(nodeId, plist, frame, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSubredButtonEnable(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, bool isEnable)
- {
- ///<<< BEGIN WRITING YOUR CODE setSubredButtonEnable
- onTreeStepStart(blockId, "setSubredButtonEnable");
- ReboltErrorInfo errorInfo;
- auto button = _reboltRedManager->getSubredControlByKey(redPath, nodeId, errorInfo);
- if(button) button->setEnabled(isEnable);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSubredNodeRotation(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, float rotation)
- {
- ///<<< BEGIN WRITING YOUR CODE setSubredNodeRotation
- onTreeStepStart(blockId, "setSubredNodeRotation");
- ReboltErrorInfo errorInfo;
- auto node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- if(node) node->setRotation(rotation);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSubredNodeScale(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string scaleXKey, behaviac::string scaleYKey)
- {
- ///<<< BEGIN WRITING YOUR CODE setSubredNodeScale
- onTreeStepStart(blockId, "setSubredNodeRotation");
- ReboltErrorInfo errorInfo;
- auto node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- if(node) node->setScale(getLocalTreeFloat(scaleXKey), getLocalTreeFloat(scaleYKey));
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSubredSpriteImage(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string imagePath)
- {
- ///<<< BEGIN WRITING YOUR CODE setSubredSpriteImage
- onTreeStepStart(blockId, "setSubredSpriteImage");
- ReboltErrorInfo errorInfo;
- std::string image = getLocalTreeString(imagePath);
- _reboltRedManager->setSubredSpriteImage(redPath, nodeId, image, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::setSubredSpritePlist(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId, behaviac::string plistPath, behaviac::string frameName)
- {
- ///<<< BEGIN WRITING YOUR CODE setSubredSpritePlist
- onTreeStepStart(blockId, "setSubredSpritePlist");
- ReboltErrorInfo errorInfo;
- std::string plist = getLocalTreeString(plistPath);
- std::string frame = getLocalTreeString(frameName);
- _reboltRedManager->setSubredSpritePlist(redPath, nodeId, plist, frame, errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::showInterstitialAds(behaviac::string blockId, behaviac::string adName)
- {
- ///<<< BEGIN WRITING YOUR CODE showInterstitialAds
- onTreeStepStart(blockId, "showInterstitialAds");
- _canUpdateBySubTree = false;
- ReboltErrorInfo errorInfo;
- redream::InterstitialAdWaiter* waiter = redream::InterstitialAdWaiter::create(_reboltRedManager, this, adName);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::showNode(behaviac::string blockId, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE showNode
- onTreeStepStart(blockId, "showNode");
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getNodeByKey(nodeId, errorInfo);
- if(node != nullptr){
- node->setVisible(true);
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::showRedNode(behaviac::string blockId, behaviac::string redPath, behaviac::string nodeId)
- {
- ///<<< BEGIN WRITING YOUR CODE showRedNode
- onTreeStepStart(blockId, "showRedNode");
- ReboltErrorInfo errorInfo;
- Node* node = _reboltRedManager->getSubredNodeByKey(redPath, nodeId, errorInfo);
- if(node != nullptr){
- node->setVisible(true);
- }
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::showRewardVideoAds(behaviac::string blockId, behaviac::string adName)
- {
- ///<<< BEGIN WRITING YOUR CODE showRewardVideoAds
- onTreeStepStart(blockId, "showRewardVideoAds");
- _canUpdateBySubTree = false;
- ReboltErrorInfo errorInfo;
- redream::RewardedAdWaiter* waiter = redream::RewardedAdWaiter::create(_reboltRedManager, this, adName);
- setWaitableStateBase(waiter);
- waiter->run(errorInfo);
- processError(blockId, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::showSelf(behaviac::string blockId)
- {
- ///<<< BEGIN WRITING YOUR CODE showSelf
- onTreeStepStart(blockId, "showSelf");
- _reboltRedManager->getRootNode()->setVisible(true);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::startLoop(behaviac::string blockId)
- {
- ///<<< BEGIN WRITING YOUR CODE startLoop
- onTreeStepStart(blockId, "startLoop");
- _canUpdateBySubTree = false;
- redream::LoopWaiter* rlm = redream::LoopWaiter::create(_reboltRedManager, this, _funLocalBoolMap, _funLocalStringMap, blockId);
- setWaitableStateBase(rlm);
- rlm->run();
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::stopSubredTimeLine(behaviac::string blockId, behaviac::string redPath)
- {
- ///<<< BEGIN WRITING YOUR CODE stopSubredTimeLine
- onTreeStepStart(blockId, "stopSubredTimeLine");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->stopSubredTimeLine(redPath, errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::stopTimeLine(behaviac::string blockId)
- {
- ///<<< BEGIN WRITING YOUR CODE stopTimeLine
- onTreeStepStart(blockId, "stopTimeLine");
- ReboltErrorInfo errorInfo;
- _reboltRedManager->stopTimeLine(errorInfo);
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::storageTemporaryVariables(behaviac::string keyVariables, float number)
- {
- ///<<< BEGIN WRITING YOUR CODE storageTemporaryVariables
- _localTreeFloatMap[keyVariables] = number;
- ///<<< END WRITING YOUR CODE
- }
- void RedBehaviacTree::storageTemporaryVariablesString(behaviac::string dataKey, behaviac::string v)
- {
- ///<<< BEGIN WRITING YOUR CODE storageTemporaryVariablesString
- _localTreeStringMap[dataKey] = v;
- ///<<< END WRITING YOUR CODE
- }
- bool RedBehaviacTree::stringEqual(behaviac::string stringKey1, behaviac::string stringKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE stringEqual
- std::string string1 = getLocalTreeString(stringKey1);
- std::string string2 = getLocalTreeString(stringKey2);
- if(string1 == string2){
- return true;
- } else {
- return false;
- }
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::stringLen(behaviac::string stringKey1)
- {
- ///<<< BEGIN WRITING YOUR CODE stringLen
- std::string string1 = getLocalTreeString(stringKey1);
- return string1.size();
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::stringLink(behaviac::string stringKey1, behaviac::string stringKey2)
- {
- ///<<< BEGIN WRITING YOUR CODE stringLink
- std::string string1 = getLocalTreeString(stringKey1);
- std::string string2 = getLocalTreeString(stringKey2);
- return string1 + string2;
- ///<<< END WRITING YOUR CODE
- }
- behaviac::string RedBehaviacTree::stringLinkMoreOperator(behaviac::string stringKeyA, behaviac::string stringKeyB, behaviac::string stringKeyC, behaviac::string stringKeyD, behaviac::string stringKeyE)
- {
- ///<<< BEGIN WRITING YOUR CODE stringLinkMoreOperator
- std::string stringA = getLocalTreeString(stringKeyA);
- std::string stringB = getLocalTreeString(stringKeyB);
- std::string stringC = getLocalTreeString(stringKeyC);
- std::string stringD = getLocalTreeString(stringKeyD);
- std::string stringE = getLocalTreeString(stringKeyE);
- return stringA + stringB + stringC + stringD + stringE;
- ///<<< END WRITING YOUR CODE
- }
- float RedBehaviacTree::stringToFloat(behaviac::string str)
- {
- ///<<< BEGIN WRITING YOUR CODE stringToFloat
- float ret;
- try {
- ret = std::stof(str);
- } catch (std::invalid_argument) {
- ret = 0;
- } catch (std::out_of_range){
- ret = 0;
- }
- return ret;
- ///<<< END WRITING YOUR CODE
- }
- ///<<< BEGIN WRITING YOUR CODE NAMESPACE_UNINIT
- void RedBehaviacTree::onTreeStepStart(std::string blockId, std::string blockName){
- // CCLOG("zml RedBehaviacTree treeId :%s blockId %s, blockName: %s",_treeName.c_str(), blockId.c_str(), blockName.c_str());
- if(_reboltRunDelegate != nullptr){
- _reboltRunDelegate->onTreeStepStart(_treeName, blockId);
- }
- }
- void RedBehaviacTree::processError(std::string blockId, ReboltErrorInfo& errorInfo){
- if(_reboltRunDelegate != nullptr){
- if(errorInfo.errorType != ReboltErrorTypeNone){
- json11::Json errorJson = json11::Json::object{
- { "treeName", _treeName},
- { "blockId", blockId},
- { "errorType", (int)errorInfo.errorType},
- { "errorDes", errorInfo.errorDes}
- };
- std::string jsonStr = errorJson.dump();
- _reboltRunDelegate->onError(jsonStr);
- }
- } else{
- switch (errorInfo.errorType) {
- case ReboltErrorTypeWarn:
- CCLOG("Treename [%s] blockId [%s] error info: %s", _treeName.c_str(), blockId.c_str(), errorInfo.errorDes.c_str());
- break;
- case ReboltErrorTypeError:
- CCLOG("Treename [%s] blockId [%s] error info: %s", _treeName.c_str(), blockId.c_str(), errorInfo.errorDes.c_str());
- CCASSERT(false, "");
- break;
- default:
- break;
- }
- }
- }
- void RedBehaviacTree::runBehaviacTree(){
- if(_reboltRunDelegate != nullptr){
- _reboltRunDelegate->onTreePlayStart(_treeName);
- }
- // CCLOG("RedBehaviacTree runBehaviacTree %s", _treeName.c_str());
- _isRunning = true;
- update();
- }
- void RedBehaviacTree::updateBySubTree(){
- if(_canUpdateBySubTree){
- update();
- }
- }
- void RedBehaviacTree::update(){
- if(_isRunning){
- behaviac::EBTStatus status = btexec();
- // CCLOG("RedBehaviacTree tree: %s status %d", _treeName.c_str(), (int)status);
- if(status != behaviac::EBTStatus::BT_RUNNING){
- if(_reboltRunDelegate != nullptr){
- _reboltRunDelegate->onTreePlayFinished(_treeName, status);
- }
- _isRunning = false;
- _reboltRedManager->onTreeRunEnd(status, _treeName);
- for(int i = 0; i < _delegateVer.size(); i++){
- RedBehaviacTreeDelegate* del = _delegateVer[i];
- del->onTreeRunningEnd(this, status, _treeName);
- }
- }
- }
- }
- void RedBehaviacTree::setWaitableStateBase(redream::WaitableStateBase* wsb) {
- CC_SAFE_RELEASE_NULL(_waitableStateBase);
- _waitableStateBase = wsb;
- CC_SAFE_RETAIN(wsb);
- }
- behaviac::EBTStatus RedBehaviacTree::getWaitableState(){
- behaviac::EBTStatus result = (behaviac::EBTStatus)(_waitableStateBase->getRunningState().btState);
- _canUpdateBySubTree = true;
- if (result == behaviac::EBTStatus::BT_SUCCESS) {
- setWaitableStateBase(nullptr);
- }
- return result;
- }
- void RedBehaviacTree::addRedBehaviacTreeDelegate(RedBehaviacTreeDelegate* delegate){
- _delegateVer.push_back(delegate);
- }
- void RedBehaviacTree::removeRedBehaviacTreeDelegate(RedBehaviacTreeDelegate* delegate){
- auto it = std::find(_delegateVer.begin(), _delegateVer.end(), delegate);
- if (it != _delegateVer.end()) {
- _delegateVer.erase(it);
- }
- }
- void RedBehaviacTree::removeAllRedBehaviacTreeDelegate(){
- _delegateVer.clear();
- }
- ///<<< END WRITING YOUR CODE
- }
- ///<<< BEGIN WRITING YOUR CODE FILE_UNINIT
- ///<<< END WRITING YOUR CODE
|