OSDN Git Service

fix cmake/Macros.cmake
[moflib/moflib.git] / saisei-1.0 / rpg / rpg / oldcode / FixedBattler.cpp
1 #include "FixedBattler.h"
2 #include "mof/KeyFrameAnimation.h"
3 #include "AttackAction.h"
4 #include "SpecialAction.h"
5 #include "BattlerGroup.h"
6 #include "GameData.h"
7 #include "AttackAction.h"
8 #include "SpecialAction.h"
9
10 et::FixedBattler::FixedBattler(BattlerType type , et::BattlerParameter& parameter , mof::TextureManager* pTextureManager , et::GameData* pGameData)
11 : BattlerFacade(type) , m_pGameData(pGameData)
12 {
13         m_command.type = et::BattleAction::NONE;
14         setParameter(parameter);
15         
16         if(getType() == et::HERO){
17                 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/hero0.png")));
18         }
19         else if(getType() == et::ENEMY){
20                 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/hd.png")));
21         }
22         else if(getType() == et::IDEAL){
23                 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(_T("image/ideal.png")));
24         }
25
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));
30         
31         
32 }
33
34
35
36
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);
43         return resource;
44 }
45
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);
54                 return resource;
55         }
56         else if(getParameter().guard && getType() == et::HERO){
57                 //\83K\81[\83h
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);
63                 return resource;
64         }
65         else {
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);
73                 return resource;
74         }
75 }
76
77 mof::AnimationResource et::FixedBattler::setCastAnimation(int category){
78         mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
79         
80         if(category == 0){
81                 //\92Ê\8fí\8dU\8c\82
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);
87         }
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);
93         }
94         mof::AnimationResource resource(pAnimation);
95         getGraphicsObject()->setAnimation( 1 , resource);
96         return resource;
97         
98 }
99
100 mof::AnimationResource et::FixedBattler::setDamagedAnimation(int level){
101         mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
102         if(level == 0){
103                 //\92Ê\8fí
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());
110         
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));
118                 
119         }
120         else if(level == 1){
121                 //\8e\80\96S
122                 
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);
127                 
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));
134                 
135         }
136         mof::AnimationResource resource(pAnimation);
137         getGraphicsObject()->setAnimation( 1 , resource);
138         return resource;
139 }
140
141 void et::FixedBattler::setBattleCommand(BattleAction& action){
142         m_command = action;
143 }
144
145 et::Action* et::FixedBattler::createAction(BattlerGroup* pGroup ){
146         
147         if(m_command.type == et::BattleAction::ATTACK_WEAPON){
148                 return new AttackAction(this , m_command.pTarget , 3);
149         }
150         else if(m_command.type == et::BattleAction::WAIT || m_command.type == et::BattleAction::GUARD){
151                 return NULL;
152         }
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();
161                 
162                 //\93Á\8eê\8bZ\82Ì\8eí\97Þ\82ð\93¾\82é
163                 return new SpecialAction(this , targetList , 5 , m_command.idealIndex);
164         }
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)){
170                                 refList.erase(itr);
171                                 break;
172                         }
173                 }
174                 std::vector<et::BattlerFacade*> targetList;
175                 if(m_command.pTarget != NULL)targetList.push_back(m_command.pTarget);
176                 else targetList = pGroup->getEnemyBattlerListAlive();
177
178                 //\93Á\8eê\8bZ\82Ì\8eí\97Þ\82ð\93¾\82é
179                 return new SpecialAction(this , targetList , 2 , 3);
180         }
181         else return NULL;
182 }
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);
185                 //else return NULL;
186         return NULL;
187 }*/