2017-10-26 17:17:30 +08:00
|
|
|
|
#include "..\emanagers.h"
|
2017-10-19 12:48:58 +08:00
|
|
|
|
#include "..\eactions.h"
|
2017-10-19 00:50:04 +08:00
|
|
|
|
|
2017-12-11 18:17:24 +08:00
|
|
|
|
static std::vector<e2d::EAction*> s_vActions;
|
2017-10-19 00:50:04 +08:00
|
|
|
|
|
2017-10-19 12:48:58 +08:00
|
|
|
|
|
2017-10-20 00:59:26 +08:00
|
|
|
|
void e2d::EActionManager::addAction(EAction * action)
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-10-19 12:48:58 +08:00
|
|
|
|
WARN_IF(action == nullptr, "EAction NULL pointer exception!");
|
|
|
|
|
|
|
2017-10-20 00:59:26 +08:00
|
|
|
|
if (action)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
action->start();
|
|
|
|
|
|
action->retain();
|
|
|
|
|
|
s_vActions.push_back(action);
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
void e2d::EActionManager::resumeAllActionsBindedWith(ENode * pTargetNode)
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-10-21 19:09:31 +08:00
|
|
|
|
if (pTargetNode)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
if ((*action)->getTarget() == pTargetNode)
|
2017-10-21 19:09:31 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
(*action)->start();
|
2017-10-21 19:09:31 +08:00
|
|
|
|
}
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
EActionManager::resumeAllActionsBindedWith((*child));
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 19:09:31 +08:00
|
|
|
|
void e2d::EActionManager::pauseAllActionsBindedWith(ENode * pTargetNode)
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-10-19 12:48:58 +08:00
|
|
|
|
if (pTargetNode)
|
|
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
if ((*action)->getTarget() == pTargetNode)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
(*action)->pause();
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
EActionManager::pauseAllActionsBindedWith((*child));
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-19 12:48:58 +08:00
|
|
|
|
void e2d::EActionManager::stopAllActionsBindedWith(ENode * pTargetNode)
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-10-19 12:48:58 +08:00
|
|
|
|
if (pTargetNode)
|
|
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
if ((*action)->getTarget() == pTargetNode)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
(*action)->stop();
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto child = pTargetNode->getChildren().begin(); child != pTargetNode->getChildren().end(); child++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
EActionManager::stopAllActionsBindedWith((*child));
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
void e2d::EActionManager::__clearAllActionsBindedWith(ENode * pTargetNode)
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-10-19 12:48:58 +08:00
|
|
|
|
if (pTargetNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (size_t i = 0; i < s_vActions.size();)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto a = s_vActions[i];
|
|
|
|
|
|
if (a->getTarget() == pTargetNode)
|
|
|
|
|
|
{
|
2017-10-31 17:19:13 +08:00
|
|
|
|
SafeRelease(&a);
|
2017-10-19 12:48:58 +08:00
|
|
|
|
s_vActions.erase(s_vActions.begin() + i);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
void e2d::EActionManager::resumeAllActions()
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++)
|
2017-10-21 19:09:31 +08:00
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
EActionManager::resumeAllActionsBindedWith((*child));
|
2017-10-21 19:09:31 +08:00
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 19:09:31 +08:00
|
|
|
|
void e2d::EActionManager::pauseAllActions()
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++)
|
2017-10-21 19:09:31 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
EActionManager::pauseAllActionsBindedWith((*child));
|
2017-10-21 19:09:31 +08:00
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 19:09:31 +08:00
|
|
|
|
void e2d::EActionManager::stopAllActions()
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2018-01-30 16:45:38 +08:00
|
|
|
|
for (auto child = ESceneManager::getCurrentScene()->getChildren().begin(); child != ESceneManager::getCurrentScene()->getChildren().end(); child++)
|
2017-10-21 19:09:31 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
EActionManager::stopAllActionsBindedWith((*child));
|
2017-10-21 19:09:31 +08:00
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
void e2d::EActionManager::__resetAllActions()
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
for (auto action = s_vActions.begin(); action != s_vActions.end(); action++)
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
2017-12-15 21:51:07 +08:00
|
|
|
|
(*action)->_resetTime();
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-30 16:45:38 +08:00
|
|
|
|
void e2d::EActionManager::__update()
|
2017-10-19 00:50:04 +08:00
|
|
|
|
{
|
2017-12-04 10:03:14 +08:00
|
|
|
|
if (s_vActions.empty())
|
2017-10-19 12:48:58 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
|
|
|
|
|
for (size_t i = 0; i < s_vActions.size(); i++)
|
|
|
|
|
|
{
|
2017-10-21 19:09:31 +08:00
|
|
|
|
auto &action = s_vActions[i];
|
2017-10-19 12:48:58 +08:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
2017-10-20 00:59:26 +08:00
|
|
|
|
if (action->isRunning() ||
|
2018-01-30 16:45:38 +08:00
|
|
|
|
(action->getTarget() && action->getTarget()->getParentScene() == ESceneManager::getCurrentScene()))
|
2017-10-19 12:48:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (action->_isEnding())
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
2017-10-31 17:19:13 +08:00
|
|
|
|
SafeRelease(&action);
|
2017-10-19 12:48:58 +08:00
|
|
|
|
s_vActions.erase(s_vActions.begin() + i);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// ִ<>ж<EFBFBD><D0B6><EFBFBD>
|
2017-12-08 15:37:52 +08:00
|
|
|
|
action->_update();
|
2017-10-19 12:48:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-19 00:50:04 +08:00
|
|
|
|
}
|