Ejemplo n.º 1
0
        /// <summary>
        /// 计算释放
        /// </summary>
        public void OnComputeRelesae()
        {
            foreach (var receive in Distanceing.ToList())
            {
                if (receive.Interaction == null)
                {
                    continue;
                }

                if (!InteractionDistanceController.IsEnter(sendData, receive))
                {
                    sendData.OnNotRelease();
                    receive.OnNotRelease();
                    continue;
                }

                switch (sendData.detectType)
                {
                case InteractionDetectType.And:

                    if (receive.Interaction.IsCanInteraction(sendData.Interaction) &&
                        sendData.Interaction.IsCanInteraction(receive.Interaction))
                    {
                        //Distanceing.Remove(receive);
                        InteractionDistanceController.OnRelease(sendData, receive);
                    }

                    break;

                case InteractionDetectType.Receive:

                    if (receive.Interaction.IsCanInteraction(sendData.Interaction))
                    {
                        //Distanceing.Remove(receive);

                        InteractionDistanceController.OnRelease(sendData, receive);
                    }

                    break;

                case InteractionDetectType.Send:

                    if (sendData.Interaction.IsCanInteraction(receive.Interaction))
                    {
                        //Distanceing.Remove(receive);

                        InteractionDistanceController.OnRelease(sendData, receive);
                    }

                    break;

                default:
                    break;
                }
            }

            sendData.Interaction.IsGrab = false;
        }
