Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/levels/events.oxw @ 10139

Last change on this file since 10139 was 9985, checked in by jo, 11 years ago

Ending missionOne.

  • Property svn:eol-style set to native
File size: 9.6 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
60    <!-- red -->
61    <!--
62      Standard:
63      Direct event-connection between an event-listener (Billboard) and an event source (DistanceTrigger).
64      Every fired event of the source is mapped to the "visibility" state of the listener.
65
66      This is a 1:1 mapping between event-listener and event-source.
67    -->
68    <Billboard position="300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
69      <events>
70        <visibility>
71          <DistanceTrigger position="300,100,0" distance=25 target="ControllableEntity" />
72        </visibility>
73      </events>
74    </Billboard>
75
76
77    <!-- orange -->
78    <!--
79      EventListener:
80      The EventListener object forwards all events from objects, whose names equal the "event" attribute
81      of the EventListener, to the enclosing object (Billboard).
82      In this case, both triggers have the name "trigger2" and thus both triggers send events to the Billboard.
83
84      The EventListener provides an 1:n mapping between one listener and multiple event-sources.
85    -->
86    <Billboard position="200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0>
87      <events>
88        <visibility>
89          <EventListener event="trigger2" />
90        </visibility>
91      </events>
92    </Billboard>
93    <DistanceTrigger name="trigger2" position="200,100,0" distance=25 target="ControllableEntity" />
94    <DistanceTrigger name="trigger2" position="200,100,100" distance=25 target="ControllableEntity" />
95
96
97    <!-- yellow -->
98    <!--
99      EventTarget:
100      The EventTarget object forwards the events, received from objects whithin the "events" subsection,
101      to all  objects whose names equal the "name" attribute.
102      In this case, the EventTarget forwards the event from the DistanceTrigger to all listeners with
103      name "bb3".
104
105      The EventTarget provides an n:1 mapping between several listeners and one event-source.
106    -->
107    <Billboard name="bb3" position="100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
108    <Billboard name="bb3" position="100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
109    <EventTarget target="bb3">
110      <events>
111        <visibility>
112          <DistanceTrigger position="100,100,0" distance=25 target="ControllableEntity" />
113        </visibility>
114      </events>
115    </EventTarget>
116
117
118    <!-- green -->
119    <!--
120      EventDispatcher:
121      The EventDispatcher catches events from objects in its "events" subsection. Those events are forwared
122      to all objects in the "targets" subsection. The EventDispatcher resembles the EventTarget, but
123      doesn't address objects with the "name" attribute. It rather places them directly inside the "targets"
124      subsection.
125      In this case, the EventDispatcher receives events from the DistanceTrigger and forwards those events
126      to the Billboard object.
127
128      The EventDispatcher provides an n:1 mapping between several targets (listeners) and one event source.
129    -->
130    <EventDispatcher>
131      <targets>
132        <Billboard position="0,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
133      </targets>
134      <events>
135        <visibility>
136          <DistanceTrigger position="0,100,0" distance=25 target="ControllableEntity" />
137        </visibility>
138      </events>
139    </EventDispatcher>
140
141
142    <!-- turquoise -->
143    <!--
144      Combination:
145      By combinding the above three classes, namely EventDispatcher, EventTarget and EventListener, you can
146      extract the event logic completely from the actual objects (Billboards and DistanceTriggers).
147      In this case, both triggers (whith names "trigger5") send events to both Billboards (with names "bb5").
148
149      This combination allows an n:n mapping between event-listeners and event-sources.
150    -->
151    <Billboard name="bb5" position="-100,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
152    <Billboard name="bb5" position="-100,150,100" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 />
153    <DistanceTrigger name="trigger5" position="-100,100,0" distance=25 target="ControllableEntity" />
154    <DistanceTrigger name="trigger5" position="-100,100,100" distance=25 target="ControllableEntity" />
155    <EventDispatcher>
156      <targets>
157        <EventTarget target="bb5" />
158      </targets>
159      <events>
160        <visibility>
161          <EventListener event="trigger5" />
162        </visibility>
163      </events>
164    </EventDispatcher>
165
166
167    <!-- blue -->
168    <!--
169      Mainstate:
170      Apart from the standard states (like activity and visibility), each object can have a mainstate.
171      You can define the mainstate with an xml-attribute: mainstate="state". "state" must be one of the
172      supported states of the object (except states which need the originator as a second argument). If
173      the mainstate is set (by default that's not the case), you can send events to the "mainstate" state.
174      This allows you to hide the actually affected state in the event-listener, while the event-source
175      just sends events.
176      Note that this example is exactly like the standard case, but the event is sent to the main-state,
177      which in turn is set to "visibility".
178    -->
179    <Billboard position="-200,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility">
180      <events>
181        <mainstate>
182          <DistanceTrigger position="-200,100,0" distance=25 target="ControllableEntity" />
183        </mainstate>
184      </events>
185    </Billboard>
186
187
188    <!-- violet -->
189    <!--
190      Event forwarding:
191      As a consequence of the mainstate, events can also be sent without any explicit declaration of
192      the targets state. This allows us to forward events from an event-source directly to a bunch of
193      event-listeners. The events are automatically piped into the mainstate. Therefore the listeners
194      have to declare their main-state.
195      In this example, the DistanceTrigger forwards the events to the Billboards main-state (visibility).
196      This does the same like the example above, but instead of piping events backwards from the source
197      into the mainstate of the listener, we're forwarding the event implicitly to the mainstate.
198    -->
199    <DistanceTrigger position="-300,100,0" distance=25 target="ControllableEntity">
200      <eventlisteners>
201        <Billboard position="-300,150,0" material="Examples/Flare" colour="1.0, 1.0, 1.0" visible=0 mainstate="visibility" />
202      </eventlisteners>
203    </DistanceTrigger>
204
205
206
207    <!--
208      End of the tutorial section.
209    -->
210
211
212
213    <!--
214      The following example shows again the red (standard layout) and the violet (event forwarding) example,
215      but this time with a memoryless state (spawn) from the ParticleSpawner instead of the boolean state
216      (visibility) in the other examples.
217    -->
218    <Billboard position=" 300,100,300" material="Examples/Flare" colour="1.0, 0.0, 0.0" />
219    <Billboard position="-300,100,300" material="Examples/Flare" colour="1.0, 0.0, 1.0" />
220    <ParticleSpawner position="300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0>
221      <events>
222        <spawn>
223          <DistanceTrigger position="300,100,300" distance=25 target="ControllableEntity" />
224        </spawn>
225      </events>
226    </ParticleSpawner>
227    <DistanceTrigger position="-300,100,300" distance=25 target="ControllableEntity">
228      <eventlisteners>
229        <ParticleSpawner position="-300,150,300" source="Orxonox/BigExplosion1part1" lifetime=3.0 autostart=0 mainstate="spawn" />
230      </eventlisteners>
231    </DistanceTrigger>
232
233  </Scene>
234</Level>
Note: See TracBrowser for help on using the repository browser.