Example #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;
        }
Example #2
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();
            }
        }