Ejemplo n.º 2
0
        void OnExit(DistanceInteraction receive)
        {
            //要加一层判断,否则一直执行是不好的
            InteractionDistanceController.OnExit(sendData, receive);

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

            if (Distanceing.Contains(receive))
            {
                Distanceing.Remove(receive);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 计算距离
        /// </summary>
        public void OnComputeDistance()
        {
            foreach (var receive in Distances)
            {
                if (receive.Interaction == null)
                {
                    continue;
                }

                //如果在距离范围内
                if (OnDistance(receive, sendData))
                {
                    switch (sendData.detectType)
                    {
                    //并且关系
                    case InteractionDetectType.And:

                        //如果都没有移入,则
                        if (!InteractionDistanceController.IsEnter(sendData, receive))
                        {
                            //判断两者的条件是否都可以进行交互。
                            if (receive.Interaction.IsCanInteraction(sendData.Interaction) &&
                                sendData.Interaction.IsCanInteraction(receive.Interaction))
                            {
                                InteractionDistanceController.OnEnter(sendData, receive);

                                if (!Distanceing.Contains(receive))
                                {
                                    Distanceing.Add(receive);
                                }
                            }
                        }

                        if (InteractionDistanceController.IsEnter(sendData, receive))
                        {
                            InteractionDistanceController.OnStay(sendData, receive);
                        }

                        break;

                    case InteractionDetectType.Receive:

                        //如果是接收端,那么只需要计算接收端的IsEnter和receiveData看是否可以进行交互。
                        if (!InteractionDistanceController.IsEnter(sendData, receive) &&
                            receive.Interaction.IsCanInteraction(sendData.Interaction))
                        {
                            InteractionDistanceController.OnEnter(sendData, receive);

                            if (!Distanceing.Contains(receive))
                            {
                                Distanceing.Add(receive);
                            }
                        }

                        if (InteractionDistanceController.IsEnter(sendData, receive))
                        {
                            InteractionDistanceController.OnStay(sendData, receive);
                        }

                        break;

                    case InteractionDetectType.Send:

                        //如果是发送端为主,那么只需要计算发射端的IsEnter和sendData看是否可以进行交互
                        if (!InteractionDistanceController.IsEnter(sendData, receive) &&
                            sendData.Interaction.IsCanInteraction(receive.Interaction))
                        {
                            InteractionDistanceController.OnEnter(sendData, receive);

                            if (!Distanceing.Contains(receive))
                            {
                                Distanceing.Add(receive);
                            }
                        }

                        if (InteractionDistanceController.IsEnter(sendData, receive))
                        {
                            InteractionDistanceController.OnStay(sendData, receive);
                        }

                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    //要加一层判断,否则一直执行是不好的
                    InteractionDistanceController.OnExit(sendData, receive);

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

                    if (Distanceing.Contains(receive))
                    {
                        Distanceing.Remove(receive);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 计算释放
        /// </summary>
        public void OnComputeRelesae(bool isAuto = false)
        {
            if (Distanceing.Count == 0)
            {
                sendData.OnInteractionNotRelease();
                return;
            }

            bool isNotRelease = false;

            foreach (var receive in Distanceing.ToList())
            {
                if (receive == null)
                {
                    continue;
                }

                //检测是否有正在交互中,如果没有,则执行notRelease释放。
                if (!InteractionDistanceController.IsEnter(sendData, receive))
                {
                    isNotRelease = true;
                    continue;
                }

                isNotRelease = false;

                switch (sendData.distanceData.detectType)
                {
                case InteractionDetectType.And:

                    if (receive.IsCanInteraction(sendData) &&
                        sendData.IsCanInteraction(receive))
                    {
                        InteractionDistanceController.OnRelease(sendData, receive, isAuto);
                    }

                    break;

                case InteractionDetectType.Receive:

                    if (receive.IsCanInteraction(sendData))
                    {
                        InteractionDistanceController.OnRelease(sendData, receive, isAuto);
                    }

                    break;

                case InteractionDetectType.Send:

                    if (sendData.IsCanInteraction(receive))
                    {
                        InteractionDistanceController.OnRelease(sendData, receive, isAuto);
                    }

                    break;

                default:
                    break;
                }
            }

            //Debug.Log("SendData IsGrab");
            sendData.IsGrab    = false;
            sendData.HandIndex = -1;

            //如果不存在有交互的,就进行无释放。
            if (isNotRelease)
            {
                sendData.OnInteractionNotRelease();
            }
        }
Ejemplo n.º 5
0
        void OnEnter(DistanceInteraction receive)
        {
            switch (sendData.distanceData.detectType)
            {
            //并且关系
            case InteractionDetectType.And:

                //如果都没有移入,则
                if (!InteractionDistanceController.IsEnter(sendData, receive))
                {
                    //判断两者的条件是否都可以进行交互。
                    if (receive.IsCanInteraction(sendData) &&
                        sendData.IsCanInteraction(receive))
                    {
                        InteractionDistanceController.OnEnter(sendData, receive);

                        if (!Distanceing.Contains(receive))
                        {
                            Distanceing.Add(receive);
                        }
                    }
                }

                if (InteractionDistanceController.IsEnter(sendData, receive))
                {
                    if (!Distanceing.Contains(receive))
                    {
                        Distanceing.Add(receive);
                    }
                    InteractionDistanceController.OnStay(sendData, receive);
                }

                break;

            case InteractionDetectType.Receive:

                //如果是接收端,那么只需要计算接收端的IsEnter和receiveData看是否可以进行交互。
                if (!InteractionDistanceController.IsEnter(sendData, receive) &&
                    receive.IsCanInteraction(sendData))
                {
                    InteractionDistanceController.OnEnter(sendData, receive);

                    if (!Distanceing.Contains(receive))
                    {
                        Distanceing.Add(receive);
                    }
                }

                if (InteractionDistanceController.IsEnter(sendData, receive))
                {
                    if (!Distanceing.Contains(receive))
                    {
                        Distanceing.Add(receive);
                    }
                    InteractionDistanceController.OnStay(sendData, receive);
                }

                break;

            case InteractionDetectType.Send:

                //如果是发送端为主,那么只需要计算发射端的IsEnter和sendData看是否可以进行交互
                if (!InteractionDistanceController.IsEnter(sendData, receive) &&
                    sendData.IsCanInteraction(receive))
                {
                    InteractionDistanceController.OnEnter(sendData, receive);

                    if (!Distanceing.Contains(receive))
                    {
                        Distanceing.Add(receive);
                    }
                }

                if (InteractionDistanceController.IsEnter(sendData, receive))
                {
                    if (!Distanceing.Contains(receive))
                    {
                        Distanceing.Add(receive);
                    }
                    InteractionDistanceController.OnStay(sendData, receive);
                }

                break;

            default:
                break;
            }
        }