Game Development Reference
In-Depth Information
public override void Process()
{
// if we don't have targets return
if (TargetDroids == null || TargetDroids.Length == 0)
return;
// If the alarm has already been triggered
// then there's no point shouting
if (alarmTriggered)
return;
//Placeholder to add some snazzy logic to locate triggered
//alarms, just returns none for now.
TriggeredCameraLocation = Vector3.zero;
// for each droid invoke our custom event if the alarm
// is triggered
if (TriggeredCameraLocation != Vector3.zero)
{
alarmTriggered = true;
var eventdata = new AlarmEventData(eventSystem,
TriggeredCameraLocation);
foreach (var droid in TargetDroids)
{
ExecuteEvents.Execute(droid, eventdata,
MyAlarmTriggerEvents.AlarmEventHandler);
}
}
}
}
The only important part of this script is the Process method, as this is called
by the BaseInputModule class when it is this script's turn to run (called by the
EventSystem ). Within this script you need to go through whatever selection logic
you need to use to identify those GameObjects that need notifying (in this case, the
set of droids on our level looking for trouble), then for each droid we are calling
Executing the event on that GameObject if it exists.
Granted, this is a very simplistic example, there are more complicated
scenarios you can implement, most of which are implemented in the
Input Modules in the UI source. Jump down to the Getting access to the
source section and browse through the source if you dare!
 
Search WWH ::




Custom Search