Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Dialogue_FS17/data/levels/events.oxw @ 11415

Last change on this file since 11415 was 11413, checked in by rrogge, 8 years ago

Buttons

  • Property svn:eol-style set to native
File size: 10.3 KB
RevLine 
[9985]1<!-- -->
[7648]2<LevelInfo
3  name = "Events showcase"
4  description = "Level to test and showcase events."
[9016]5  tags = "test, showcase"
6  screenshot = "eventsshowcase.png"
[7648]7/>
8
[6417]9<?lua
[7679]10  include("HUDTemplates3.oxo")
[6417]11  include("stats.oxo")
[7679]12  include("templates/spaceshipAssff.oxt")
13  include("templates/spaceshipH2.oxt")
14  include("templates/lodInformation.oxt")
[6417]15?>
16
[9016]17<Level>
[7163]18  <templates>
19    <Template link=lodtemplate_default />
20  </templates>
[8706]21  <?lua include("includes/notifications.oxi") ?>
[7163]22
[6417]23  <Scene
24   ambientlight = "0.5, 0.5, 0.5"
[9348]25   skybox       = "Orxonox/skyBoxBasic"
[6417]26  >
27    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
28
29    <SpawnPoint position="0,-100,0" lookat="0,0,0" roll=180 spawnclass=SpaceShip pawndesign=spaceshipassff />
30
31    <Billboard position=" 300,100,  0" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
32    <Billboard position=" 200,100,  0" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
33    <Billboard position=" 200,100,100" material="Examples/Flare" colour="1.0, 0.5, 0.0" />
34    <Billboard position=" 100,100,  0" material="Examples/Flare" colour="1.0, 1.0, 0.0" />
35    <Billboard position="   0,100,  0" material="Examples/Flare" colour="0.0, 1.0, 0.0" />
36    <Billboard position="-100,100,  0" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
37    <Billboard position="-100,100,100" material="Examples/Flare" colour="0.0, 1.0, 1.0" />
38    <Billboard position="-200,100,  0" material="Examples/Flare" colour="0.0, 0.0, 1.0" />
39    <Billboard position="-300,100,  0" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
40
41
42
43    <!--
44      Begin of the tutorial section.
45    -->
46
47
48
49    <!--
50      Note:
51      All following examples use only one subobject (in nested layouts). But of course you can add more
52      objects. They will all follow the same rules (depending on the example receive, send or pipe events).
53
54      Some examples address objects by name. Those methods always address ALL objects with this name, no
55      matter where they are in the XML-file (before or after the addressing object). Of course this also
56      works with all amounts of objects from zero to infinity. In the examples I used two objects each.
57    -->
58
[11413]59    <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true" />
[11401]60    <Backlight position="0,0,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>
[11413]61    <NextQuestion  question="Continue?" a1="yes" a2="no" >
62      <!-- <possibleQuestions>
63        <NextQuestion  question="Are you sure?" a1="yep let me continue" a2="no actually not" />
64        <NextQuestion  question="Why?" a1="Got a dentist's appointment" a2="this sucks" />
65      </possibleQuestions>     -->
[11394]66      <events>
67        <execute>
68           <EventListener event="test" />
69        </execute>
70      </events>
[11401]71    </NextQuestion>
[6417]72
73    <!-- red -->
74    <!--
75      Standard:
76      Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
77      Every fired event of the source is mapped to the "visibility" state of the listener.
78
79      This is a 1:1 mapping between event-listener and event-source.
80    -->
81    <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
82      <events>
83        <visibility>
84          <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
85        </visibility>
86      </events>
87    </Billboard>
88
89
90    <!-- orange -->
91    <!--
92      EventListener:
93      The EventListener object forwards all events from objects, whose names equal the "event" attribute
94      of the EventListener, to the enclosing object (Billboard).
95      In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
96
97      The EventListener provides an 1:n mapping between one listener and multiple event-sources.
98    -->
99    <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
100      <events>
101        <visibility>
102          <EventListener event="trigger2" />
103        </visibility>
104      </events>
105    </Billboard>
106    <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
107    <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
108
109
110    <!-- yellow -->
111    <!--
112      EventTarget:
113      The EventTarget object forwards the events, received from objects whithin the "events" subsection,
114      to all  objects whose names equal the "name" attribute.
115      In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
116      name "bb3".
117
118      The EventTarget provides an n:1 mapping between several listeners and one event-source.
119    -->
120    <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
121    <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
122    <EventTarget target="bb3">
123      <events>
124        <visibility>
125          <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
126        </visibility>
127      </events>
128    </EventTarget>
129
130
131    <!-- green -->
132    <!--
133      EventDispatcher:
134      The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
135      to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
136      doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
137      subsection.
138      In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
139      to the Billboard object.
140
141      The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
142    -->
143    <EventDispatcher>
144      <targets>
145        <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
146      </targets>
147      <events>
148        <visibility>
149          <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
150        </visibility>
151      </events>
152    </EventDispatcher>
153
154
155    <!-- turquoise -->
156    <!--
157      Combination:
158      By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
159      extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
160      In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
161
162      This combination allows an n:n mapping between event-listeners and event-sources.
163    -->
164    <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
165    <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
166    <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
167    <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
168    <EventDispatcher>
169      <targets>
170        <EventTarget target="bb5" />
171      </targets>
172      <events>
173        <visibility>
174          <EventListener event="trigger5" />
175        </visibility>
176      </events>
177    </EventDispatcher>
178
179
180    <!-- blue -->
181    <!--
182      Mainstate:
183      Apart from the standard states (like activity and visibility), each object can have a mainstate.
184      You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
185      supported states of the object (except states which need the originator as a second argument). If
186      the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
187      This allows you to hide the actually affected state in the event-listener, while the event-source
188      just sends events.
189      Note that this example is exactly like the standard case, but the event is sent to the main-state,
190      which in turn is set to "visibility".
191    -->
192    <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
193      <events>
194        <mainstate>
195          <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
196        </mainstate>
197      </events>
198    </Billboard>
199
200
201    <!-- violet -->
202    <!--
203      Event forwarding:
204      As a consequence of the mainstate, events can also be sent without any explicit declaration of
205      the targets state. This allows us to forward events from an event-source directly to a bunch of
206      event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
207      have to declare their main-state.
208      In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
209      This does the same like the example above, but instead of piping events backwards from the source
210      into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
211    -->
212    <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
213      <eventlisteners>
214        <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
215      </eventlisteners>
216    </DistanceTrigger>
217
218
219
220    <!--
221      End of the tutorial section.
222    -->
223
224
225
226    <!--
227      The following example shows again the red (standard layout) and the violet (event forwarding) example,
228      but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
229      (visibility) in the other examples.
230    -->
231    <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
232    <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
233    <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
234      <events>
235        <spawn>
236          <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
237        </spawn>
238      </events>
239    </ParticleSpawner>
240    <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
241      <eventlisteners>
242        <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
243      </eventlisteners>
244    </DistanceTrigger>
245
246  </Scene>
247</Level>
Note: See TracBrowser for help on using the repository browser.