1 #include "BattleData.h"
2 #include "mof/KeyFrameAnimation.h"
3 #include "AttackAction.h"
4 #include "SpecialAction.h"
6 #include "BattlerGroup.h"
7 #include "BattlerFacade.h"
9 et::BattleData::BattleData(mof::TextureManager* pTextureManager , et::GameData* pGameData , et::BattlerGroup* pGroup)
11 m_pGameData = pGameData;
12 m_pTextureManager = pTextureManager;
13 m_battleAction.type = BattleAction::NONE;
14 et::BattlerParameter parameter;
16 //m_battlerList.push_back(new Battler(parameter , m_pTextureManager));
19 et::BattleData::~BattleData(void)
27 void et::BattleData::addBattler(et::BattlerFacade* pBattler){
28 m_battlerList.push_back(pBattler);
32 void et::BattleData::layoutBattler(){
37 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
38 if((*itr)->getType() == et::ENEMY)nEnemy++;
39 else if((*itr)->getType() == et::IDEAL)nIdeal++;
44 float zTable[3][3] = { {0.6f , 0.6f , 0.6f} , { 0.8f , 0.4f , 0.6f} , {0.86f , 0.6f , 0.34f} };//[
\91\8d\90\94][
\94Ô
\8d\86]
45 float xTable[3][3] = { {0.0f , 0.0f , 0.0f} , { 0.1f , -0.1f , 0.6f} , {0.15f , 0.0f , -0.15f} };//[
\91\8d\90\94][
\94Ô
\8d\86]
46 float ixTable[3][3] = { {0.2f , 0.0f , 0.0f} , { 0.0f , 0.07f , 0.6f} , {0.0f , 0.1f , 0.15f} };//[
\91\8d\90\94][
\94Ô
\8d\86]
47 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
48 if((*itr)->getType() == et::HERO){
49 (*itr)->setAidlingAnimation(mof::Vector3D(0.3f , 0.0f , 0.6f));
50 (*itr)->setBasePosition(mof::Vector3D(0.3f , 0.0f , 0.6f));
52 else if((*itr)->getType() == et::ENEMY){
53 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
54 (*itr)->setAidlingAnimation(mof::Vector3D(-0.45f + xTable[nEnemy-1][cntEnemy] , 0.0f , zTable[nEnemy-1][cntEnemy]));
55 (*itr)->setBasePosition(mof::Vector3D(-0.45f + xTable[nEnemy-1][cntEnemy] , 0.0f , zTable[nEnemy-1][cntEnemy]));
58 else if((*itr)->getType() == et::IDEAL){
59 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
60 (*itr)->setAidlingAnimation(mof::Vector3D(0.6 +ixTable[nIdeal-1][cntIdeal] , 0.0f , zTable[nIdeal-1][cntIdeal]));
68 et::BattlerFacade* et::BattleData::getHeroBattler(){
69 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
70 if((*itr)->getType() == et::HERO){
78 et::BattlerFacade* et::BattleData::getEnemyBattler(int index){
80 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
81 if((*itr)->getType() == et::ENEMY){
82 if(cntEnemy++ == index)return *itr;
90 et::BattlerFacade* et::BattleData::getIdealBattler(int index){
92 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
93 if((*itr)->getType() == et::IDEAL){
94 if(cntIdeal++ == index)return *itr;
101 et::Action* et::BattleData::createBattlerAction(et::BattlerFacade* pBattler){
102 if(pBattler->getType() == et::HERO){
103 et::BattleAction action = m_battleAction;
104 m_battleAction.type = et::BattleAction::NONE;
105 if(action.type == et::BattleAction::ATTACK_WEAPON){
106 return new AttackAction(pBattler , action.pTarget , 3);
108 else if(action.type == et::BattleAction::WAIT || action.type == et::BattleAction::GUARD){
111 else if(action.type == et::BattleAction::CAST){
112 et::BattlerFacade* pIdeal = getIdealBattler(action.idealIndex);
113 et::BattlerParameter parameter = pIdeal->getParameter();
114 parameter.dActionPoint -= 5;
115 pIdeal->setParameter(parameter);
116 std::list<et::BattlerFacade*> targetList;
117 if(action.pTarget != NULL)targetList.push_back(action.pTarget);
119 for(std::list<et::BattlerFacade*>::const_iterator itr = getBattlerList().begin() ; itr != getBattlerList().end() ; ++itr){
120 if((*itr)->getType() == et::ENEMY && (*itr)->getParameter().alive)targetList.push_back(*itr);
123 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
124 return new SpecialAction(pBattler , targetList , 5 , action.idealIndex);
126 else if(action.type == et::BattleAction::USE_ITEM){
127 //
\83A
\83C
\83e
\83\80\82ð
\82È
\82
\82·
128 std::list<et::ItemData> &refList = getItemList();
129 for(std::list<et::ItemData>::iterator itr = refList.begin() ; itr != refList.end() ; ++itr){
130 if(action.pTargetItem == &(*itr)){
135 std::list<et::BattlerFacade*> targetList;
136 if(action.pTarget != NULL)targetList.push_back(action.pTarget);
138 for(std::list<et::BattlerFacade*>::const_iterator itr = getBattlerList().begin() ; itr != getBattlerList().end() ; ++itr){
139 if((*itr)->getType() == et::ENEMY && (*itr)->getParameter().alive)targetList.push_back(*itr);
142 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
143 return new SpecialAction(pBattler , targetList , 2 , 3);
148 std::list<BattlerFacade*> enemyList;
149 enemyList.push_back(getHeroBattler());
150 std::list<BattlerFacade*> allyList;
151 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
152 if((*itr)->getType() == et::ENEMY && *itr != pBattler)allyList.push_back(*itr);
154 return pBattler->createNextAction(enemyList , allyList);
160 et::BattleAction et::BattleData::pollBattleAction(){
161 BattleAction action = m_battleAction;
162 m_battleAction.type = BattleAction::NONE;
166 bool et::BattleData::isOver(){
167 if(!m_pGroup->getHeroBattler()->getParameter().alive)return true;
168 //et::BattlerFacade* pEnemy = NULL;
169 return m_pGroup->getEnemyBattlerListAlive().size() == 0;
170 /*for(int i = 0 ; (pEnemy = m_pGroup->getEnemyBattlerAt(i)) != NULL ; i++){
171 if(pEnemy->getParameter().alive)return false;
178 std::list<et::ItemData>& et::BattleData::getItemList(){
179 return m_pGameData->getBattleItemList();