Esempio n. 1
0
 /// <summary>
 /// 离开
 /// </summary>
 public virtual void OnDistanceExit(DistanceInteraction distanceInteraction)
 {
     if (OnExit != null)
     {
         OnExit.Invoke(distanceInteraction);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 带状态释放
 /// </summary>
 /// <param name="distanceInteraction"></param>
 /// <param name="status"></param>
 public virtual void OnDistanceRelease(DistanceInteraction distanceInteraction, InteractionReleaseStatus status)
 {
     if (OnStatusRelease != null)
     {
         OnStatusRelease.Invoke(distanceInteraction, status);
     }
 }
        /// <summary>
        /// 移入
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        public static void OnEnter(DistanceInteraction send, DistanceInteraction receive)
        {
            //if (send.distanceData.IsOnly && send.OnlyDistance != receive) return;

            //在次之前,还需要判断一次,否则一直执行循环查找,会很费资源,这么处理不恰当
            if (send.OnlyDistance != null || !receive.OnInteractionCheck())
            {
                return;
            }

            //Debug.Log("进来-发送端:" + send.Interaction.FeaturesObjectController + " 接收端:" + receive.Interaction.FeaturesObjectController);

            InteractionDistanceInfo distanceInfo;

            if (IsContains(send, receive, out distanceInfo))
            {
                distanceInfo.SetDistanceStatus(DistanceStatus.Enter);
            }
            else
            {
                distanceInfo = new InteractionDistanceInfo(send, receive, DistanceStatus.Enter);
                DistanceInfos.Add(distanceInfo);
            }

            receive.OnInteractionEnter(send);
            send.OnInteractionEnter(receive);
        }
        /// <summary>
        /// 交互离开处理
        /// </summary>
        /// <param name="interaction">Interaction.</param>
        public void OnInteractionExit(DistanceInteraction interaction)
        {
            switch (distanceData.interactionType)
            {
            case InteractionType.Receive:
            case InteractionType.All:
            case InteractionType.Pour:

                if (distanceData.IsOnly)
                {
                    OnlyDistance = null;
                }
                else
                {
                    RemoveReceiveDistancing(interaction);
                    RemoveReceiveDistanced(interaction);
                }

                OnDistanceExit(interaction);

                break;

            case InteractionType.Send:

                OnlyDistance = null;

                OnDistanceExit(interaction);

                break;
            }
        }
        /// <summary>
        /// 往接收端中添加发送端信息
        /// </summary>
        /// <param name="send"></param>
        public void AddReceiveDistanced(DistanceInteraction send)
        {
            if (Distanced == null)
            {
                Distanced = new List <DistanceInteraction>();
            }

            //移除正在交互的
            if (Distancing.Contains(send))
            {
                Distancing.Remove(send);
            }

            if (Distanced.Contains(send))
            {
                return;
            }

            Distanced.Add(send);

            if (distanceData.maxCount == -1)
            {
                return;
            }

            distanceData.maxCount--;
        }
Esempio n. 6
0
 /// <summary>
 /// 停留
 /// </summary>
 public virtual void OnDistanceStay(DistanceInteraction distanceInteraction)
 {
     if (OnStay != null)
     {
         OnStay.Invoke(distanceInteraction);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 释放
 /// </summary>
 public virtual void OnDistanceRelesae(DistanceInteraction distanceInteraction)
 {
     if (OnRelease != null)
     {
         OnRelease.Invoke(distanceInteraction);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 释放
 /// </summary>
 public virtual void OnDistanceRelesae(DistanceInteraction distanceInteraction)
 {
     if (ActiveParent && interactionParent != null)
     {
         interactionParent.OnOpen(this, distanceInteraction);
     }
     if (ActiveShadow && interactionShadow != null)
     {
         if (AutoDetection)
         {
             if (!HasDeteced)
             {
                 HasDeteced = true;
             }
             else
             {
                 interactionShadow.OnClose(this, distanceInteraction);
             }
         }
         else
         {
             interactionShadow.OnClose(this, distanceInteraction);
         }
     }
     if (OnRelease != null)
     {
         OnRelease.Invoke(distanceInteraction);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// 移入
 /// </summary>
 public virtual void OnDistanceEnter(DistanceInteraction distanceInteraction)
 {
     if (OnEnter != null)
     {
         OnEnter.Invoke(distanceInteraction);
     }
 }
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        /// <returns></returns>
        static bool IsContains(DistanceInteraction send, DistanceInteraction receive, out InteractionDistanceInfo distanceInfo)
        {
            var distance = DistanceInfos.Find(obj => obj.sendKey.Equals(send) && obj.receiveValue.Equals(receive));

            distanceInfo = distance;

            return(distance != null);
        }
Esempio n. 11
0
        /// <summary>
        /// 根据物体传递传递过来的距离对象,去找到相应的所在管理端
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static DistanceDataManager GetSendDistanceManager(DistanceInteraction data)
        {
            if (dataManagers == null)
            {
                return(null);
            }

            return(dataManagers.Find(obj => obj.sendData != null && obj.sendData.Equals(data)));//寻找到一个GUID与TadID一致的对象
        }
Esempio n. 12
0
        /// <summary>
        /// 根据距离点,获取到指定的发送点
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static List <DistanceDataManager> GetSendDistaceDataKey(DistanceInteraction data)
        {
            if (dataManagers == null)
            {
                return(null);
            }

            return(dataManagers.FindAll(obj => obj.sendData.distanceData.TagID.Equals(data.distanceData.TagID) && obj.sendData.Equals(data)));
        }
Esempio n. 13
0
        protected virtual void OnEnable()
        {
            interaction = serializedObject.targetObject as DistanceInteraction;

            OnEnter      = serializedObject.FindProperty("OnEnter");
            OnExit       = serializedObject.FindProperty("OnExit");
            OnStay       = serializedObject.FindProperty("OnStay");
            OnRelease    = serializedObject.FindProperty("OnRelease");
            OnNotRelease = serializedObject.FindProperty("OnNotRelease");
        }
Esempio n. 14
0
        /// <summary>
        /// 带状态释放
        /// </summary>
        /// <param name="distanceInteraction"></param>
        /// <param name="status"></param>
        public virtual void OnDistanceRelease(DistanceInteraction distanceInteraction, InteractionReleaseStatus status)
        {
            //Debug.Log("OnDistanceRelease IsGrab");
            IsGrab = false;

            if (OnStatusRelease != null)
            {
                OnStatusRelease.Invoke(distanceInteraction, status);
            }
        }
        /// <summary>
        /// 放下,完成
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        public static void OnRelease(DistanceInteraction send, DistanceInteraction receive, bool isAuto = false)
        {
            InteractionDistanceInfo distanceInfo;

            if (IsContains(send, receive, out distanceInfo))
            {
                distanceInfo.SetDistanceStatus(DistanceStatus.Complete);

                receive.OnInteractionRelease(send, isAuto);
                send.OnInteractionRelease(receive);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 根据到所有的主动点接收数据,适用Send类型以及All类型(但是不包括本身)
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static List <DistanceDataManager> GetSendDistaceDataAll(DistanceInteraction data, InteractionType interactionType)
        {
            if (dataManagers == null)
            {
                return(null);
            }

            return(dataManagers.FindAll(obj => obj.sendData != null && obj.sendData.distanceData.TagID.Equals(data.distanceData.TagID) &&
                                        obj.sendData.distanceData.interactionType.Equals(interactionType) &&
                                        !obj.sendData.Equals(data) &&
                                        !obj.sendData.FeaturesObjectController.Equals(data.FeaturesObjectController)));
        }
Esempio n. 17
0
 /// <summary>
 /// 移除接收距离交互信息
 /// </summary>
 /// <param name="send">Send.</param>
 public void RemoveReceiveDistancing(DistanceInteraction send)
 {
     if (Distancing == null)
     {
         return;
     }
     if (!Distancing.Contains(send))
     {
         return;
     }
     Distancing.Remove(send);
 }
Esempio n. 18
0
        /// <summary>
        /// 获取接收距离数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static List <DistanceInteraction> GetReceiveDistanceDatas(DistanceInteraction data)
        {
            List <DistanceInteraction> distances = new List <DistanceInteraction>();
            var manager = GetSendDistanceManager(data);

            if (manager != null)
            {
                distances = manager.Distances;
            }

            return(distances);
        }
Esempio n. 19
0
        /// <summary>
        /// 停留
        /// </summary>
        public virtual void OnDistanceStay(DistanceInteraction distanceInteraction)
        {
            if (ActiveShadow && interactionShadow != null)
            {
                interactionShadow.OnOpen(this, distanceInteraction);
            }

            if (OnStay != null)
            {
                OnStay.Invoke(distanceInteraction);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 添加接收端信息
        /// </summary>
        /// <param name="send">Send.</param>
        public void AddReceiveDistancing(DistanceInteraction send)
        {
            if (Distancing == null)
            {
                Distancing = new List <DistanceInteraction>();
            }

            if (Distancing.Contains(send))
            {
                return;
            }

            Distancing.Add(send);
        }
        /// <summary>
        /// 两者之间是否已经靠近
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        /// <returns></returns>
        public static bool IsEnter(DistanceInteraction send, DistanceInteraction receive)
        {
            InteractionDistanceInfo distanceInfo;

            IsContains(send, receive, out distanceInfo);

            if (distanceInfo == null)
            {
                return(false);
            }

            return(distanceInfo.distanceStatus == DistanceStatus.Enter ||
                   distanceInfo.distanceStatus == DistanceStatus.Complete);
        }
Esempio n. 22
0
        void OnExit(DistanceInteraction receive)
        {
            //要加一层判断,否则一直执行是不好的
            InteractionDistanceController.OnExit(sendData, receive);

            if (Distanceing.Count == 0)
            {
                return;
            }

            if (Distanceing.Contains(receive))
            {
                Distanceing.Remove(receive);
            }
        }
Esempio n. 23
0
        bool OnDistance(DistanceInteraction receiveDistance, DistanceInteraction sendDistance, out float distanceValue)
        {
            switch (receiveDistance.distanceData.distanceShape)
            {
            case DistanceShape.Sphere:
                return(Utilitys.Distance(receiveDistance.Position, sendDistance.Position, receiveDistance.distanceData.distanceType, out distanceValue) <= receiveDistance.distanceData.distanceValue);

            case DistanceShape.Cube:
                return(Utilitys.CubeDistance(receiveDistance.Position, receiveDistance.distanceData.Size, sendDistance.Position, receiveDistance.distanceData.distanceType, out distanceValue));

            default:
                distanceValue = -1;
                return(false);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 释放
        /// </summary>
        public virtual void OnDistanceRelesae(DistanceInteraction distanceInteraction)
        {
            if (ActiveParent && interactionParent != null)
            {
                interactionParent.OnOpen(this, distanceInteraction);
            }
            if (ActiveShadow && interactionShadow != null)
            {
                interactionShadow.OnClose(this, distanceInteraction);
            }

            if (OnRelease != null)
            {
                OnRelease.Invoke(distanceInteraction);
            }
        }
Esempio n. 25
0
        /// <summary>
        /// 离开
        /// </summary>
        public virtual void OnDistanceExit(DistanceInteraction distanceInteraction)
        {
            if (OnExit != null)
            {
                OnExit.Invoke(distanceInteraction);
            }

            if (ActiveParent && interactionParent != null)
            {
                interactionParent.OnClose(this, distanceInteraction);
            }

            if (ActiveShadow && interactionShadow != null)
            {
                interactionShadow.OnClose(this, distanceInteraction);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 交互移入处理
        /// </summary>
        /// <param name="interaction">Interaction.</param>
        public void OnInteractionEnter(DistanceInteraction interaction)
        {
            switch (distanceData.interactionType)
            {
            case InteractionType.Receive:
            case InteractionType.All:
            case InteractionType.Pour:
                AddReceiveDistancing(interaction);
                OnDistanceEnter(interaction);

                break;

            case InteractionType.Send:
                OnDistanceEnter(interaction);
                break;
            }
        }
Esempio n. 27
0
        /// <summary>
        /// 移除已经交互的距离信息
        /// </summary>
        /// <param name="send">Send.</param>
        public void RemoveReceiveDistanced(DistanceInteraction send)
        {
            if (Distanced == null)
            {
                return;
            }
            if (!Distanced.Contains(send))
            {
                return;
            }

            Distanced.Remove(send);

            if (distanceData.maxCount != -1)
            {
                distanceData.maxCount++;
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 添加距离数据
        /// </summary>
        /// <param name="data"></param>
        public static void AddDistanceData(DistanceInteraction data)
        {
            if (data == null)
            {
                return;
            }

            if (AllDistances.Contains(data))
            {
                return;
            }

            AllDistances.Add(data);

            AddDistanceData(dataManagers, data);
            //校验一次
            CheckDistanceData();
        }
        /// <summary>
        /// 移出
        /// </summary>
        /// <param name="send"></param>
        /// <param name="receive"></param>
        public static void OnExit(DistanceInteraction send, DistanceInteraction receive)
        {
            //在次之前,还需要判断一次,否则一直执行循环查找,会很费资源,这么处理不恰当

            //To…Do

            InteractionDistanceInfo distanceInfo;

            if (IsContains(send, receive, out distanceInfo))
            {
                DistanceInfos.Remove(distanceInfo);

                receive.OnInteractionExit(send);
                send.OnInteractionExit(receive);

                //Debug.Log("离开了");
            }
        }
Esempio n. 30
0
        /// <summary>
        /// 加入距离
        /// </summary>
        /// <param name="distance"></param>
        /// <param name="target"></param>
        public void AddDistance(DistanceInteraction distance, DistanceInteraction target)
        {
            if (sendData != distance)
            {
                return;
            }

            if (distance.distanceData.interactionType != target.distanceData.interactionType)
            {
                return;
            }

            if (Distances.Contains(target))
            {
                return;
            }

            Distances.Add(target);
        }