コード例 #1
0
ファイル: EObjectTrigger.cs プロジェクト: moto2002/FrameLock
        protected void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.layer == DefineLayer.HitRaycast)
            {
                return;
            }

            if (!string.IsNullOrEmpty(triggerMask))
            {
                if (!GHelper.UF_CheckStringMask(triggerMask, other.gameObject.tag))
                {
                    return;
                }
            }

            if (m_MapTriggerCache.ContainsKey(other.gameObject))
            {
                float fixedTime = time;
                //判定是否在连续触发事件内
                float dt = fixedTime - m_MapTriggerCache[other.gameObject];
                if (dt >= interval)
                {
                    m_MapTriggerCache[other.gameObject] = fixedTime;
                    TriggerGameObject(other.gameObject);
                }
            }
            else
            {
                m_MapTriggerCache.Add(other.gameObject, time);
                if (interval <= 0 || m_IsOnRun)
                {
                    TriggerGameObject(other.gameObject);
                }
            }
        }
コード例 #2
0
        //unity monobehavior event
        private void OnTriggerEnter(Collider hitObject)
        {
            Vector3 hitPoint = this.transform.position;

            if (!string.IsNullOrEmpty(triggerMask))
            {
                if (!GHelper.UF_CheckStringMask(triggerMask, hitObject.tag))
                {
                    return;
                }
            }

            //自身不检测碰撞
            if (ower == hitObject.gameObject || ower == null)
            {
                return;
            }
            //同类型Member不检测
            if (ower.tag == hitObject.tag)
            {
                return;
            }

            UF_OnColliderEnter(hitObject.gameObject, hitPoint);
        }
コード例 #3
0
 protected override void UF_OnColliderEnter(GameObject hitObject, Vector3 hitPoint)
 {
     //只对Member 生效
     if (GHelper.UF_CheckStringMask(DefineTagMask.Member, hitObject.tag))
     {
         base.UF_OnColliderEnter(hitObject, hitPoint);
     }
     else
     {
         UF_PlayTriggerEffect(hitPoint);
     }
 }
コード例 #4
0
 protected override void UF_OnColliderEnter(GameObject hitObject, Vector3 hitPoint)
 {
     if (GHelper.UF_CheckStringMask(DefineTagMask.Member, hitObject.tag) && hitObject.activeSelf)
     {
         base.UF_OnColliderEnter(hitObject, hitPoint);
     }
     else
     {
         UF_PlayTriggerDip();
         UF_PlayTriggerEffect(this.position);
     }
     this.UF_Stop();
 }
コード例 #5
0
 protected override void UF_OnColliderEnter(GameObject hitObject, Vector3 hitPoint)
 {
     //只对Member 生效
     if (GHelper.UF_CheckStringMask(DefineTagMask.Member, hitObject.tag))
     {
         if (!m_MapTriggerCache.ContainsKey(hitObject))
         {
             m_MapTriggerCache.Add(hitObject, m_ExistTime);
         }
         var tarHitPoint = hitObject.transform.position;
         tarHitPoint.y = hitPoint.y;
         base.UF_OnColliderEnter(hitObject, tarHitPoint);
     }
 }
コード例 #6
0
ファイル: TriggerObject.cs プロジェクト: moto2002/FrameLock
        protected virtual void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.layer == DefineLayer.HitRaycast)
            {
                return;
            }
            if (string.IsNullOrEmpty(eTrigger))
            {
                return;
            }
            if (!string.IsNullOrEmpty(triggerMask))
            {
                if (!GHelper.UF_CheckStringMask(triggerMask, other.tag))
                {
                    return;
                }
            }
            if (m_AttachTarget != null && m_AttachTarget == other.gameObject)
            {
                return;
            }

            //send message
            MessageSystem msg = MessageSystem.UF_GetInstance();

            msg.UF_BeginSend();
            msg.UF_PushParam(eTrigger);
            msg.UF_PushParam(this.gameObject);
            msg.UF_PushParam(other.gameObject);
            for (int k = 0; k < eParams.Length; k++)
            {
                msg.UF_PushParam(eParams[k]);
            }
            msg.UF_EndSend(DefineEvent.E_TRIGGER_CONTROLLER);

            if (m_UETrigger != null)
            {
                m_UETrigger.Invoke();
            }

            //paly sound
            AudioManager.UF_GetInstance().UF_Play(eSound);
            //release?
            if (autoRelese)
            {
                this.Release();
            }
        }
