Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/HUD_HS16/data/levels/events.oxw @ 12076

Last change on this file since 12076 was 11502, checked in by patricwi, 7 years ago

updated HUD by merging trunk into it

  • Property svn:eol-style set to native
File size: 11.9 KB
Line 
1<!-- -->
2<LevelInfo
3  name = "Events showcase"
4  description = "Level to test and showcase events."
5  tags = "test, showcase"
6  screenshot = "eventsshowcase.png"
7/>
8
9<?lua
10  include("HUDTemplates3.oxo")
11  include("stats.oxo")
12  include("templates/spaceshipAssff.oxt")
13  include("templates/spaceshipH2.oxt")
14  include("templates/lodInformation.oxt")
15?>
16
17<Level>
18  <templates>
19    <Template link=lodtemplate_default />
20  </templates>
21  <?lua include("includes/notifications.oxi") ?>
22
23  <Scene
24   ambientlight = "0.5, 0.5, 0.5"
25   skybox       = "Orxonox/skyBoxBasic"
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
59    <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true" />
60    <Backlight position="0,0,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,1"/>
61   
62    <NextQuestion  question="Continue?" a1="yes" a2="no" >
63     <possibleQuestions>
64        <NextQuestion  question="Are you sure?" a1="yep let me continue" a2="no actually not" />
65        <NextQuestion  question="Why?" a1="Got a dentist's appointment" a2="this sucks" >
66        <possibleQuestions>
67          <NextQuestion  question="Are your teeth that bad mate?" a1="yep" a2="leave me alone godammit" />
68          <NextQuestion  question="You suck" a1="..." a2="Im going now okay" />
69        </possibleQuestions>
70      </NextQuestion>
71      </possibleQuestions>   
72      <events>
73        <execute>
74           <EventListener event="test" />
75        </execute>
76      </events>
77    </NextQuestion>
78
79    <DistanceTrigger name="test1" position="100,300,0" target="Pawn" distance=25 stayActive="true" />
80    <Backlight position="100,300,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,1,1"/>
81   
82    <NextQuestion  question="Wazzp bud?" a1="yes" a2="no" >
83     <possibleQuestions>
84        <NextQuestion  question="Do you like fish" a1="yep let me continue" a2="no actually not" />
85        <NextQuestion  question="Whats your favourite pastime?" a1="Got a dentist's appointment" a2="this sucks" >
86        <possibleQuestions>
87          <NextQuestion  question="Whatever?" a1="yep" a2="leave me alone godammit" />
88          <NextQuestion  question="Turtles then?" a1="..." a2="Im going now okay" />
89        </possibleQuestions>
90      </NextQuestion>
91      </possibleQuestions>   
92      <events>
93        <execute>
94           <EventListener event="test1" />
95        </execute>
96      </events>
97    </NextQuestion>
98
99
100    <!-- red -->
101    <!--
102      Standard:
103      Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
104      Every fired event of the source is mapped to the "visibility" state of the listener.
105
106      This is a 1:1 mapping between event-listener and event-source.
107    -->
108    <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
109      <events>
110        <visibility>
111          <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
112        </visibility>
113      </events>
114    </Billboard>
115
116    <!-- HELLO THERE ................................................................ ITS ME -->
117    <DistanceTrigger name="test" position="0,0,0" target="Pawn" distance=25 stayActive="true"/>
118    <Backlight position="0,0,0" visible=true frequency=0.6 amplitude=3 material="Flares/lensflare" colour="1,0,0"/>
119    <DDDialogue string="Hello World3" >
120      <events>
121        <execute>
122           <EventListener event="test" />
123        </execute>
124      </events>
125    </DDDialogue>
126
127    <!-- orange -->
128    <!--
129      EventListener:
130      The EventListener object forwards all events from objects, whose names equal the "event" attribute
131      of the EventListener, to the enclosing object (Billboard).
132      In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
133
134      The EventListener provides an 1:n mapping between one listener and multiple event-sources.
135    -->
136    <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
137      <events>
138        <visibility>
139          <EventListener event="trigger2" />
140        </visibility>
141      </events>
142    </Billboard>
143    <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
144    <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
145
146
147    <!-- yellow -->
148    <!--
149      EventTarget:
150      The EventTarget object forwards the events, received from objects whithin the "events" subsection,
151      to all  objects whose names equal the "name" attribute.
152      In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
153      name "bb3".
154
155      The EventTarget provides an n:1 mapping between several listeners and one event-source.
156    -->
157    <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
158    <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
159    <EventTarget target="bb3">
160      <events>
161        <visibility>
162          <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
163        </visibility>
164      </events>
165    </EventTarget>
166
167
168    <!-- green -->
169    <!--
170      EventDispatcher:
171      The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
172      to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
173      doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
174      subsection.
175      In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
176      to the Billboard object.
177
178      The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
179    -->
180    <EventDispatcher>
181      <targets>
182        <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
183      </targets>
184      <events>
185        <visibility>
186          <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
187        </visibility>
188      </events>
189    </EventDispatcher>
190
191
192    <!-- turquoise -->
193    <!--
194      Combination:
195      By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
196      extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
197      In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
198
199      This combination allows an n:n mapping between event-listeners and event-sources.
200    -->
201    <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
202    <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
203    <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
204    <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
205    <EventDispatcher>
206      <targets>
207        <EventTarget target="bb5" />
208      </targets>
209      <events>
210        <visibility>
211          <EventListener event="trigger5" />
212        </visibility>
213      </events>
214    </EventDispatcher>
215
216
217    <!-- blue -->
218    <!--
219      Mainstate:
220      Apart from the standard states (like activity and visibility), each object can have a mainstate.
221      You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
222      supported states of the object (except states which need the originator as a second argument). If
223      the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
224      This allows you to hide the actually affected state in the event-listener, while the event-source
225      just sends events.
226      Note that this example is exactly like the standard case, but the event is sent to the main-state,
227      which in turn is set to "visibility".
228    -->
229    <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
230      <events>
231        <mainstate>
232          <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
233        </mainstate>
234      </events>
235    </Billboard>
236
237
238    <!-- violet -->
239    <!--
240      Event forwarding:
241      As a consequence of the mainstate, events can also be sent without any explicit declaration of
242      the targets state. This allows us to forward events from an event-source directly to a bunch of
243      event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
244      have to declare their main-state.
245      In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
246      This does the same like the example above, but instead of piping events backwards from the source
247      into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
248    -->
249    <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
250      <eventlisteners>
251        <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
252      </eventlisteners>
253    </DistanceTrigger>
254
255
256
257    <!--
258      End of the tutorial section.
259    -->
260
261
262
263    <!--
264      The following example shows again the red (standard layout) and the violet (event forwarding) example,
265      but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
266      (visibility) in the other examples.
267    -->
268    <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
269    <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
270    <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
271      <events>
272        <spawn>
273          <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
274        </spawn>
275      </events>
276    </ParticleSpawner>
277    <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
278      <eventlisteners>
279        <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
280      </eventlisteners>
281    </DistanceTrigger>
282
283  </Scene>
284</Level>
Note: See TracBrowser for help on using the repository browser.