Ejemplo n.º 1
0
 /// <summary>
 /// Convenience function to return the event arguments cast to our desired arguments type.
 /// If the type is incompatible, it will throw an exception with a descriptive error message.
 /// </summary>
 /// <typeparam name="T">Type to cast to.</typeparam>
 /// <param name="args">Arguments object to cast.</param>
 /// <returns></returns>
 protected T CastArguments <T>(GenericEventArguments args) where T : GenericEventArguments
 {
     try
     {
         return((T)args);
     }
     catch (InvalidCastException)
     {
         throw new ArgumentException("Given arguments were not of the correct type. Desired: " + typeof(T).Name + " Given: " + args.GetType().Name);
     }
 }
 /// <summary>
 /// The action performed when the event is triggered.
 /// </summary>
 /// <param name="sender">The sender infomation</param>
 /// <param name="args">Receives a generic event</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     AudioSource.PlayClipAtPoint(soundToPlay, GameObject.transform.position, volume);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Performs the action of spawning the designated object.
 /// </summary>
 /// <param name="sender">Object from which the event originated. Ignored.</param>
 /// <param name="args">Event arguments object. Ignored.</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     GameObject.Instantiate(objectToSpawn, GameObject.transform.position, Quaternion.identity);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Responds to any event to which we are hooked in.
 /// </summary>
 /// <param name="sender">The object from which the event originated.</param>
 /// <param name="args">The GenericEventArguments (or derivative thereof) raised with the event.</param>
 public abstract void HandleEvent(object sender, GenericEventArguments args);
 /// <summary>
 /// Handles the event to which we are responding. In this case, simply logs our
 /// stored message.
 /// </summary>
 /// <param name="sender">The sender from which the event originated.</param>
 /// <param name="args">Our arguments object. Ignored for this responder.</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     Debug.Log(message);
 }
 /// <summary>
 /// Handles the event to which we are responding. In this case, simply logs our
 /// stored message.
 /// </summary>
 /// <param name="sender">The sender from which the event originated.</param>
 /// <param name="args">Our arguments object. Ignored for this responder.</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     Debug.Log(message);
 }
 /// <summary>
 /// Performs the action of spawning the designated object.
 /// </summary>
 /// <param name="sender">Object from which the event originated. Ignored.</param>
 /// <param name="args">Event arguments object. Ignored.</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     GameObject.Instantiate(objectToSpawn, GameObject.transform.position, Quaternion.identity);
 }
 /// <summary>
 /// The action performed when the event is triggered.
 /// </summary>
 /// <param name="sender">The sender infomation</param>
 /// <param name="args">Receives a generic event</param>
 public override void HandleEvent(object sender, GenericEventArguments args)
 {
     AudioSource.PlayClipAtPoint(soundToPlay, GameObject.transform.position, volume);
 }