• R/O
  • SSH
  • HTTPS

shaman: Commit


Commit MetaInfo

Révision65 (tree)
l'heure2012-11-19 00:14:17
Auteurshom5xg

Message de Log

Make Knight to appear on the sequence.

Change Summary

Modification

--- trunk/program/src/service/service_entity.cpp (revision 64)
+++ trunk/program/src/service/service_entity.cpp (revision 65)
@@ -14,6 +14,7 @@
1414 #include "entity/automata/automata_shaman.h"
1515 #include "entity/automata/automata_gilgen.h"
1616 #include "entity/automata/automata_ghost.h"
17+#include "entity/automata/Automata_Knight.h"
1718 #include "entity/automata/automata_car.h"
1819 #include "entity/reactor/reactor_prop.h"
1920
@@ -161,7 +162,9 @@
161162 case eEntity_Hara: { p_entity = new cautomata_shaman(); } break;
162163 case eEntity_Gilgen: { p_entity = new CAutomata_Gilgen(); } break;
163164
164- case eEntity_Ghost: { p_entity = new cautomata_ghost(); } break;
165+ case eEntity_Ghost: { p_entity = new CAutomata_Ghost(); } break;
166+ case eEntity_KnightRed: { p_entity = new CAutomata_Knight( TRUE ); } break;
167+ case eEntity_KnightBlue:{ p_entity = new CAutomata_Knight( FALSE ); } break;
165168
166169 case eEntity_Car: { p_entity = new CAutomata_Car(); } break;
167170
--- trunk/program/src/module/Module_Ai.cpp (revision 64)
+++ trunk/program/src/module/Module_Ai.cpp (revision 65)
@@ -32,6 +32,7 @@
3232 {
3333 { eModuleComponent_AiGilgen },
3434 { eModuleComponent_AiGhost },
35+ { eModuleComponent_Ai_Knight },
3536 };
3637 BOOST_STATIC_ASSERT( ELEMENTSOF( sc_e_compo_list ) == eNof_Ai );
3738 };
--- trunk/program/src/module/Module_Ai.h (revision 64)
+++ trunk/program/src/module/Module_Ai.h (revision 65)
@@ -16,6 +16,7 @@
1616 {
1717 eAi_Gilgen,
1818 eAi_Ghost,
19+ eAi_Knight,
1920
2021 eNof_Ai,
2122 eAi_Invalid,
--- trunk/program/src/module/ai/ai_ghost.h (revision 64)
+++ trunk/program/src/module/ai/ai_ghost.h (revision 65)
@@ -18,23 +18,24 @@
1818
1919 void SetInDamage( b32 b_in_damage );
2020
21+ enum eState
22+ {
23+ eState_Appear = ai::sc_state_init,
24+ eState_Wander,
25+ eState_Approach,
26+ eState_Belch,
27+
28+ eNof_State,
29+ eState_Invalid = U32_INVALID,
30+ };
31+
2132 private:
2233 virtual void update_shift_ai();
2334 virtual void update_exec_ai();
2435
25- enum eSTATE
26- {
27- eSTATE_APPEAR = ai::sc_state_init,
28- eSTATE_WANDER,
29- eSTATE_APPROACH,
30- eSTATE_BELCH,
31-
32- eNOF_STATE,
33- eSTATE_INVALID = U32_INVALID,
34- };
36+private:
37+ centity_base *m_pEntityTarget;
3538
36- centity_base* m_p_entity_target;
37-
38- b32 m_b_in_damage;
39+ b32 m_bInDamage;
3940 };
4041
--- trunk/program/src/module/ai/Ai_Knight.h (nonexistent)
+++ trunk/program/src/module/ai/Ai_Knight.h (revision 65)
@@ -0,0 +1,41 @@
1+/***************************************************************************/
2+/** @file Ai_Knight.h
3+ @brief
4+ @author shom
5+ @internal
6+****************************************************************************/
7+
8+#pragma once
9+
10+#include "ai_base.h"
11+
12+class CModuleComponent_Ai_Knight
13+:
14+public cai_base
15+{
16+public:
17+ CModuleComponent_Ai_Knight( centity_base* const p_entity_loaded );
18+
19+ void SetInDamage( b32 b_in_damage );
20+
21+ enum eState
22+ {
23+ eState_Appear = ai::sc_state_init,
24+ eState_Wander,
25+ eState_Approach,
26+ eState_Belch,
27+
28+ eNof_State,
29+ eState_Invalid = U32_INVALID,
30+ };
31+
32+private:
33+ virtual void update_shift_ai();
34+ virtual void update_exec_ai();
35+
36+private:
37+ centity_base *m_pEntityTarget;
38+
39+ b32 m_bInDamage;
40+};
41+
--- trunk/program/src/module/ai/ai_ghost.cpp (revision 64)
+++ trunk/program/src/module/ai/ai_ghost.cpp (revision 65)
@@ -23,16 +23,17 @@
2323 CModuleComponent_AiGhost::CModuleComponent_AiGhost(
2424 centity_base* const p_entity_loaded
2525 )
26-:
27-cai_base( eModuleComponent_AiGhost, p_entity_loaded ),
26+: cai_base( eModuleComponent_AiGhost, p_entity_loaded )
2827
29-m_b_in_damage( FALSE )//,
28+, m_pEntityTarget( NULL )
29+
30+, m_bInDamage( FALSE )
3031 {
3132 }
3233
33-void CModuleComponent_AiGhost::SetInDamage( b32 b_in_damage )
34+void CModuleComponent_AiGhost::SetInDamage( b32 in_bInDamage )
3435 {
35- m_b_in_damage = b_in_damage;
36+ m_bInDamage = in_bInDamage;
3637 }
3738
3839 void CModuleComponent_AiGhost::update_shift_ai()
@@ -39,46 +40,49 @@
3940 {
4041 if( g_pService_GameCtrl->IsGameOver() )
4142 {
42- set_state( eSTATE_WANDER );
43+ set_state( eState_Wander );
4344 }
4445 else
4546 {
4647 switch( get_state() )
4748 {
48- case eSTATE_APPEAR:
49+ case eState_Appear:
4950 {
50- const b32 b_appear_end = TRUE;
51+ const b32 bAppearEnd = TRUE;
5152
52- if( b_appear_end )
53+ if( bAppearEnd )
5354 {
54- set_state( eSTATE_WANDER );
55+ set_state( eState_Wander );
5556 }
5657 }
5758 break;
5859
59- case eSTATE_WANDER:
60+ case eState_Wander:
6061 {
61- set_state( eSTATE_APPROACH );
62+ set_state( eState_Approach );
6263 }
6364 break;
6465
65- case eSTATE_APPROACH:
66+ case eState_Approach:
6667 {
67- if( GetElapsedTimeInState() > 6 * 1000 )
68+ if( GetElapsedTimeInState() > ( 6 * 1000 ) )
6869 {
69- set_state( eSTATE_BELCH );
70+ set_state( eState_Belch );
7071 }
7172 }
7273 break;
7374
74- case eSTATE_BELCH:
75+ case eState_Belch:
7576 {
76- m_p_entity_loaded->QUERY_MODULE( MotionGhost )->
77- Request( motion_ghost_def::eMotion_Belch );
77+ if( !m_bInDamage )
78+ {
79+ m_p_entity_loaded->QUERY_MODULE( MotionGhost )->
80+ Request( motion_ghost_def::eMotion_Belch );
81+ }
7882
79- if( GetElapsedTimeInState() > 2 * 1000 )
83+ if( GetElapsedTimeInState() > ( 2 * 1000 ) )
8084 {
81- set_state( eSTATE_APPROACH );
85+ set_state( eState_Approach );
8286 }
8387 }
8488 break;
@@ -92,33 +96,33 @@
9296 {
9397 switch( get_state() )
9498 {
95- case eSTATE_APPEAR:
99+ case eState_Appear:
96100 {
97101 //TODO
98102 }
99103 break;
100104
101- case eSTATE_WANDER:
105+ case eState_Wander:
102106 {
103107 //TODO
104108 }
105109 break;
106110
107- case eSTATE_APPROACH:
111+ case eState_Approach:
108112 {
109- if( !m_b_in_damage )
113+ if( !m_bInDamage )
110114 {
111- vec2f v2_pos_target, v2_pos_me;
115+ vec2f v2PosTarget, v2PosMe;
112116
113- g_p_service_entity->FindHara()->GetPos( v2_pos_target );
114- m_p_entity_loaded->GetPos( v2_pos_me );
117+ g_p_service_entity->FindHara()->GetPos( v2PosTarget );
118+ m_p_entity_loaded->GetPos( v2PosMe );
115119
116- m_p_entity_loaded->Move( v2_pos_target - v2_pos_me, 0.5f );
120+ m_p_entity_loaded->Move( v2PosTarget - v2PosMe, 0.5f );
117121 }
118122 }
119123 break;
120124
121- case eSTATE_BELCH:
125+ case eState_Belch:
122126 {
123127 //TODO
124128 }
--- trunk/program/src/module/ai/Ai_Knight.cpp (nonexistent)
+++ trunk/program/src/module/ai/Ai_Knight.cpp (revision 65)
@@ -0,0 +1,134 @@
1+/***************************************************************************/
2+/** @file Ai_Knight.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "Ai_Knight.h"
10+
11+#include "entity/entity_base.h"
12+
13+#include "service/service_entity.h"
14+#include "entity/automata/automata_shaman.h"
15+#include "service/Service_GameCtrl.h"
16+#include "module/motion/ghost/motion_ghost.h"
17+
18+
19+/***************************************************************************
20+ CModuleComponent_Ai_Knight
21+****************************************************************************/
22+
23+CModuleComponent_Ai_Knight::CModuleComponent_Ai_Knight(
24+ centity_base* const p_entity_loaded
25+ )
26+: cai_base( eModuleComponent_Ai_Knight, p_entity_loaded )
27+
28+, m_pEntityTarget( NULL )
29+
30+, m_bInDamage( FALSE )
31+{
32+}
33+
34+void CModuleComponent_Ai_Knight::SetInDamage( b32 in_bInDamage )
35+{
36+ m_bInDamage = in_bInDamage;
37+}
38+
39+void CModuleComponent_Ai_Knight::update_shift_ai()
40+{
41+ if( g_pService_GameCtrl->IsGameOver() )
42+ {
43+ set_state( eState_Wander );
44+ }
45+ else
46+ {
47+ switch( get_state() )
48+ {
49+ case eState_Appear:
50+ {
51+ const b32 bAppearEnd = TRUE;
52+
53+ if( bAppearEnd )
54+ {
55+ set_state( eState_Wander );
56+ }
57+ }
58+ break;
59+
60+ case eState_Wander:
61+ {
62+ set_state( eState_Approach );
63+ }
64+ break;
65+
66+ case eState_Approach:
67+ {
68+ if( GetElapsedTimeInState() > ( 6 * 1000 ) )
69+ {
70+ set_state( eState_Belch );
71+ }
72+ }
73+ break;
74+
75+ case eState_Belch:
76+ {
77+ if( !m_bInDamage )
78+ {
79+// m_p_entity_loaded->QUERY_MODULE( MotionGhost )->
80+// Request( motion_ghost_def::eMotion_Belch );
81+ }
82+
83+ if( GetElapsedTimeInState() > ( 2 * 1000 ) )
84+ {
85+ set_state( eState_Approach );
86+ }
87+ }
88+ break;
89+
90+ default: DEBUG_BREAK(); break;
91+ }
92+ }
93+}
94+
95+void CModuleComponent_Ai_Knight::update_exec_ai()
96+{
97+ switch( get_state() )
98+ {
99+ case eState_Appear:
100+ {
101+ //TODO
102+ }
103+ break;
104+
105+ case eState_Wander:
106+ {
107+ //TODO
108+ }
109+ break;
110+
111+ case eState_Approach:
112+ {
113+ if( !m_bInDamage )
114+ {
115+ vec2f v2PosTarget, v2PosMe;
116+
117+ g_p_service_entity->FindHara()->GetPos( v2PosTarget );
118+ m_p_entity_loaded->GetPos( v2PosMe );
119+
120+ m_p_entity_loaded->Move( v2PosTarget - v2PosMe, 0.5f );
121+ }
122+ }
123+ break;
124+
125+ case eState_Belch:
126+ {
127+ //TODO
128+ }
129+ break;
130+
131+ default: DEBUG_BREAK(); break;
132+ }
133+}
134+
--- trunk/program/src/module/ModuleDef.h (revision 64)
+++ trunk/program/src/module/ModuleDef.h (revision 65)
@@ -20,10 +20,12 @@
2020 MODULE_COMPONENT__MODULE_DEF_mb( MotionShaman )\
2121 MODULE_COMPONENT__MODULE_DEF_mb( MotionGhost )\
2222 MODULE_COMPONENT__MODULE_DEF_mb( MotionGilgen )\
23+MODULE_COMPONENT__MODULE_DEF_mb( MotionKnightBase )\
2324 /*-- */\
2425 /*-- "ai"*/\
2526 MODULE_COMPONENT__MODULE_DEF_mb( AiGilgen )\
2627 MODULE_COMPONENT__MODULE_DEF_mb( AiGhost )\
28+MODULE_COMPONENT__MODULE_DEF_mb( Ai_Knight )\
2729 /*-- */\
2830 /**=====================================================================**/
2931
@@ -54,8 +56,9 @@
5456 MODULE__MODULE_DEF_mb( Spirit )\
5557 /*-- "motion"*/\
5658 MODULE__MODULE_DEF_mb( MotionShaman )\
59+MODULE__MODULE_DEF_mb( MotionGhost )\
5760 MODULE__MODULE_DEF_mb( MotionGilgen )\
58-MODULE__MODULE_DEF_mb( MotionGhost )\
61+MODULE__MODULE_DEF_mb( MotionKnightBase )\
5962 /*-- */\
6063 /*-- "movement"*/\
6164 MODULE__MODULE_DEF_mb( MovementGilgen )\
--- trunk/program/src/module/ModuleAll.h (revision 64)
+++ trunk/program/src/module/ModuleAll.h (revision 65)
@@ -17,9 +17,11 @@
1717 #include "component/ModuleComponent_Hp.h"
1818 #include "component/ModuleComponent_Collision.h"
1919 #include "motion/shaman/motion_shaman.h"
20+#include "motion/Ghost/Motion_Ghost.h"
2021 #include "motion/Gilgen/Motion_Gilgen.h"
21-#include "motion/ghost/motion_ghost.h"
22+#include "motion/Knight/Motion_KnightBase.h"
2223 #include "movement/Movement_Gilgen.h"
2324 #include "ai/Ai_Gilgen.h"
2425 #include "ai/ai_ghost.h"
26+#include "ai/Ai_Knight.h"
2527
--- trunk/program/src/module/motion/ghost/motion_ghost.h (revision 64)
+++ trunk/program/src/module/motion/ghost/motion_ghost.h (revision 65)
@@ -13,7 +13,9 @@
1313
1414 #include "core/sound/Sound_def.h"
1515
16+#include "module/motion/MotionObject_Base.h"
1617
18+
1719 class CModuleComponent_MotionGhost
1820 :
1921 public CModuleComponent_Base
@@ -29,12 +31,10 @@
2931 private:
3032 void set_texture_active( motion_ghost_def::eTexture in_e_tex );
3133
34+ CMotionObject_Base *m_pMotionObject_tbl[ motion_ghost_def::eNof_Motion ];
35+
3236 motion_ghost_def::eMotion m_eMotionCur;
33- u32 m_TexIdx_list[ motion_ghost_def::eNof_Texture ];
3437 vec2f m_v2_pos_prev;
35- u32 m_uFrameMotionCur;
36-
37- theSound m_hSeBelch;
3838 };
3939
4040
--- trunk/program/src/module/motion/ghost/MotionObject_Ghost.cpp (nonexistent)
+++ trunk/program/src/module/motion/ghost/MotionObject_Ghost.cpp (revision 65)
@@ -0,0 +1,64 @@
1+/***************************************************************************/
2+/** @file MotionObject_Ghost.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "MotionObject_Ghost.h"
10+
11+
12+/***************************************************************************
13+ CMotionObject_Ghost_Move
14+****************************************************************************/
15+
16+CMotionObject_Ghost_Move::CMotionObject_Ghost_Move( centity_base* in_pEntity )
17+:
18+CMotionObject_BaseOne( in_pEntity, _T( "texture/chara/ghost/ghost.png" ) )
19+{
20+}
21+
22+
23+/***************************************************************************
24+ CMotionObject_Ghost_Bite
25+****************************************************************************/
26+
27+CMotionObject_Ghost_Bite::CMotionObject_Ghost_Bite( centity_base* in_pEntity )
28+:
29+CMotionObject_BaseTwo(
30+ in_pEntity,
31+ _T( "texture/chara/ghost/ghost_kamu00.png" ),
32+ _T( "texture/chara/ghost/ghost_kamu01.png" )
33+ )
34+{
35+}
36+
37+
38+/***************************************************************************
39+ CMotionObject_Ghost_Belch
40+****************************************************************************/
41+
42+CMotionObject_Ghost_Belch::CMotionObject_Ghost_Belch( centity_base* in_pEntity )
43+:
44+CMotionObject_BaseOne(
45+ in_pEntity,
46+ _T( "texture/chara/ghost/ghost_shout.png" ),
47+ _T( "sound\\se\\ghost_voice.wav" )
48+ )
49+{
50+}
51+
52+
53+/***************************************************************************
54+ CMotionObject_Ghost_Damaged
55+****************************************************************************/
56+
57+CMotionObject_Ghost_Damaged::CMotionObject_Ghost_Damaged( centity_base* in_pEntity )
58+:
59+CMotionObject_BaseOne( in_pEntity, _T( "texture/chara/ghost/ghost_damage.png" ) )
60+{
61+ StartBlink();
62+}
63+
64+
--- trunk/program/src/module/motion/ghost/MotionObject_Ghost.h (nonexistent)
+++ trunk/program/src/module/motion/ghost/MotionObject_Ghost.h (revision 65)
@@ -0,0 +1,43 @@
1+/***************************************************************************/
2+/** @file MotionObject_Ghost.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "module/motion/MotionObject_Base.h"
10+
11+
12+class CMotionObject_Ghost_Move
13+:
14+public CMotionObject_BaseOne
15+{
16+public:
17+ CMotionObject_Ghost_Move( centity_base* in_pEntity );
18+};
19+
20+class CMotionObject_Ghost_Bite
21+:
22+public CMotionObject_BaseTwo
23+{
24+public:
25+ CMotionObject_Ghost_Bite( centity_base* in_pEntity );
26+};
27+
28+class CMotionObject_Ghost_Belch
29+:
30+public CMotionObject_BaseOne
31+{
32+public:
33+ CMotionObject_Ghost_Belch( centity_base* in_pEntity );
34+};
35+
36+class CMotionObject_Ghost_Damaged
37+:
38+public CMotionObject_BaseOne
39+{
40+public:
41+ CMotionObject_Ghost_Damaged( centity_base* in_pEntity );
42+};
43+
--- trunk/program/src/module/motion/ghost/motion_ghost.cpp (revision 64)
+++ trunk/program/src/module/motion/ghost/motion_ghost.cpp (revision 65)
@@ -1,5 +1,5 @@
11 /***************************************************************************/
2-/** @file CModuleComponent_MotionShaman.cpp
2+/** @file motion_ghost.cpp
33 @brief
44 @author shom
55 ****************************************************************************/
@@ -12,13 +12,10 @@
1212 #include "core/graphic/2d/image_board.h"
1313
1414 #include "module/module_base.h"
15-#include "module/ai/ai_ghost.h"
1615
17-#include "game.h"
16+#include "MotionObject_Ghost.h"
1817
19-#include "core/sound/Sound.h"
2018
21-
2219 using namespace motion_ghost_def;
2320
2421
@@ -26,123 +23,65 @@
2623 CModuleComponent_MotionGhost
2724 ****************************************************************************/
2825
29-CModuleComponent_MotionGhost::
30-CModuleComponent_MotionGhost( centity_base* const in_p_entity_loaded )
26+#define CIMPL CModuleComponent_MotionGhost
27+
28+CIMPL::CIMPL( centity_base* ct in_p_entity_loaded )
3129 :
3230 CModuleComponent_Base( eModuleComponent_MotionGhost, in_p_entity_loaded ),
3331
32+m_pMotionObject_tbl(),
33+
3434 m_eMotionCur( eMotion_Move ),
35-m_TexIdx_list(),
36-m_v2_pos_prev( mm::zero_v2() ),
37-m_uFrameMotionCur( 0 ),
38-
39-m_hSeBelch()//,
35+m_v2_pos_prev( mm::zero_v2() )
4036 {
41- #define CREATE_TEXTURE( _idx, _sz_path ) \
42- \
43- m_TexIdx_list[ eTexture_##_idx ] = \
44- m_p_entity_loaded->GetImageBoard()-> \
45- CreateTexture( _T( _sz_path ), 64.0f, 64.0f );
37+ m_pMotionObject_tbl[ motion_ghost_def::eMotion_Move ] = new CMotionObject_Ghost_Move( m_p_entity_loaded );
38+ m_pMotionObject_tbl[ motion_ghost_def::eMotion_Bite ] = new CMotionObject_Ghost_Bite( m_p_entity_loaded );
39+ m_pMotionObject_tbl[ motion_ghost_def::eMotion_Belch ] = new CMotionObject_Ghost_Belch( m_p_entity_loaded );
40+ m_pMotionObject_tbl[ motion_ghost_def::eMotion_Damaged ] = new CMotionObject_Ghost_Damaged( m_p_entity_loaded );
4641
47- CREATE_TEXTURE( Move, "texture/chara/ghost/ghost.png" );
48- CREATE_TEXTURE( Bite_1, "texture/chara/ghost/ghost_kamu00.png" );
49- CREATE_TEXTURE( Bite_2, "texture/chara/ghost/ghost_kamu01.png" );
50- CREATE_TEXTURE( Damaged, "texture/chara/ghost/ghost_damage.png" );
51- CREATE_TEXTURE( Belch, "texture/chara/ghost/ghost_shout.png" );
52-
53- #undef CREATE_TEXTURE
54-
55- ///--
56- g_pSound->LoadFile( _T("sound\\se\\ghost_voice.wav"), 0, 4, &m_hSeBelch );
57- ///--
58-
5942 Request( eMotion_Move );
6043 }
6144
62-CModuleComponent_MotionGhost::~CModuleComponent_MotionGhost()
45+CIMPL::~CIMPL()
6346 {
64- g_pSound->ReleaseTheSound( &m_hSeBelch );
47+ for( u32 i=0; i<ELEMENTSOF( m_pMotionObject_tbl ); ++i )
48+ {
49+ my_safe_del( m_pMotionObject_tbl[i] );
50+ }
6551 }
6652
67-void CModuleComponent_MotionGhost::ExecOnFrame()
53+void CIMPL::ExecOnFrame()
6854 {
69- switch( m_eMotionCur )
70- {
71- case eMotion_Move:
72- set_texture_active( eTexture_Move );
73- break;
55+ m_pMotionObject_tbl[ m_eMotionCur ]->ExecOnFrame();
7456
75- case eMotion_Bite:
76- {
77- cu32 uTime =
78- m_p_entity_loaded->QUERY_MODULE( Ai )->
79- FIND_COMPO( AiGhost )->GetElapsedTimeInState();
80- ct eTexture e_tex =
81- ( ( uTime * 1000 / 5 ) % 2 == 0 ) ? eTexture_Bite_1 :
82- eTexture_Bite_2;
83- set_texture_active( e_tex );
84- }
85- break;
86-
87- case eMotion_Belch:
88- {
89- if( m_uFrameMotionCur == 0 )
90- {
91- g_pSound->PlaySound( &m_hSeBelch, 0, 0, TRUE );
92- }
93-
94- set_texture_active( eTexture_Belch );
95- }
96- break;
97-
98- case eMotion_Damaged:
99- set_texture_active( eTexture_Damaged );
100- break;
101-
102- default:
103- break;
104- }
105-
10657 vec2f v2_pos_cur;
10758 m_p_entity_loaded->GetPos( v2_pos_cur );
10859
10960 if( m_v2_pos_prev.x != v2_pos_cur.x )
11061 {
111- const b32 in_b_inverse = m_v2_pos_prev.x < v2_pos_cur.x;
62+ cb32 in_b_inverse = m_v2_pos_prev.x < v2_pos_cur.x;
11263 m_p_entity_loaded->GetImageBoard()->SetInverse( in_b_inverse );
11364 }
11465
11566 m_p_entity_loaded->GetPos( m_v2_pos_prev );
116-
117- ///--
118- ++m_uFrameMotionCur;
119- ///--
12067 }
12168
122-void CModuleComponent_MotionGhost::Request( eMotion in_e_mot )
69+void CIMPL::Request( eMotion in_e_mot )
12370 {
12471 if( m_eMotionCur != in_e_mot )
12572 {
12673 m_eMotionCur = in_e_mot;
12774
128- m_uFrameMotionCur = 0;
75+ m_pMotionObject_tbl[ m_eMotionCur ]->ZeroTimer();
12976 }
13077 }
13178
132-void CModuleComponent_MotionGhost::set_texture_active( eTexture in_e_tex )
133-{
134- ASSERT( in_e_tex < eNof_Texture );
135- const u32 uTexIdx = m_TexIdx_list[ in_e_tex ];
13679
137- m_p_entity_loaded->GetImageBoard()->SetTextureActive( uTexIdx );
138-}
139-
140-
14180 /***************************************************************************
14281 CModule_MotionGhost
14382 ****************************************************************************/
14483
145-CModule_MotionGhost::CModule_MotionGhost( centity_base* const p_entity_loaded )
84+CModule_MotionGhost::CModule_MotionGhost( centity_base* ct p_entity_loaded )
14685 :
14786 CModule_Base( eModule_MotionGhost, p_entity_loaded )
14887 {
@@ -151,7 +90,7 @@
15190 /*------------------------------------------------------------------------*/
15291 namespace
15392 {
154- const eModuleComponent sc_e_compo_list[] =
93+ ct eModuleComponent sc_e_compo_list[] =
15594 {
15695 eModuleComponent_MotionGhost,
15796 };
@@ -159,7 +98,7 @@
15998 /*------------------------------------------------------------------------*/
16099
161100 void CModule_MotionGhost::CompoList(
162- const eModuleComponent** out_p_list,
101+ ct eModuleComponent** out_p_list,
163102 u32& out_len
164103 )
165104 {
@@ -171,3 +110,5 @@
171110 {
172111 FIND_COMPO( MotionGhost )->Request( in_e_mot );
173112 }
113+
114+#undef CIMPL
--- trunk/program/src/module/motion/Knight/Motion_KnightBase.cpp (nonexistent)
+++ trunk/program/src/module/motion/Knight/Motion_KnightBase.cpp (revision 65)
@@ -0,0 +1,176 @@
1+/***************************************************************************/
2+/** @file Motion_KnightBase.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "module/motion/Knight/Motion_KnightBase.h"
10+
11+#include "entity/entity_base.h"
12+#include "core/graphic/2d/image_board.h"
13+
14+#include "core/app.h"
15+
16+
17+using namespace Motion_KnightBase_def;
18+
19+
20+/***************************************************************************
21+ CModuleComponent_MotionKnightBase
22+****************************************************************************/
23+
24+CModuleComponent_MotionKnightBase::
25+CModuleComponent_MotionKnightBase( centity_base* const p_entity_loaded )
26+:
27+CModuleComponent_Base( eModuleComponent_MotionKnightBase, p_entity_loaded ),
28+
29+m_e_state( eSTATE_STOP ),
30+m_e_state_req( eSTATE_INVALID ),
31+
32+m_idx_texture_list(),
33+
34+m_time_exec_elapsed(0)//,
35+{
36+}
37+
38+void CModuleComponent_MotionKnightBase::Initialize( b32 in_bRed )
39+{
40+ #define CREATE_TEXTURE( _idx, _sz_path ) \
41+ \
42+ m_idx_texture_list[ eTEXTURE_##_idx ] = \
43+ m_p_entity_loaded->GetImageBoard()-> \
44+ CreateTexture( _T( _sz_path ), 64.0f, 64.0f );
45+
46+ if( in_bRed )
47+ {
48+ CREATE_TEXTURE( STOP, "texture/chara/KnightRed/knight_red_top.png" );
49+ CREATE_TEXTURE( MOVE_DOWN, "texture/chara/KnightRed/knight_red_top.png" );
50+ CREATE_TEXTURE( MOVE_UP, "texture/chara/KnightRed/knight_red_back.png" );
51+ CREATE_TEXTURE( MOVE_LEFT, "texture/chara/KnightRed/knight_red_l.png" );
52+ CREATE_TEXTURE( MOVE_RIGHT, "texture/chara/KnightRed/knight_red_r.png" );
53+ }
54+ else
55+ {
56+ CREATE_TEXTURE( STOP, "texture/chara/KnightBlue/knight_bule_top.png" );
57+ CREATE_TEXTURE( MOVE_DOWN, "texture/chara/KnightBlue/knight_bule_top.png" );
58+ CREATE_TEXTURE( MOVE_UP, "texture/chara/KnightBlue/knight_bule_back.png" );
59+ CREATE_TEXTURE( MOVE_LEFT, "texture/chara/KnightBlue/knight_bule_l.png" );
60+ CREATE_TEXTURE( MOVE_RIGHT, "texture/chara/KnightBlue/knight_bule_r.png" );
61+ }
62+
63+ #undef CREATE_TEXTURE
64+}
65+
66+void CModuleComponent_MotionKnightBase::ExecOnFrame()
67+{
68+ if( m_e_state_req == eSTATE_INVALID )
69+ {
70+ m_time_exec_elapsed = 0;
71+
72+ m_e_state = eSTATE_STOP;
73+ }
74+ else
75+ {
76+ m_e_state = m_e_state_req;
77+
78+ m_e_state_req = eSTATE_INVALID;
79+ }
80+
81+ m_time_exec_elapsed += app::GetTimeElapsedOnFrame();
82+
83+ exec_state();
84+}
85+
86+void CModuleComponent_MotionKnightBase::exec_state()
87+{
88+ switch( m_e_state )
89+ {
90+ case eSTATE_STOP: exec_state_stop(); break;
91+ case eSTATE_MOVE_DOWN: exec_state_move_down(); break;
92+ case eSTATE_MOVE_UP: exec_state_move_up(); break;
93+ case eSTATE_MOVE_LEFT: exec_state_move_left(); break;
94+ case eSTATE_MOVE_RIGHT: exec_state_move_right(); break;
95+ default: DEBUG_BREAK(); break;
96+ }
97+}
98+
99+void CModuleComponent_MotionKnightBase::exec_state_stop()
100+{
101+ set_texture_active( eTEXTURE_STOP );
102+}
103+
104+void CModuleComponent_MotionKnightBase::exec_state_move_down()
105+{
106+ set_texture_active( eTEXTURE_MOVE_DOWN );
107+}
108+
109+void CModuleComponent_MotionKnightBase::exec_state_move_up()
110+{
111+ set_texture_active( eTEXTURE_MOVE_UP );
112+}
113+
114+void CModuleComponent_MotionKnightBase::exec_state_move_left()
115+{
116+ set_texture_active( eTEXTURE_MOVE_LEFT );
117+}
118+
119+void CModuleComponent_MotionKnightBase::exec_state_move_right()
120+{
121+ set_texture_active( eTEXTURE_MOVE_RIGHT );
122+}
123+
124+void CModuleComponent_MotionKnightBase::set_texture_active( eTEXTURE in_e_tex )
125+{
126+ const u32 idx = m_idx_texture_list[ in_e_tex ];
127+
128+ m_p_entity_loaded->GetImageBoard()->SetTextureActive( idx );
129+}
130+
131+void CModuleComponent_MotionKnightBase::Request( eSTATE e_state )
132+{
133+ m_e_state_req = e_state;
134+}
135+
136+
137+/***************************************************************************
138+ CModule_MotionKnightBase
139+****************************************************************************/
140+
141+CModule_MotionKnightBase::
142+CModule_MotionKnightBase( centity_base* const p_entity_loaded )
143+:
144+CModule_Base( eModule_MotionKnightBase, p_entity_loaded )
145+{
146+}
147+
148+/*------------------------------------------------------------------------*/
149+namespace
150+{
151+ const eModuleComponent sc_e_compo_list[] =
152+ {
153+ eModuleComponent_MotionKnightBase,
154+ };
155+};
156+/*------------------------------------------------------------------------*/
157+
158+void CModule_MotionKnightBase::Initialize( b32 in_bRed )
159+{
160+ FIND_COMPO( MotionKnightBase )->Initialize( in_bRed );
161+}
162+
163+void CModule_MotionKnightBase::CompoList(
164+ const eModuleComponent** out_p_list,
165+ u32& out_len
166+ )
167+{
168+ *out_p_list = sc_e_compo_list;
169+ out_len = 1;
170+}
171+
172+void CModule_MotionKnightBase::Request( eSTATE in_e_state )
173+{
174+ FIND_COMPO( MotionKnightBase )->Request( in_e_state );
175+}
176+
--- trunk/program/src/module/motion/Knight/Motion_KnightBase_def.h (nonexistent)
+++ trunk/program/src/module/motion/Knight/Motion_KnightBase_def.h (revision 65)
@@ -0,0 +1,25 @@
1+/***************************************************************************/
2+/** @file Motion_KnightBase_def.h
3+ @brief
4+ @author shom
5+ @internal
6+****************************************************************************/
7+
8+#pragma once
9+
10+namespace Motion_KnightBase_def
11+{
12+ enum eSTATE
13+ {
14+ eSTATE_STOP,
15+
16+ eSTATE_MOVE_UP,
17+ eSTATE_MOVE_DOWN,
18+ eSTATE_MOVE_LEFT,
19+ eSTATE_MOVE_RIGHT,
20+
21+ eNOF_STATE,
22+ eSTATE_INVALID = U32_INVALID,
23+ };
24+}
25+
--- trunk/program/src/module/motion/Knight/Motion_KnightBase.h (nonexistent)
+++ trunk/program/src/module/motion/Knight/Motion_KnightBase.h (revision 65)
@@ -0,0 +1,76 @@
1+/***************************************************************************/
2+/** @file Motion_KnightBase.h
3+ @brief
4+ @author shom
5+ @internal
6+****************************************************************************/
7+
8+#pragma once
9+
10+#include "module/component/ModuleComponent_Base.h"
11+
12+#include "Motion_KnightBase_def.h"
13+
14+
15+class CModuleComponent_MotionKnightBase
16+:
17+public CModuleComponent_Base
18+{
19+public:
20+ CModuleComponent_MotionKnightBase( centity_base* const p_entity_loaded );
21+
22+ virtual void Initialize( b32 in_bRed );
23+
24+ virtual void ExecOnFrame();
25+private:
26+ void exec_state();
27+ void exec_state_stop();
28+ void exec_state_move_down();
29+ void exec_state_move_up();
30+ void exec_state_move_left();
31+ void exec_state_move_right();
32+
33+ enum eTEXTURE
34+ {
35+ eTEXTURE_STOP,
36+ eTEXTURE_MOVE_DOWN,
37+ eTEXTURE_MOVE_UP,
38+ eTEXTURE_MOVE_LEFT,
39+ eTEXTURE_MOVE_RIGHT,
40+
41+ eNOF_TEXTURE,
42+ eTEXTURE_INVALID = U32_INVALID,
43+ };
44+ void set_texture_active( eTEXTURE e_tex );
45+public:
46+
47+ void Request( Motion_KnightBase_def::eSTATE e_state );
48+
49+private:
50+ Motion_KnightBase_def::eSTATE m_e_state;
51+ Motion_KnightBase_def::eSTATE m_e_state_req;
52+
53+ u32 m_idx_texture_list[ eNOF_TEXTURE ];
54+
55+ u32 m_time_exec_elapsed;
56+};
57+
58+
59+#include "module/Module_Base.h"
60+
61+class CModule_MotionKnightBase
62+:
63+public CModule_Base
64+{
65+public:
66+ CModule_MotionKnightBase( centity_base* const p_entity_loaded );
67+
68+ virtual void Initialize( b32 in_bRed );
69+
70+ virtual void CompoList(
71+ const eModuleComponent** out_p_list,
72+ u32& out_len
73+ );
74+
75+ void Request( Motion_KnightBase_def::eSTATE in_e_state );
76+};
--- trunk/program/src/module/motion/MotionObject_Base.cpp (nonexistent)
+++ trunk/program/src/module/motion/MotionObject_Base.cpp (revision 65)
@@ -0,0 +1,168 @@
1+/***************************************************************************/
2+/** @file MotionObject.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "MotionObject_Base.h"
10+
11+#include "entity/entity_base.h"
12+#include "core/graphic/2d/image_board.h"
13+#include "core/sound/Sound.h"
14+#include "core/app.h"
15+
16+
17+/***************************************************************************
18+ CMotionObject_Base
19+****************************************************************************/
20+
21+#define CIMPL CMotionObject_Base
22+
23+CIMPL::CIMPL( centity_base* in_pEntity )
24+:
25+ m_pEntity( in_pEntity )
26+
27+, m_uTexIdx( U32_INVALID )
28+
29+, m_uFrameMotionCur( 0 )
30+
31+, m_hSeBelch()
32+
33+, m_timerBlink()
34+{
35+ ASSERT( in_pEntity );
36+}
37+
38+CIMPL::~CIMPL()
39+{
40+ if( m_hSeBelch.IsInitialized() )
41+ {
42+ g_pSound->ReleaseTheSound( &m_hSeBelch );
43+ }
44+}
45+
46+void CIMPL::ExecOnFrame()
47+{
48+ ///--
49+ if( m_timerBlink.IsProceed() )
50+ {
51+ cu32 uAlpha ( ( m_timerBlink.GetTime() / 100 % 2 == 0 ) ? 255 : 0 );
52+ m_pEntity->GetImageBoard()->SetColor( set_color_argb( uAlpha ) );
53+ }
54+ else
55+ {
56+ m_pEntity->GetImageBoard()->SetColor( COLOR_WHITE );
57+ }
58+ ///--
59+
60+ ///--
61+ if( m_uFrameMotionCur == 0 )
62+ {
63+ if( m_hSeBelch.IsInitialized() )
64+ {
65+ g_pSound->PlaySound( &m_hSeBelch, 0, 0, TRUE );
66+ }
67+ }
68+ ///--
69+
70+ ///--
71+ ++m_uFrameMotionCur;
72+ m_timerBlink.Update( app::GetTimeElapsedOnFrame() );
73+ ///--
74+}
75+
76+void CIMPL::ZeroTimer()
77+{
78+ m_uFrameMotionCur = 0;
79+ m_timerBlink.Reset();
80+}
81+
82+void CIMPL::StartBlink()
83+{
84+ m_timerBlink.Start();
85+}
86+
87+void CIMPL::StopBlink()
88+{
89+ m_timerBlink.Stop();
90+}
91+
92+void CIMPL::create_image( const TCHAR* const in_szPath )
93+{
94+ m_uTexIdx =
95+ m_pEntity->GetImageBoard()->CreateTexture( in_szPath, 64.0f, 64.0f );
96+}
97+
98+void CIMPL::create_se( const TCHAR* const in_szPath )
99+{
100+ g_pSound->LoadFile( in_szPath, 0, 4, &m_hSeBelch );
101+}
102+
103+#undef CIMPL
104+
105+
106+/***************************************************************************
107+ CMotionObject_BaseOne
108+****************************************************************************/
109+
110+#define CIMPL CMotionObject_BaseOne
111+
112+CIMPL::CIMPL( centity_base* in_pEntity, const TCHAR* const in_szPath, const TCHAR* const in_szPathSe )
113+:
114+CMotionObject_Base( in_pEntity )
115+{
116+ create_image( in_szPath );
117+
118+ if( in_szPathSe )
119+ {
120+ create_se( in_szPathSe );
121+ }
122+}
123+
124+void CIMPL::ExecOnFrame()
125+{
126+ m_pEntity->GetImageBoard()->SetTextureActive( m_uTexIdx );
127+
128+ CMotionObject_Base::ExecOnFrame();
129+}
130+
131+#undef CIMPL
132+
133+
134+/***************************************************************************
135+ CMotionObject_BaseTwo
136+****************************************************************************/
137+
138+#define CIMPL CMotionObject_BaseTwo
139+
140+CIMPL::CIMPL( centity_base* in_pEntity, const TCHAR* const in_szPath0, const TCHAR* const in_szPath1 )
141+:
142+ CMotionObject_BaseOne( in_pEntity, in_szPath0 )
143+
144+, m_uTexIdx2( 0 )
145+{
146+ create_image_2nd( in_szPath1 );
147+}
148+
149+void CIMPL::ExecOnFrame()
150+{
151+ cu32 uTexIdx ( ( ( GetTime() * 60 / 5 ) % 2 ) ? m_uTexIdx : m_uTexIdx2 );
152+ m_pEntity->GetImageBoard()->SetTextureActive( uTexIdx );
153+
154+ CMotionObject_Base::ExecOnFrame();
155+}
156+
157+void CIMPL::create_image_1st( const TCHAR* const in_szPath )
158+{
159+ create_image( in_szPath );
160+}
161+
162+void CIMPL::create_image_2nd( const TCHAR* const in_szPath )
163+{
164+ m_uTexIdx2 =
165+ m_pEntity->GetImageBoard()->CreateTexture( in_szPath, 64.0f, 64.0f );
166+}
167+
168+#undef CIMPL
--- trunk/program/src/module/motion/MotionObject_Base.h (nonexistent)
+++ trunk/program/src/module/motion/MotionObject_Base.h (revision 65)
@@ -0,0 +1,91 @@
1+/***************************************************************************/
2+/** @file MotionObject.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "core/sound/Sound_def.h"
10+
11+class centity_base;
12+
13+
14+class CMotionObject_Base
15+{
16+ ///--
17+public:
18+ enum eMotion
19+ {
20+ eMotion_Move,
21+ eMotion_Bite,
22+ eMotion_Belch,
23+ eMotion_Damaged,
24+
25+ eNof_Motion,
26+ eMotion_Invalid = U32_INVALID,
27+ };
28+ ///--
29+
30+ ///--
31+public:
32+ CMotionObject_Base( centity_base* in_pEntity );
33+ virtual ~CMotionObject_Base();
34+
35+ virtual void ExecOnFrame();
36+
37+ void ZeroTimer();
38+ u32 GetTime() { return m_uFrameMotionCur; }
39+
40+ void StartBlink();
41+ void StopBlink();
42+
43+protected:
44+ virtual void create_image( const TCHAR* const in_szPath );
45+ virtual void create_se( const TCHAR* const in_szPath );
46+ ///--
47+
48+ ///--
49+protected:
50+ centity_base *m_pEntity;
51+
52+ u32 m_uTexIdx;
53+
54+private:
55+ u32 m_uFrameMotionCur;
56+
57+ theSound m_hSeBelch;
58+
59+ CTimer m_timerBlink;
60+ ///--
61+};
62+
63+
64+class CMotionObject_BaseOne
65+:
66+public CMotionObject_Base
67+{
68+public:
69+ CMotionObject_BaseOne( centity_base* in_pEntity, const TCHAR* const in_szPath, const TCHAR* const in_szPathSe = NULL );
70+
71+ virtual void ExecOnFrame();
72+};
73+
74+
75+class CMotionObject_BaseTwo
76+:
77+public CMotionObject_BaseOne
78+{
79+public:
80+ CMotionObject_BaseTwo( centity_base* in_pEntity, const TCHAR* const in_szPath0, const TCHAR* const in_szPath1 );
81+
82+ virtual void ExecOnFrame();
83+
84+protected:
85+ void create_image_1st( const TCHAR* const in_szPath );
86+ void create_image_2nd( const TCHAR* const in_szPath );
87+
88+private:
89+ u32 m_uTexIdx2;
90+};
91+
--- trunk/program/src/entity/entity_def.h (revision 64)
+++ trunk/program/src/entity/entity_def.h (revision 65)
@@ -16,6 +16,8 @@
1616
1717 //-- enemy
1818 eEntity_Ghost,
19+ eEntity_KnightRed,
20+ eEntity_KnightBlue,
1921 eEntity_Gorem,
2022 //--
2123
--- trunk/program/src/entity/automata/automata_ghost.cpp (revision 64)
+++ trunk/program/src/entity/automata/automata_ghost.cpp (nonexistent)
@@ -1,151 +0,0 @@
1-/***************************************************************************/
2-/** @file automata_ghost.cpp
3- @brief
4- @author shom
5-****************************************************************************/
6-
7-#include "pch.h"
8-
9-#include "automata_ghost.h"
10-
11-#include "module/Module_Status.h"
12-#include "module/Module_Ai.h"
13-#include "module/ai/ai_ghost.h"
14-#include "module/component/ModuleComponent_Collision.h"
15-#include "module/motion/Ghost/motion_ghost.h"
16-
17-#include "core/app.h"
18-#include "core/graphic/2d/image_board.h"
19-
20-#include "service/service_collision.h"
21-#include "service/service_entity.h"
22-
23-
24-/***************************************************************************
25- automata_ghost
26-****************************************************************************/
27-
28-cautomata_ghost::cautomata_ghost()
29-:
30-m_e_state( eSTATE_NORMAL ),
31-m_time_damaged_elapsed(0)//,
32-{
33- ///--
34- //--
35- LoadModule( eModule_Collision );
36-
37- QUERY_MODULE( Collision )->SetSize( mm::get_v( 64.f, 64.f ) );
38- using namespace ModuleComponent_Collision_def;
39- const u32 attributes =
40- COLLI_ATTRIBUTE_ATTACK_TO_PLAYER | COLLI_ATTRIBUTE_WALL;
41- QUERY_MODULE( Collision )->SetAttributes( attributes );
42- //--
43-
44- //--
45- LoadModule( eModule_Status );
46- QUERY_MODULE( Status )->Initialize( 3 );
47- //--
48-
49- //--
50- LoadModuleAi( eModule_Ai, Module_Ai_def::eAi_Ghost );
51- //--
52-
53- //--
54- LoadModule( eModule_MotionGhost );
55- //--
56- ///--
57-}
58-
59-void cautomata_ghost::UpdatePreColli()
60-{
61- cautomata_base::UpdatePreColli();
62-
63- ///--
64- if( m_time_damaged_elapsed == 0 )
65- {
66- QUERY_MODULE_COMPO( Ai, AiGhost )->SetInDamage( FALSE );
67- }
68- else
69- {
70- QUERY_MODULE_COMPO( Ai, AiGhost )->SetInDamage( TRUE );
71-
72- cu32 time_elapsed = app::GetTimeElapsedOnFrame();
73- m_time_damaged_elapsed =
74- ( time_elapsed < m_time_damaged_elapsed ) ?
75- ( m_time_damaged_elapsed - time_elapsed ) : 0;
76-
77- if( m_time_damaged_elapsed == 0 )
78- {
79- m_e_state = eSTATE_NORMAL;
80-
81- GetImageBoard()->SetColor( COLOR_WHITE );
82- }
83- else
84- {
85- cu32 alpha =
86- ( m_time_damaged_elapsed / 100 % 2 == 0 ) ? 255 : 0;
87- GetImageBoard()->SetColor( set_color_argb( alpha ) );
88- }
89- }
90- ///--
91-
92- ///--
93- if( QUERY_MODULE( Status )->GetHpCur() == 0 )
94- {
95-#if 0
96- unload_module( QUERY_MODULE( Collision ) );
97-#else
98- g_p_service_collision->UnregisterCollision( QUERY_MODULE( Collision )->GetUid() );
99-#endif
100- g_p_service_entity->Destroy( GetUid() );
101- }
102- ///--
103-}
104-
105-void cautomata_ghost::UpdatePostColli()
106-{
107- ///--
108- //--
109- cu32 nof_entities = QUERY_MODULE( Collision )->GetNofColliInfo();
110-
111- for( u32 i=0; i<nof_entities; ++i )
112- {
113- using namespace ModuleComponent_Collision_def;
114- const b32 b_attribute_take_damage =
115- QUERY_MODULE( Collision )->IsIncludeAttributeCollidedWith(
116- i,
117- eCOLLI_ATTRIBUTE_ATTACK_TO_ENEMY
118- );
119- const b32 e_state_normal = ( m_e_state == eSTATE_NORMAL );
120-
121- if( b_attribute_take_damage && e_state_normal )
122- {
123- QUERY_MODULE( Status )->Damaged( 1 );
124-
125- m_e_state = eSTATE_DAMAGED;
126- m_time_damaged_elapsed = 1000;
127- }
128- }
129- //--
130-
131- //--
132- QUERY_MODULE( Collision )->ClearColliInfoList();
133- //--
134- ///--
135-
136- ///--
137- cu32 uState = QUERY_MODULE( Ai )->FIND_COMPO( AiGhost )->get_state();
138-
139- if( uState != 3/*eState_Belch*/ )
140- {
141- using namespace motion_ghost_def;
142- ct eMotion eMot =
143- ( m_e_state == eSTATE_DAMAGED ) ? eMotion_Damaged : eMotion_Move;
144- QUERY_MODULE( MotionGhost )->Request( eMot );
145- }
146- ///--
147-
148- cautomata_base::UpdatePostColli();
149-}
150-
151-
--- trunk/program/src/entity/automata/automata_ghost.h (revision 64)
+++ trunk/program/src/entity/automata/automata_ghost.h (nonexistent)
@@ -1,33 +0,0 @@
1-/***************************************************************************/
2-/** @file automata_ghost.h
3- @brief
4- @author shom
5-****************************************************************************/
6-
7-#pragma once
8-
9-#include "entity/automata/automata_base.h"
10-
11-class CModuleComponent_Collision;
12-class CModuleComponent_Hp;
13-class cai_ghost;
14-
15-class cautomata_ghost
16-:
17-public cautomata_base
18-{
19-public:
20- cautomata_ghost();
21-
22- virtual void UpdatePreColli();
23- virtual void UpdatePostColli();
24-
25-private:
26- enum eSTATE
27- {
28- eSTATE_NORMAL,
29- eSTATE_DAMAGED,
30- };
31- eSTATE m_e_state;
32- u32 m_time_damaged_elapsed;
33-};
--- trunk/program/src/entity/automata/Automata_Ghost.cpp (nonexistent)
+++ trunk/program/src/entity/automata/Automata_Ghost.cpp (revision 65)
@@ -0,0 +1,74 @@
1+/***************************************************************************/
2+/** @file Automata_Ghost.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "Automata_Ghost.h"
10+
11+#include "module/ai/ai_ghost.h"
12+#include "module/motion/Ghost/motion_ghost.h"
13+
14+#include "core/app.h"
15+
16+
17+/***************************************************************************
18+ CAutomata_Ghost
19+****************************************************************************/
20+
21+#define CIMPL CAutomata_Ghost
22+#define CSUPER CAutomata_EnemyBase
23+
24+CIMPL::CIMPL()
25+{
26+ //--
27+ LoadModule( eModule_MotionGhost );
28+ //--
29+
30+ //--
31+ LoadModuleAi( eModule_Ai, Module_Ai_def::eAi_Ghost );
32+ //--
33+}
34+
35+void CIMPL::UpdatePostColli()
36+{
37+ ///--
38+ if( m_uTimeDamagedElapsed == 0 )
39+ {
40+ QUERY_MODULE_COMPO( Ai, AiGhost )->SetInDamage( FALSE );
41+ }
42+ else
43+ {
44+ QUERY_MODULE_COMPO( Ai, AiGhost )->SetInDamage( TRUE );
45+
46+ cu32 uTimeElapsed ( app::GetTimeElapsedOnFrame() );
47+ m_uTimeDamagedElapsed =
48+ ( uTimeElapsed < m_uTimeDamagedElapsed ) ?
49+ ( m_uTimeDamagedElapsed - uTimeElapsed ) : 0;
50+
51+ if( m_uTimeDamagedElapsed == 0 )
52+ {
53+ m_eState = eSTATE_NORMAL;
54+ }
55+ }
56+ ///--
57+
58+ ///--
59+ cu32 uState ( QUERY_MODULE( Ai )->FIND_COMPO( AiGhost )->get_state() );
60+
61+ if( uState != CModuleComponent_AiGhost::eState_Belch )
62+ {
63+ using namespace motion_ghost_def;
64+ ct eMotion eMot =
65+ ( m_eState == eSTATE_DAMAGED ) ? eMotion_Damaged : eMotion_Move;
66+ QUERY_MODULE( MotionGhost )->Request( eMot );
67+ }
68+ ///--
69+
70+ CSUPER::UpdatePostColli();
71+}
72+
73+#undef CIMPL
74+#undef CSUPER
--- trunk/program/src/entity/automata/Automata_Knight.cpp (nonexistent)
+++ trunk/program/src/entity/automata/Automata_Knight.cpp (revision 65)
@@ -0,0 +1,59 @@
1+/***************************************************************************/
2+/** @file Automata_Knight.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "Automata_Knight.h"
10+
11+#include "module/motion/Knight/Motion_KnightBase.h"
12+#include "module/ai/Ai_Knight.h"
13+
14+#include "core/app.h"
15+
16+
17+/***************************************************************************
18+ CAutomata_Knight
19+****************************************************************************/
20+
21+#define CIMPL CAutomata_Knight
22+
23+CIMPL::CIMPL( b32 in_bRed )
24+{
25+ //--
26+ LoadModule( eModule_MotionKnightBase );
27+ QUERY_MODULE( MotionKnightBase )->Initialize( in_bRed );
28+ //--
29+
30+ //--
31+ LoadModuleAi( eModule_Ai, Module_Ai_def::eAi_Knight );
32+ //--
33+}
34+
35+void CIMPL::UpdatePostColli()
36+{
37+ ///--
38+ if( m_uTimeDamagedElapsed == 0 )
39+ {
40+ QUERY_MODULE_COMPO( Ai, Ai_Knight )->SetInDamage( FALSE );
41+ }
42+ else
43+ {
44+ QUERY_MODULE_COMPO( Ai, Ai_Knight )->SetInDamage( TRUE );
45+
46+ cu32 uTimeElapsed ( app::GetTimeElapsedOnFrame() );
47+ m_uTimeDamagedElapsed =
48+ ( uTimeElapsed < m_uTimeDamagedElapsed ) ?
49+ ( m_uTimeDamagedElapsed - uTimeElapsed ) : 0;
50+
51+ if( m_uTimeDamagedElapsed == 0 )
52+ {
53+ m_eState = eSTATE_NORMAL;
54+ }
55+ }
56+ ///--
57+}
58+
59+#undef CIMPL
--- trunk/program/src/entity/automata/Automata_EnemyBase.cpp (nonexistent)
+++ trunk/program/src/entity/automata/Automata_EnemyBase.cpp (revision 65)
@@ -0,0 +1,100 @@
1+/***************************************************************************/
2+/** @file automata_ghost.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "automata_ghost.h"
10+
11+#include "module/Module_Status.h"
12+#include "module/Module_Ai.h"
13+#include "module/component/ModuleComponent_Collision.h"
14+
15+#include "core/graphic/2d/image_board.h"
16+
17+#include "service/service_collision.h"
18+#include "service/service_entity.h"
19+
20+
21+/***************************************************************************
22+ CAutomata_EnemyBase
23+****************************************************************************/
24+
25+#define CIMPL CAutomata_EnemyBase
26+
27+CIMPL::CIMPL()
28+:
29+ m_eState( eSTATE_NORMAL )
30+, m_uTimeDamagedElapsed( 0 )
31+{
32+ ///--
33+ //--
34+ LoadModule( eModule_Collision );
35+
36+ QUERY_MODULE( Collision )->SetSize( mm::get_v( 64.0f, 64.0f ) );
37+ using namespace ModuleComponent_Collision_def;
38+ const u32 uAttr ( COLLI_ATTRIBUTE_ATTACK_TO_PLAYER | COLLI_ATTRIBUTE_WALL );
39+ QUERY_MODULE( Collision )->SetAttributes( uAttr );
40+ //--
41+
42+ //--
43+ LoadModule( eModule_Status );
44+ QUERY_MODULE( Status )->Initialize( 3 );
45+ //--
46+ ///--
47+}
48+
49+void CIMPL::UpdatePreColli()
50+{
51+ cautomata_base::UpdatePreColli();
52+
53+ ///--
54+ if( QUERY_MODULE( Status )->GetHpCur() == 0 )
55+ {
56+#if 0
57+ unload_module( QUERY_MODULE( Collision ) );
58+#else
59+ g_p_service_collision->UnregisterCollision( QUERY_MODULE( Collision )->GetUid() );
60+#endif
61+ g_p_service_entity->Destroy( GetUid() );
62+ }
63+ ///--
64+}
65+
66+void CIMPL::UpdatePostColli()
67+{
68+ ///--
69+ //--
70+ cu32 uNofEntities ( QUERY_MODULE( Collision )->GetNofColliInfo() );
71+
72+ for( u32 i=0; i<uNofEntities; ++i )
73+ {
74+ using namespace ModuleComponent_Collision_def;
75+ const b32 b_attribute_take_damage =
76+ QUERY_MODULE( Collision )->IsIncludeAttributeCollidedWith(
77+ i,
78+ eCOLLI_ATTRIBUTE_ATTACK_TO_ENEMY
79+ );
80+ const b32 e_state_normal = ( m_eState == eSTATE_NORMAL );
81+
82+ if( b_attribute_take_damage && e_state_normal )
83+ {
84+ QUERY_MODULE( Status )->Damaged( 1 );
85+
86+ m_eState = eSTATE_DAMAGED;
87+ m_uTimeDamagedElapsed = 1000;
88+ }
89+ }
90+ //--
91+
92+ //--
93+ QUERY_MODULE( Collision )->ClearColliInfoList();
94+ //--
95+ ///--
96+
97+ cautomata_base::UpdatePostColli();
98+}
99+
100+#undef CIMPL
--- trunk/program/src/entity/automata/Automata_Ghost.h (nonexistent)
+++ trunk/program/src/entity/automata/Automata_Ghost.h (revision 65)
@@ -0,0 +1,20 @@
1+/***************************************************************************/
2+/** @file Automata_Ghost.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "entity/automata/Automata_EnemyBase.h"
10+
11+
12+class CAutomata_Ghost
13+:
14+public CAutomata_EnemyBase
15+{
16+public:
17+ CAutomata_Ghost();
18+
19+ virtual void UpdatePostColli();
20+};
--- trunk/program/src/entity/automata/Automata_Knight.h (nonexistent)
+++ trunk/program/src/entity/automata/Automata_Knight.h (revision 65)
@@ -0,0 +1,20 @@
1+/***************************************************************************/
2+/** @file Automata_Knight.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "entity/automata/Automata_EnemyBase.h"
10+
11+
12+class CAutomata_Knight
13+:
14+public CAutomata_EnemyBase
15+{
16+public:
17+ CAutomata_Knight( b32 in_bRed );
18+
19+ virtual void UpdatePostColli();
20+};
--- trunk/program/src/entity/automata/Automata_EnemyBase.h (nonexistent)
+++ trunk/program/src/entity/automata/Automata_EnemyBase.h (revision 65)
@@ -0,0 +1,36 @@
1+/***************************************************************************/
2+/** @file automata_ghost.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "entity/automata/automata_base.h"
10+
11+class CModuleComponent_Collision;
12+class CModuleComponent_Hp;
13+class cai_ghost;
14+
15+class CAutomata_EnemyBase
16+:
17+public cautomata_base
18+{
19+protected:
20+ enum eSTATE
21+ {
22+ eSTATE_NORMAL,
23+ eSTATE_DAMAGED,
24+ };
25+
26+public:
27+ CAutomata_EnemyBase();
28+
29+ virtual void UpdatePreColli();
30+ virtual void UpdatePostColli();
31+
32+protected:
33+ eSTATE m_eState;
34+
35+ u32 m_uTimeDamagedElapsed;
36+};
Afficher sur ancien navigateur de dépôt.