OSDN Git Service

fix build system ofmoflib1 and saisei1
[moflib/moflib.git] / saisei-1.0 / src / oldcode / Action.cpp
1 #include "Action.h"
2 #include "BattlerFacade.h"
3 #include "mof/DataRow.h"
4 #include "mof/DataBasedAnimation.h"
5 #include "mof/KeyFrameAnimation.h"
6
7 et::Action::Action(et::BattlerFacade* pBattler , et::BattlerFacade* pTarget , int cost)
8 {
9         m_pBattler = pBattler;
10         if(pTarget != NULL)m_targetList.push_back(pTarget);
11         m_cost = cost;
12 }
13
14
15
16 et::Action::Action(et::BattlerFacade* pBattler , std::vector<et::BattlerFacade*>& targetList , int cost)
17 {
18         m_pBattler = pBattler;
19         m_targetList = targetList;
20         m_cost = cost;
21 }
22
23
24 et::Action::~Action(void)
25 {
26 }
27
28 void et::Action::setTargetList(std::vector<et::BattlerFacade*>& targetList){
29         m_targetList = targetList;
30 }
31
32 std::vector<int> et::Action::doAction(){
33         std::vector<int> result;
34         et::BattlerParameter parameter = m_pBattler->getParameter();
35         parameter.dActionPoint -= getAPCost();
36         m_pBattler->setParameter(parameter);
37         for(std::vector<BattlerFacade*>::iterator itr = m_targetList.begin() ; itr != m_targetList.end() ; ++itr){
38                 result.push_back(doActionTo(*itr));
39         }
40         return result;
41 }
42
43 mof::GraphicsSchedule* et::Action::createEffect(et::Common& common){
44         mof::DataResource effectTable = common.m_pDataResourceManager->getResource(_T("data/effect/shock.csv"));
45
46         mof::GraphicsSchedule* pSchedule = new mof::GraphicsSchedule();
47
48         for(int i = 0 ; i < effectTable->getNumberOfRows() ; i++){
49                 mof::DataRow effectRow = mof::DataRow(effectTable , i);
50
51                 //---\83\82\81[\83V\83\87\83\93\82Ì\8d\\90¬
52                 mof::CascadeAnimation* pCascadeAnimation = new mof::CascadeAnimation();
53                 
54                 mof::KeyFrameAnimation* pCommonAnimation = new mof::KeyFrameAnimation();
55                 mof::Vector3D targetPosition = getTargetList().front()->getPosition();
56                 mof::Vector3D basePosition = m_pBattler->getGraphicsObject()->getPosition();
57                 //\83X\83P\81[\83\8b\82ð\8cv\8eZ
58                 mof::Vector3D scale = targetPosition - basePosition;
59                 //if(scale.x < 0)scale.x = -scale.x;
60                 scale.y = scale.z = 1.0;
61                 pCommonAnimation->setPosition(0 , basePosition);
62                 mof::AnimationResource resource(pCommonAnimation);
63
64                 mof::tstring motionName(effectRow.getData(_T("Motion")));
65                 mof::DataBasedAnimation* pMotionAnimation = new mof::DataBasedAnimation(motionName.c_str() , scale);
66                 pCascadeAnimation->setElement(0 , mof::AnimationResource(pMotionAnimation));
67                 
68                 
69                 pCascadeAnimation->setElement(1 , resource);
70                 mof::AnimationResource animation(pCascadeAnimation);
71
72                 //---\83I\83u\83W\83F\83N\83g\82Ì\8d\\90¬
73                 mof::tstring className(effectRow.getData(_T("Class")));
74
75                 mof::tstring textureName(effectRow.getData(_T("Texture")));
76                 if(textureName == _T(""))textureName = _T("null");
77                 mof::TextureResource texture = common.m_pTextureManager->getResource(textureName.c_str());
78
79                 if(className == _T("Billboard")){
80                         //\83r\83\8b\83{\81[\83h
81                         mof::GraphicsObject* pModel = new mof::Billboard(mof::Billboard::Y_FIXED , texture);
82                         pModel->setAnimation(0 , animation);
83                         pSchedule->add(20 , mof::GraphicsModelPtr(pModel) , animation);
84                 }
85                 else {
86                         //\83\81\83b\83V\83\85(className\82ªPath)
87                         mof::MeshResource pModel = common.m_pMeshManager->getResource(className.c_str());
88                         pModel->setTexture(0 , texture);
89                         pModel->setAnimation(0 , animation);
90                         pSchedule->add(20 , mof::GraphicsModelPtr(pModel) , animation);
91                 }
92                 
93         }
94         
95         
96         return pSchedule;
97 }