コード例 #7
0
ファイル: AvatarCapsule.cs プロジェクト: moto2002/FrameLock
        //碰撞
        internal void UF_OnCollisionHit(ControllerColliderHit hit)
        {
            if (!activeTriggerCollision)
            {
                return;
            }

            GameObject hitTarget = hit.gameObject;

            if (hitTarget.tag == DefineTag.Ground)
            {
                return;
            }

            if (!UF_CheckCollisionIntervalTime())
            {
                return;
            }

            //忽略指定层碰撞
            if (hitTarget.tag == DefineTag.Block || hitTarget.tag == DefineTag.Unwalk)
            {
                //碰撞不可走区域
                MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_AVATAR_BLOCK, m_Avatar, hitTarget, hit.point);
                return;
            }

            //只处理角色间碰撞
            if (m_Avatar.tag != hitTarget.tag)
            {
                //if (!CheckCollisionIntervalTime()) return;
                if (GHelper.UF_CheckStringMask(collisionMask, hitTarget.tag))
                {
                    //推开角色
                    if (hit.collider is CharacterController)
                    {
                        var     targetController = hit.collider as CharacterController;
                        Vector3 pushForward      = MathX.UF_Foward(m_Avatar.position, hit.transform.position);
                        pushForward.y = 0;
                        //Vector3 pushForward = hit.moveDirection;
                        targetController.Move(pushFactor * pushForward.normalized * GTime.RunDeltaTime);
                    }

                    MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_AVATAR_COLLISION, m_Avatar, hitTarget);
                }
            }
        }
コード例 #8
0
        IEnumerator UF_IOnRayCastHit(Vector3 sorPoint, Vector3 vecforward)
        {
            var listTemp = ListCache <RaycastHit> .Acquire();

            bool ispierce = UF_GetBoolParam("is_pierce");
            int  rbtimes  = UF_GetIntParam("rebound_times");

            if (ispierce)
            {
                this.UF_GetRayAllHitReflex(sorPoint, vecforward, 1000, rbtimes, listTemp);
            }
            else
            {
                this.UF_GetRayHitReflex(sorPoint, vecforward, 1000, rbtimes, listTemp);
            }

            Vector3 lastPoint   = sorPoint;
            var     listVectors = ListCache <Vector3> .Acquire();

            UF_ClearChain();
            for (int k = 0; k < listTemp.Count; k++)
            {
                var  hit      = listTemp[k];
                bool hitblock = hit.collider.gameObject.layer == DefineLayer.HitRaycast;
                if (hitblock || !ispierce)
                {
                    listVectors.Add(lastPoint);
                    lastPoint = hit.point;
                    listVectors.Add(lastPoint);
                    UF_SetChain(listVectors.ToArray());
                    if (hitblock)
                    {
                        useReboundTimes++;
                    }
                }

                if (!string.IsNullOrEmpty(triggerMask))
                {
                    if (!GHelper.UF_CheckStringMask(triggerMask, hit.collider.tag))
                    {
                        UF_PlayTriggerEffect(hit.point);
                        yield return(UF_WaitFixedInterval());

                        continue;
                    }
                }
                //同类型Member不检测
                if (ower == null || ower.tag == hit.collider.tag)
                {
                    UF_PlayTriggerEffect(hit.point);
                    yield return(UF_WaitFixedInterval());

                    continue;
                }

                //检查是否被屏蔽
                if (UF_CheckMaskTriggerObject(hit.collider.gameObject))
                {
                    continue;
                }
                this.UF_OnColliderEnter(hit.collider.gameObject, hit.point);

                if (ispierce)
                {
                    usePierceTimes++;
                }

                yield return(UF_WaitFixedInterval());
            }

            //SetChain(listVectors.ToArray());
            ListCache <Vector3> .Release(listVectors);

            ListCache <RaycastHit> .Release(listTemp);

            yield return(null);
        }