Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11431 was 11395, checked in by patricwi, 8 years ago

dialogue classes added

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