Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11394 was 11394, checked in by rrogge, 7 years ago

DialogueManager not loadable

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