Game Development Reference
In-Depth Information
51.
foreach(TriggerMessage message
52.
in newState.messagesToSend){
53.
//Get the receiver of the message
54.
GameObject sendTo = message.messageReceiver;
55.
//Get the name of the message
56.
string messageName = message.messageName;
57.
//Send the message
58.
sendTo.SendMessage(messageName);
59.
}
60.
61.
//Finally, record switching time
62.
lastSwitchTime = Time.time;
63.
return true;
64.
} else {
65.
return false;
66.
}
}
67.
68.}
69.
70.
//Small structure to represent state
71.
[System.Serializable]
72.
public class TriggerState{
73.
publicfloatrestTime;
74.
public TriggerMessage[] messagesToSend;
75.} 76.
77.
//A structure to represent messages sent by trigger
78.
[System.Serializable]
79.
public class TriggerMessage{
80.
public GameObject messageReceiver;
81.
public string messageName;
82. }
Search WWH ::




Custom Search