1 #include "DataBasedBattler.h"
2 #include "mof/KeyFrameAnimation.h"
3 #include "mof/DataBasedAnimation.h"
6 //#include "AttackerAI.h"
8 et::DataBasedBattler::DataBasedBattler(const TCHAR* pName , mof::DataResourceManager* pDataResourceManager , mof::TextureManager* pTextureManager , TCHAR serialCode)
9 : BattlerFacade(et::ENEMY)
11 m_pDataResourceManager = pDataResourceManager;
12 mof::DataResource resource = m_pDataResourceManager->getResource(_T("data/monster.csv"));
13 m_targetRow = mof::DataRow(resource , pName);
16 std::basic_ostringstream<TCHAR> stream;
17 stream << m_targetRow.getData( _T("Name")) << serialCode;
18 BattlerParameter parameter;
19 parameter.hp = m_targetRow.getIntegerData(_T("Hp"));
20 parameter.maxHp = parameter.hp;
21 parameter.attack = m_targetRow.getIntegerData(_T("Offense"));
22 parameter.diffence = m_targetRow.getIntegerData(_T("Defense"));
23 parameter.name = stream.str();
24 parameter.speed = m_targetRow.getIntegerData(_T("Speed"));
25 parameter.actionPoint = 3;
26 parameter.dActionPoint = 0;
27 setParameter(parameter);
29 mof::DataResource typeResource = m_pDataResourceManager->getResource(_T("data/monster.type.csv"));
30 m_typeRow = mof::DataRow(typeResource , m_targetRow.getData(_T("Type")).c_str());
31 std::basic_ostringstream<TCHAR> stream2;
32 stream2 << _T("image/") << m_typeRow.getData(_T("Image"));
33 m_pGraphicsObject = new mof::Billboard(mof::Billboard::Y_FIXED , pTextureManager->getResource(stream2.str()));
36 updateAI(m_targetRow.getData(_T("AI")).c_str());
39 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
40 pAnimation->setScale(0 , mof::Vector3D(0.3f , 0.3f , 0.3f));
41 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
42 getGraphicsObject()->setAnimation( 0 , mof::AnimationResource(pAnimation));
46 et::DataBasedBattler::~DataBasedBattler(void)
52 void et::DataBasedBattler::updateAI(const TCHAR* const pName){
55 //AI
\83I
\83u
\83W
\83F
\83N
\83g
\82ð
\82Â
\82
\82é
56 mof::tstring ai = m_targetRow.getData(_T("AI"));
57 if(ai == _T("
\83U
\83R
\83^
\83C
\83v"))m_pAI = new NormalAI(m_pDataResourceManager);
58 else if(ai == _T("
\83A
\83^
\83b
\83J
\81["))m_pAI = new NormalAI(m_pDataResourceManager);
62 mof::AnimationResource et::DataBasedBattler::setMovingAnimation(mof::Vector3D& goal , int nFrame){
63 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
64 pAnimation->setPosition(0 , getPosition());
65 pAnimation->setPosition(nFrame-1 , goal);
66 mof::AnimationResource resource(pAnimation);
67 getGraphicsObject()->setAnimation( 1 , resource);
71 mof::AnimationResource et::DataBasedBattler::setAidlingAnimation(mof::Vector3D& position ){
72 if(!getParameter().alive){
73 //
\89½
\82à
\95\
\8e¦
\82µ
\82È
\82¢
74 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation(true);
75 pAnimation->setPosition(0 , position);
76 pAnimation->setTextureRectangle(0 , mof::Line2D(1 , 1 , 1 , 1));
77 mof::AnimationResource resource(pAnimation);
78 getGraphicsObject()->setAnimation( 1 , resource);
81 else if(getParameter().guard && getType() == et::HERO){
83 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation(true);
84 pAnimation->setPosition(0 , position);
85 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 64*2 , 64 , 64*3));
86 mof::AnimationResource resource(pAnimation);
87 getGraphicsObject()->setAnimation( 1 , resource);
91 mof::CascadeAnimation* pCascadeAnimation = new mof::CascadeAnimation();
93 mof::KeyFrameAnimation* pBaseAnimation = new mof::KeyFrameAnimation(true);
94 pBaseAnimation->setPosition(0 , mof::Vector3D(position));
95 pCascadeAnimation->setElement(0 , mof::AnimationResource(pBaseAnimation));
98 pCascadeAnimation->setElement(1 , mof::AnimationResource(
99 new mof::DataBasedAnimation(m_typeRow.getData(_T("AidlingMotion")).c_str() , true)));
101 mof::AnimationResource resource(pCascadeAnimation);
102 getGraphicsObject()->setAnimation( 1 , resource);
107 mof::AnimationResource et::DataBasedBattler::setCastAnimation(int category){
109 const TCHAR* const table[] = {_T("DirectAttack1Motion") , _T("DirectAttack2Motion") ,
110 _T("SpecialAttack1Motion") , _T("SpecialAttack2Motion")};
112 mof::CascadeAnimation* pCascadeAnimation = new mof::CascadeAnimation();
114 mof::KeyFrameAnimation* pBaseAnimation = new mof::KeyFrameAnimation();
115 pBaseAnimation->setPosition(0 , mof::Vector3D(getPosition()));
116 //pBaseAnimation->setFinalKey(20);
117 pCascadeAnimation->setElement(0 , mof::AnimationResource(pBaseAnimation));
119 pCascadeAnimation->setElement(1 , mof::AnimationResource(
120 new mof::DataBasedAnimation(m_typeRow.getData(table[category] ).c_str() )));
121 mof::AnimationResource resource(pCascadeAnimation);
122 getGraphicsObject()->setAnimation( 1 , resource);
127 mof::AnimationResource et::DataBasedBattler::setDamagedAnimation(int level){
128 mof::KeyFrameAnimation* pAnimation = new mof::KeyFrameAnimation();
131 mof::Vector3D backPosition = getPosition();
132 backPosition.x += (getType() == et::ENEMY)? -0.1f : 0.1f;
133 pAnimation->setPosition(0 , getPosition());
134 pAnimation->setPosition(10 , backPosition);
135 pAnimation->setPosition(40 , backPosition);
136 pAnimation->setPosition(60 , getPosition());
138 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
139 pAnimation->setTextureRectangle(8 , mof::Line2D(64*3 , 0 , 256 , 64));
140 pAnimation->setTextureRectangle(10 , mof::Line2D(1 , 1 , 1 , 1));
141 pAnimation->setTextureRectangle(12 , mof::Line2D(64*3 , 0 , 256 , 64));
142 pAnimation->setTextureRectangle(14 , mof::Line2D(1 , 1 , 1 , 1));
143 pAnimation->setTextureRectangle(16 , mof::Line2D(1 , 1 , 1 , 1));
144 pAnimation->setTextureRectangle(26 , mof::Line2D(0 , 0 , 64 , 64));
149 /*if(getType() == et::HERO){
150 //
\83C
\83G
\83A
\83A
\83A
\83A
\83A
151 mof::Vector3D backPosition = getPosition();
152 backPosition.x += (getType() == et::ENEMY)? -0.1f : 0.1f;
153 pAnimation->setPosition(0 , getPosition());
154 pAnimation->setPosition(10 , backPosition);
155 pAnimation->setPosition(20 , backPosition);
156 backPosition.y += 0.4;
157 pAnimation->setPosition(100 , backPosition);
159 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
160 pAnimation->setTextureRectangle(8 , mof::Line2D(64*3 , 0 , 256 , 64));
161 pAnimation->setTextureRectangle(10 , mof::Line2D(1 , 1 , 1 , 1));
162 pAnimation->setTextureRectangle(12 , mof::Line2D(64*3 , 0 , 256 , 64));
163 pAnimation->setTextureRectangle(14 , mof::Line2D(64*3 , 64 , 256 , 64*2));
164 pAnimation->setTextureRectangle(150 , mof::Line2D(64*3 , 64 , 256 , 64*2));
167 mof::Vector3D backPosition = getPosition();
168 backPosition.x += (getType() == et::ENEMY)? -0.1f : 0.1f;
169 pAnimation->setPosition(0 , getPosition());
170 pAnimation->setPosition(10 , backPosition);
172 pAnimation->setTextureRectangle(0 , mof::Line2D(0 , 0 , 64 , 64));
173 pAnimation->setTextureRectangle(8 , mof::Line2D(64*3 , 0 , 256 , 64));
174 pAnimation->setTextureRectangle(10 , mof::Line2D(1 , 1 , 1 , 1));
175 pAnimation->setTextureRectangle(12 , mof::Line2D(64*3 , 0 , 256 , 64));
176 pAnimation->setTextureRectangle(14 , mof::Line2D(1 , 1 , 1 , 1));
177 pAnimation->setTextureRectangle(25 , mof::Line2D(1 , 1 , 1 , 1));
180 mof::AnimationResource resource(pAnimation);
181 getGraphicsObject()->setAnimation( 1 , resource);
186 et::Action* et::DataBasedBattler::createAction(BattlerGroup* pGroup ) {
187 return m_pAI->createAction(this , pGroup);