示例#1
0
    /// <summary>
    /// Checks if the surface currently collided with is a moving platform
    /// </summary>
    /// <param name="collision">The collision information of the raycast colliding with an object</param>
    private void CheckMovingPlatform(RaycastHit2D collision)
    {
        // if the object has a script inheriting from the PlatformObservable interface then register this as an observer.
        PlatformObservable observable = collision.collider.GetComponentInParent <PlatformObservable>();

        if (observable != null)
        {
            RegisterObservable(observable);
        }
    }
示例#2
0
 /// <summary>
 /// Removes the currently collided with PlatformObservable, as well as removing this PlatformObserver object from the PlatformObservable.
 /// </summary>
 /// <param name="observable">The PlatformObservable instance to remove.</param>
 public void DeregisterObservable(PlatformObservable observable)
 {
     observable.DeregisterObserver(this);
     platformObservable = null;
 }
示例#3
0
 /// <summary>
 /// Registers the currently collided with PlatformObservable as the platformObservable field, as well as registering
 /// This PlatformObserver object with the PlatformObservable.
 /// </summary>
 /// <param name="observable">The PlatformObservable instance to register</param>
 public void RegisterObservable(PlatformObservable observable)
 {
     observable.RegisterObserver(this);
     platformObservable = observable;
 }