1 #include "FixedBattler.h"
2 #include "mof/KeyFrameAnimation.h"
3 #include "AttackAction.h"
4 #include "SpecialAction.h"
5 #include "BattlerGroup.h"
7 #include "AttackAction.h"
8 #include "SpecialAction.h"
10 et::FixedBattler::FixedBattler(BattlerType type , et::BattlerParameter& parameter , mof::TextureManager* pTextureManager , et::GameData* pGameData)
11 : BattlerFacade(type) , m_pGameData(pGameData)
13 m_command.type = et::BattleAction::NONE;
14 setParameter(parameter);
16 if(getType() == et::HERO){
17 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/hero0.png")));
19 else if(getType() == et::ENEMY){
20 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/hd.png")));
22 else if(getType() == et::IDEAL){
23 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/ideal.png")));
26 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
27 pAnimation->setScale(0 , mof::Vector3D(0.3f , 0.3f , 0.3f));
28 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
29 getGraphicsObject()->setAnimation( 0 , mof::AnimationResource(pAnimation));
37 mof::AnimationResource et::FixedBattler::setMovingAnimation(mof::Vector3D& goal , int nFrame){
38 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
39 pAnimation->setPosition(0 , getPosition());
40 pAnimation->setPosition(nFrame-1 , goal);
41 mof::AnimationResource resource(pAnimation);
42 getGraphicsObject()->setAnimation( 1 , resource);
46 mof::AnimationResource et::FixedBattler::setAidlingAnimation(mof::Vector3D& position ){
47 if(!getParameter().alive){
48 //
\89½
\82à
\95\
\8e¦
\82µ
\82È
\82¢
49 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation(true);
50 pAnimation->setPosition(0 , position);
51 pAnimation->setTextureRectangle(0 , mof::Line2D(1 , 1 , 1 , 1));
52 mof::AnimationResource resource(pAnimation);
53 getGraphicsObject()->setAnimation( 1 , resource);
56 else if(getParameter().guard && getType() == et::HERO){
58 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation(true);
59 pAnimation->setPosition(0 , position);
60 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 64*2 , 64 , 64*3));
61 mof::AnimationResource resource(pAnimation);
62 getGraphicsObject()->setAnimation( 1 , resource);
66 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation(true);
67 pAnimation->setPosition(0 , position);
68 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
69 pAnimation->setTextureRectangle(15 , mof::Line2D(0 , 64 , 64 , 64*2));
70 pAnimation->setTextureRectangle(30-1 , mof::Line2D(0 , 0 , 64 , 64));
71 mof::AnimationResource resource(pAnimation);
72 getGraphicsObject()->setAnimation( 1 , resource);
77 mof::AnimationResource et::FixedBattler::setCastAnimation(int category){
78 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
82 pAnimation->setPosition(0 , getPosition());
83 pAnimation->setTextureRectangle(0 , mof::Line2D(64 , 0 , 128 , 64));
84 pAnimation->setTextureRectangle(10 , mof::Line2D(64 , 64 , 128 , 64*2));
85 pAnimation->setTextureRectangle(20 , mof::Line2D(64 , 128 , 128 , 64*3));
86 pAnimation->setFinalKey(20);
88 else if(category == 1){
89 pAnimation->setPosition(0 , getPosition());
90 pAnimation->setTextureRectangle(0 , mof::Line2D(64*2 , 0 , 64*3 , 64));
91 pAnimation->setTextureRectangle(40 , mof::Line2D(0 , 0 , 64 , 64));
92 pAnimation->setFinalKey(20);
94 mof::AnimationResource resource(pAnimation);
95 getGraphicsObject()->setAnimation( 1 , resource);
100 mof::AnimationResource et::FixedBattler::setDamagedAnimation(int level){
101 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
104 mof::Vector3D backPosition = getPosition();
105 backPosition.x += (getType() == et::ENEMY)? -0.1f : 0.1f;
106 pAnimation->setPosition(0 , getPosition());
107 pAnimation->setPosition(10 , backPosition);
108 pAnimation->setPosition(40 , backPosition);
109 pAnimation->setPosition(60 , getPosition());
111 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
112 pAnimation->setTextureRectangle(8 , mof::Line2D(64*3 , 0 , 256 , 64));
113 pAnimation->setTextureRectangle(10 , mof::Line2D(1 , 1 , 1 , 1));
114 pAnimation->setTextureRectangle(12 , mof::Line2D(64*3 , 0 , 256 , 64));
115 pAnimation->setTextureRectangle(14 , mof::Line2D(1 , 1 , 1 , 1));
116 pAnimation->setTextureRectangle(16 , mof::Line2D(1 , 1 , 1 , 1));
117 pAnimation->setTextureRectangle(26 , mof::Line2D(0 , 0 , 64 , 64));
123 mof::Vector3D backPosition = getPosition();
124 backPosition.x += (getType() == et::ENEMY)? -0.1f : 0.1f;
125 pAnimation->setPosition(0 , getPosition());
126 pAnimation->setPosition(10 , backPosition);
128 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
129 pAnimation->setTextureRectangle(8 , mof::Line2D(64*3 , 0 , 256 , 64));
130 pAnimation->setTextureRectangle(10 , mof::Line2D(1 , 1 , 1 , 1));
131 pAnimation->setTextureRectangle(12 , mof::Line2D(64*3 , 0 , 256 , 64));
132 pAnimation->setTextureRectangle(14 , mof::Line2D(1 , 1 , 1 , 1));
133 pAnimation->setTextureRectangle(25 , mof::Line2D(1 , 1 , 1 , 1));
136 mof::AnimationResource resource(pAnimation);
137 getGraphicsObject()->setAnimation( 1 , resource);
141 void et::FixedBattler::setBattleCommand(BattleAction& action){
145 et::Action* et::FixedBattler::createAction(BattlerGroup* pGroup ){
147 if(m_command.type == et::BattleAction::ATTACK_WEAPON){
148 return new AttackAction(this , m_command.pTarget , 3);
150 else if(m_command.type == et::BattleAction::WAIT || m_command.type == et::BattleAction::GUARD){
153 else if(m_command.type == et::BattleAction::CAST){
154 et::BattlerFacade* pIdeal = pGroup->getIdealBattlerAt(m_command.idealIndex);
155 et::BattlerParameter parameter = pIdeal->getParameter();
156 parameter.dActionPoint -= 5;
157 pIdeal->setParameter(parameter);
158 std::vector<et::BattlerFacade*> targetList;
159 if(m_command.pTarget != NULL)targetList.push_back(m_command.pTarget);
160 else targetList = pGroup->getEnemyBattlerListAlive();
162 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
163 return new SpecialAction(this , targetList , 5 , m_command.idealIndex);
165 else if(m_command.type == et::BattleAction::USE_ITEM){
166 //
\83A
\83C
\83e
\83\80\82ð
\82È
\82
\82·
167 std::list<et::ItemData> &refList = m_pGameData->getBattleItemList();
168 for(std::list<et::ItemData>::iterator itr = refList.begin() ; itr != refList.end() ; ++itr){
169 if(m_command.pTargetItem == &(*itr)){
174 std::vector<et::BattlerFacade*> targetList;
175 if(m_command.pTarget != NULL)targetList.push_back(m_command.pTarget);
176 else targetList = pGroup->getEnemyBattlerListAlive();
178 //
\93Á
\8eê
\8bZ
\82Ì
\8eí
\97Þ
\82ð
\93¾
\82é
179 return new SpecialAction(this , targetList , 2 , 3);
183 /*et::Action* et::FixedBattler::createNextAction(std::list<BattlerFacade*>& enemy , std::list<BattlerFacade*>& ally){
184 //if(pBattler->getParameter().actionPoint >= 3)return new AttackAction(pBattler , getHeroBattler() , 3 , 1.0f);