RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
cenemytarget.cpp
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #include <irrklang/irrKlang.h>
32 #include "cengine/csoundplayer.h"
33 #include "shootingrange/cbullet.h"
35 
36 //-----------------------------------------------------------------------------
37 
39  setDelayTime(0.0f);
40  setExposureTime(1.0f);
41  setSlideLength(0.0f);
42  setDoSlide(false);
43  m_slideSoundId = -1;
44 }
45 
46 //-----------------------------------------------------------------------------
47 
48 float CEnemyTarget::delayTime() const {
49  return m_delayTime;
50 }
51 
52 //-----------------------------------------------------------------------------
53 
54 void CEnemyTarget::setDelayTime(float delayTime) {
56 }
57 
58 //-----------------------------------------------------------------------------
59 
61  return m_exposureTime;
62 }
63 
64 //-----------------------------------------------------------------------------
65 
66 void CEnemyTarget::setExposureTime(float exposureTime) {
68 }
69 
70 //-----------------------------------------------------------------------------
71 
73  return m_slideLength;
74 }
75 
76 //-----------------------------------------------------------------------------
77 
78 void CEnemyTarget::setSlideLength(float slideLength) {
80 }
81 
82 //-----------------------------------------------------------------------------
83 
84 bool CEnemyTarget::doSlide() const {
85  return m_doSlide;
86 }
87 
88 //-----------------------------------------------------------------------------
89 
90 void CEnemyTarget::setDoSlide(bool doSlide) {
92 }
93 
94 //-----------------------------------------------------------------------------
95 
97  return m_launcherHeight;
98 }
99 
100 //-----------------------------------------------------------------------------
101 
102 void CEnemyTarget::setLauncherHeight(float launcherHeight) {
104 }
105 
106 //-----------------------------------------------------------------------------
107 
109  if(doSlide()) {
110  m_transform.moveX(-slideLength() / 2.0f);
111  }
112 
113  bulletProperties.setActivationState(CBulletProperties::ActivationState::DisableDeactivation);
114 
115  CActionInterval* delay_action = new CDelayTime(delayTime());
116  CActionInterval* go_up = new CMoveBy(0.2f, btVector3(0, size().y(), 0.0f));
117  connect(go_up, SIGNAL(onActionStart(CAction*)), this, SLOT(onGoUpActionStart(CAction*)));
118 
119  CActionInterval* slide = new CMoveBy(exposureTime(), btVector3(slideLength(), 0, 0.0f));
120 
121  if(doSlide()) {
122  connect(slide, SIGNAL(onActionStart(CAction*)), this, SLOT(onSlideActionStart(CAction*)));
123  }
124 
125  CActionInterval* go_down = go_up->reverse();
126  connect(go_down, SIGNAL(onActionStart(CAction*)), this, SLOT(onGoDownActionStart(CAction*)));
127 
128  CFiniteTimeAction* sequence = CSequence::actions(delay_action, go_up, slide, go_down, NULL);
129  connect(sequence, SIGNAL(onActionDone(CAction*)), this, SLOT(onSequenceDone(CAction*)));
130 
131  runAction(sequence);
132 
133  SAFE_RELEASE(delay_action);
134  SAFE_RELEASE(go_up);
135  SAFE_RELEASE(slide);
136  SAFE_RELEASE(go_down);
137 }
138 
139 //-----------------------------------------------------------------------------
140 
141 void CEnemyTarget::onGoUpActionStart(CAction* action) {
142  deployIntoDynamicsWorld();
143  CSOUNDPLAYER->play2D("enter.wav");
144 }
145 
146 //-----------------------------------------------------------------------------
147 
149  if(doSlide() && m_slideSoundId > -1) {
150  irrklang::ISound* sound = CSOUNDPLAYER->getISound(m_slideSoundId);
151  sound->stop();
152  sound->drop();
153  m_slideSoundId = -1;
154  }
155 }
156 
157 //-----------------------------------------------------------------------------
158 
159 void CEnemyTarget::onGoDownActionStart(CAction* action) {
160  stopAllSounds();
161  CSOUNDPLAYER->play2D("exit.wav");
162 }
163 
164 //-----------------------------------------------------------------------------
165 
166 void CEnemyTarget::onSequenceDone(CAction* action) {
167  remove();
168 }
169 
170 //-----------------------------------------------------------------------------
171 
172 void CEnemyTarget::onSlideActionStart(CAction* action) {
173  m_slideSoundId = CSOUNDPLAYER->play2D("slide.wav", true, false, true);
174 }
175 
176 //-----------------------------------------------------------------------------
177 
179  stopAllSounds();
180 }
181 
182 //-----------------------------------------------------------------------------
183 
185  CSOUNDPLAYER->play2D("bombexplosion.wav");
186  remove();
187 }
void setSlideLength(float slide_length)
Main header file of the irrKlang sound library, the only file needed to include.
#define CSOUNDPLAYER
Definition: csoundplayer.h:38
Transform m_transform
Definition: clnode.h:77
virtual bool drop()=0
Drops the object. Decrements the reference counter by one.
float m_exposureTime
Definition: cenemytarget.h:63
float launcherHeight() const
virtual void launch()
void setDelayTime(float delay_time)
float delayTime() const
Represents a sound which is currently played.
Definition: ik_ISound.h:24
void moveX(float dx, TransformMode transform_mode=GLOBAL)
Definition: transform.cpp:242
float m_slideLength
Definition: cenemytarget.h:64
void setDoSlide(bool do_slide)
const btVector3 & size() const
Definition: clnode.cpp:182
Definition: cenemy.h:35
bool doSlide() const
virtual CActionInterval * reverse()
#define SAFE_RELEASE(x)
Definition: cobject.h:36
void setLauncherHeight(float launcher_height)
float m_delayTime
Definition: cenemytarget.h:62
virtual void stopAllSounds()
float exposureTime() const
int m_slideSoundId
Definition: cenemytarget.h:67
virtual void aboutToBeRemoved()
static CFiniteTimeAction * actions(CFiniteTimeAction *action,...)
float slideLength() const
virtual void damageReceived(int damage)
virtual void stop()=0
Will stop the sound and free its resources.
float m_launcherHeight
Definition: cenemytarget.h:65
void setExposureTime(float exposure_time)