コード例 #1
0
        void CheckInTrigger(Vector3 emitter)
        {
            Collider[] colls = Physics.OverlapSphere(transform.position, 0.1f, GameConfig.ProjectileDamageLayer);

            for (int i = 0; i < colls.Length; ++i)
            {
                Collider hitCol = colls[i];
                if (hitCol.transform == null)
                {
                    continue;
                }

                if (hitCol.transform.IsChildOf(transform))
                {
                    continue;
                }

                if (m_Caster != null && hitCol.transform.IsChildOf(m_Caster))
                {
                    continue;
                }

                if (hitCol.gameObject.tag == "EnergyShield")
                {
                    EnergySheildHandler shield = hitCol.GetComponent <EnergySheildHandler>();
                    if (shield != null)
                    {
                        shield.Impact(emitter);
                    }
                    continue;
                }

                PEDefenceTrigger defencetrigger = hitCol.transform.GetComponent <PEDefenceTrigger>();
                if (null != defencetrigger)
                {
                    PECapsuleHitResult hitResult;
                    if (!defencetrigger.GetClosest(emitter, (TriggerBounds.size / 2f).magnitude, out hitResult))
                    {
                        continue;
                    }
                    Hit(hitResult.hitPos, -hitResult.hitDir, hitResult.hitTrans);
                    if (!m_Trigger)
                    {
                        m_Valid = false;
                    }
                }
                else if (!hitCol.isTrigger)
                {
                    Hit(emitter, Vector3.Normalize(emitter - hitCol.transform.position), hitCol.transform);
                    if (!m_Trigger)
                    {
                        m_Valid = false;
                    }
                }
                return;
            }
        }
コード例 #2
0
 public void HitShield(Projectile proj)
 {
     if (!proj.ShieldHasBeenHitted(this))
     {
         if (mActive)
         {
             Vector3 dir = proj.transform.position - transform.position;
             mSheild.Impact(transform.position + dir.normalized);
             proj.ApplyDamageReduce(mSkillRunner.ApplyEnergyShieldAttack(proj), this);
         }
     }
 }
コード例 #3
0
        public void OnTriggerEnter(Collider other)
        {
            if (m_DeletByHitLayer && 0 != (m_DeletLayer.value & (1 << other.gameObject.layer)))
            {
                Delete();
            }

            if (!m_Valid)
            {
                return;
            }

            if (0 == ((1 << other.gameObject.layer) & GameConfig.ProjectileDamageLayer))
            {
                return;
            }

            if (other.gameObject.GetComponentInParent <SkProjectile>() != null)
            {
                return;
            }

            if (other.transform.IsChildOf(transform))
            {
                return;
            }

            if (m_Caster != null && other.transform.IsChildOf(m_Caster))
            {
                return;
            }

            if (!m_Colliders.Contains(other))
            {
                m_Colliders.Add(other);
            }

            SkEntity entity = other.GetComponentInParent <SkEntity>();

            if (entity != null)
            {
                if (!m_Explode && !m_DamageEntities.Contains(entity))
                {
                    PECapsuleHitResult hitResult = GetHitResult(transform, other);
                    if (null != hitResult)
                    {
                        if (other.gameObject.tag == "EnergyShield")
                        {
                            EnergySheildHandler shield = other.GetComponent <EnergySheildHandler>();
                            if (shield != null)
                            {
                                shield.Impact(hitResult.hitPos);
                            }
                            return;
                        }

                        if (!m_DamageEntities.Contains(entity))
                        {
                            Hit(hitResult);
//							CastSkill(entity, hitResult);
                            m_DamageEntities.Add(entity);
                        }
                    }
                }

                if (!m_Entities.Contains(entity))
                {
                    m_Entities.Add(entity);
                }
            }
        }
コード例 #4
0
        bool GetRaycastInfo(Vector3 position, Vector3 velcity, out RaycastHit hitInfo, out Transform hitTrans, out PECapsuleHitResult hitResult, out bool useHitReslut, int layer)
        {
            hitResult    = null;
            useHitReslut = false;
            hitInfo      = new RaycastHit();
            hitTrans     = null;
            if (velcity.sqrMagnitude > 0.05f * 0.05f)
            {
                Ray          rayStart = new Ray(position, velcity);
                RaycastHit[] hitInfos = Physics.RaycastAll(rayStart, velcity.magnitude, layer);
                hitInfos = PETools.PEUtil.SortHitInfo(hitInfos, false);
                RaycastHit hit;
                for (int i = 0; i < hitInfos.Length; ++i)
                {
                    hit = hitInfos[i];
                    if (hit.transform == null)
                    {
                        continue;
                    }

                    if (hit.transform.IsChildOf(transform))
                    {
                        continue;
                    }

                    if (m_Caster != null && hit.transform.IsChildOf(m_Caster))
                    {
                        continue;
                    }

                    if (hit.collider.gameObject.tag == "EnergyShield")
                    {
                        EnergySheildHandler shield = hit.collider.GetComponent <EnergySheildHandler>();
                        if (shield != null)
                        {
                            shield.Impact(hit.point);
                        }
                        continue;
                    }

                    hitInfo  = hit;
                    hitTrans = hit.transform;

                    PEDefenceTrigger defencetrigger = hit.transform.GetComponent <PEDefenceTrigger>();
                    if (null != defencetrigger)
                    {
                        if (!defencetrigger.RayCast(rayStart, 100f, out hitResult))
                        {
                            continue;
                        }
                        hitInfo.point = hitResult.hitPos;
                        hitTrans      = hitResult.hitTrans;
                        useHitReslut  = true;
                    }
                    else if (hit.collider.isTrigger)
                    {
                        return(false);
                    }

                    return(true);
                }
            }

            return(false);
        }