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"
10 et::BattleData::BattleData(mof::TextureManager* pTextureManager , et::GameData* pGameData , et::BattlerGroup* pGroup)
12 m_pGameData = pGameData;
13 m_pTextureManager = pTextureManager;
14 m_battleAction.type = BattleAction::NONE;
15 et::BattlerParameter parameter;
17 //m_battlerList.push_back(new Battler(parameter , m_pTextureManager));
20 et::BattleData::~BattleData(void)
28 void et::BattleData::addBattler(et::BattlerFacade* pBattler){
29 m_battlerList.push_back(pBattler);
33 void et::BattleData::layoutBattler(){
38 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
39 if((*itr)->getType() == et::ENEMY)nEnemy++;
40 else if((*itr)->getType() == et::IDEAL)nIdeal++;
45 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]
46 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]
47 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]
48 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
49 if((*itr)->getType() == et::HERO){
50 (*itr)->setAidlingAnimation(mof::Vector3D(0.3f , 0.0f , 0.6f));
51 (*itr)->setBasePosition(mof::Vector3D(0.3f , 0.0f , 0.6f));
53 else if((*itr)->getType() == et::ENEMY){
54 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
55 (*itr)->setAidlingAnimation(mof::Vector3D(-0.45f + xTable[nEnemy-1][cntEnemy] , 0.0f , zTable[nEnemy-1][cntEnemy]));
56 (*itr)->setBasePosition(mof::Vector3D(-0.45f + xTable[nEnemy-1][cntEnemy] , 0.0f , zTable[nEnemy-1][cntEnemy]));
59 else if((*itr)->getType() == et::IDEAL){
60 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
61 (*itr)->setAidlingAnimation(mof::Vector3D(0.6 +ixTable[nIdeal-1][cntIdeal] , 0.0f , zTable[nIdeal-1][cntIdeal]));
69 et::BattlerFacade* et::BattleData::getHeroBattler(){
70 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
71 if((*itr)->getType() == et::HERO){
79 et::BattlerFacade* et::BattleData::getEnemyBattler(int index){
81 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
82 if((*itr)->getType() == et::ENEMY){
83 if(cntEnemy++ == index)return *itr;
91 et::BattlerFacade* et::BattleData::getIdealBattler(int index){
93 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
94 if((*itr)->getType() == et::IDEAL){
95 if(cntIdeal++ == index)return *itr;
102 et::Action* et::BattleData::createBattlerAction(et::BattlerFacade* pBattler){
103 if(pBattler->getType() == et::HERO){
104 et::BattleAction action = m_battleAction;
105 m_battleAction.type = et::BattleAction::NONE;
106 if(action.type == et::BattleAction::ATTACK_WEAPON){
107 return new AttackAction(pBattler , action.pTarget , 3);
109 else if(action.type == et::BattleAction::WAIT || action.type == et::BattleAction::GUARD){
112 else if(action.type == et::BattleAction::CAST){
113 et::BattlerFacade* pIdeal = getIdealBattler(action.idealIndex);
114 et::BattlerParameter parameter = pIdeal->getParameter();
115 parameter.dActionPoint -= 5;
116 pIdeal->setParameter(parameter);
117 std::list<et::BattlerFacade*> targetList;
118 if(action.pTarget != NULL)targetList.push_back(action.pTarget);
120 for(std::list<et::BattlerFacade*>::const_iterator itr = getBattlerList().begin() ; itr != getBattlerList().end() ; ++itr){
121 if((*itr)->getType() == et::ENEMY && (*itr)->getParameter().alive)targetList.push_back(*itr);
124 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
125 return new SpecialAction(pBattler , targetList , 5 , action.idealIndex);
127 else if(action.type == et::BattleAction::USE_ITEM){
128 //
\83A
\83C
\83e
\83\80\82ð
\82È
\82
\82·
129 std::list<et::ItemData> &refList = getItemList();
130 for(std::list<et::ItemData>::iterator itr = refList.begin() ; itr != refList.end() ; ++itr){
131 if(action.pTargetItem == &(*itr)){
136 std::list<et::BattlerFacade*> targetList;
137 if(action.pTarget != NULL)targetList.push_back(action.pTarget);
139 for(std::list<et::BattlerFacade*>::const_iterator itr = getBattlerList().begin() ; itr != getBattlerList().end() ; ++itr){
140 if((*itr)->getType() == et::ENEMY && (*itr)->getParameter().alive)targetList.push_back(*itr);
143 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
144 return new SpecialAction(pBattler , targetList , 2 , 3);
149 std::list<BattlerFacade*> enemyList;
150 enemyList.push_back(getHeroBattler());
151 std::list<BattlerFacade*> allyList;
152 for(std::list<BattlerFacade*>::iterator itr = m_battlerList.begin() ; itr != m_battlerList.end() ; ++itr){
153 if((*itr)->getType() == et::ENEMY && *itr != pBattler)allyList.push_back(*itr);
155 return pBattler->createNextAction(enemyList , allyList);
161 et::BattleAction et::BattleData::pollBattleAction(){
162 BattleAction action = m_battleAction;
163 m_battleAction.type = BattleAction::NONE;
167 bool et::BattleData::isOver(){
168 if(!m_pGroup->getHeroBattler()->getParameter().alive)return true;
169 //et::BattlerFacade* pEnemy = NULL;
170 return m_pGroup->getEnemyBattlerListAlive().size() == 0;
171 /*for(int i = 0 ; (pEnemy = m_pGroup->getEnemyBattlerAt(i)) != NULL ; i++){
172 if(pEnemy->getParameter().alive)return false;
179 std::list<et::ItemData>& et::BattleData::getItemList(){
180 return m_pGameData->getBattleItemList();