예제 #1
0
 public static void RaiseOnObjectEnteredPortal(PortalInstance portal, WarppableObject obj)
 {
     if (ObjectEnteredPortal != null)
     {
         ObjectEnteredPortal.Invoke(portal, obj);
     }
 }
예제 #2
0
 public static void RaiseOnObjectExitedPortal(PortalInstance portal, WarppableObject obj, bool crossedThePortal)
 {
     if (ObjectExitedPortal != null)
     {
         ObjectExitedPortal.Invoke(portal, obj, crossedThePortal);
     }
 }
예제 #3
0
        private void OnTriggerExit(Collider other)
        {
            Debug.Log("OnTriggerEnd");
            if (other == null)
            {
                return;
            }
            WarppableObject warppableObject = other.GetComponent <WarppableObject>();

            if (warppableObject == null)
            {
                return;
            }

            if (!_warppableObjectsInside.Contains(warppableObject))
            {
                return;
            }

            bool exitedFromBack = !IsWarppableObjectInPositionZ(warppableObject);

            _warppableObjectsInside.Remove(warppableObject);

            Events.RaiseOnObjectExitedPortal(this, warppableObject, exitedFromBack);
        }
예제 #4
0
        private void OnTriggerEnter(Collider other)
        {
            Debug.Log("OnTriggerEnter");
            if (other == null)
            {
                return;
            }
            WarppableObject warppableObject = other.GetComponent <WarppableObject>();

            if (warppableObject == null)
            {
                return;
            }

            if (_warppableObjectsInside.Contains(warppableObject))
            {
                return;
            }

            if (!IsWarppableObjectInPositionZ(warppableObject))
            {
                return;                                                 // the object did not enter from forward
            }
            _warppableObjectsInside.Add(warppableObject);
            Events.RaiseOnObjectEnteredPortal(this, warppableObject);
        }
예제 #5
0
        public PositionAndRotation GetWarpableObjectLocalTransforms(WarppableObject obj)
        {
            PositionAndRotation posAndRot = new PositionAndRotation();

            posAndRot.lPosition = _axis.InverseTransformPoint(obj.transform.position);         // Getting the position in the axis of the portal
            posAndRot.lRotation = Quaternion.Inverse(_axis.rotation) * obj.transform.rotation; // finding local rotation - we are taking global rotaion and substracting it by Axis rotation.
                                                                                               // in rotations, substraction is inverse
            return(posAndRot);
        }
예제 #6
0
 private WarpableObjectSet GetWormHoleSet(WarppableObject obj)
 {
     foreach (var set in warpableObjectSets)
     {
         if (set._warpObject == obj)
         {
             return(set);
         }
     }
     return(null);
 }
예제 #7
0
        private void OnObjectEnterWarp(PortalInstance portal, WarppableObject warppableObj)
        {
            Debug.Log("OnObjectEnterWarp 1");
            Utils.Assert(portal != null && warppableObj != null);
            if (!portalSet.IsWormHoleOpen())
            {
                return;
            }
            if (GetWormHoleSet(warppableObj) != null)
            {
                return;
            }

            warppableObj.CloneObject();
            warpableObjectSets.Add(new WarpableObjectSet(portal, portalSet.GetOtherPortal(portal), warppableObj));
        }
예제 #8
0
        private void OnObjectExitedWarp(PortalInstance portal, WarppableObject warppableObj, bool crossedTheWormHole)
        {
            Utils.Assert(portal != null && warppableObj != null);
            if (!portalSet.IsWormHoleOpen())
            {
                return;
            }

            WarpableObjectSet warpableObjectSet = GetWormHoleSet(warppableObj);

            if (warpableObjectSet == null)
            {
                Debug.LogWarning("Check this!"); return;
            }

            if (crossedTheWormHole)
            {
                warpableObjectSet._warpObject.SwapWithClone();
            }
            warpableObjectSet._warpObject.DestroyClone();

            warpableObjectSets.Remove(warpableObjectSet);
        }
 public void Start()
 {
     obj = GetComponent <WarppableObject>();
 }
예제 #10
0
 public WarpableObjectSet(PortalInstance portalA, PortalInstance portalB, WarppableObject warpableObj)
 {
     _portalA    = portalA;
     _portalB    = portalB;
     _warpObject = warpableObj;
 }
예제 #11
0
 public bool IsWarppableObjectInPositionZ(WarppableObject obj)
 {
     return(GetWarpableObjectLocalTransforms(obj).lPosition.z > 0);
 }