private bool DamageCrossObjects(GameObject obj, SkillInstance instance, UnityEngine.Vector3 pos)
        {
            bool is_damaged_somebody          = false;
            SkillDamageManager damage_manager = instance.CustomDatas.GetData <SkillDamageManager>();

            if (damage_manager == null)
            {
                damage_manager = new SkillDamageManager(obj);
                instance.CustomDatas.AddData <SkillDamageManager>(damage_manager);
            }
            List <GameObject> hit_objes = TriggerUtil.GetRayHitObjects(TriggerUtil.CHARACTER_LAYER, pos);
            List <GameObject> enimies   = TriggerUtil.FiltEnimy(obj, hit_objes);
            int        final_skill_id   = -1;
            GameObject source_obj       = TriggerUtil.GetFinalOwner(obj, final_skill_id, out final_skill_id);
            long       hit_count_id     = TriggerUtil.NextHitCountId();

            for (int i = 0; i < enimies.Count; i++)
            {
                if (!SkillDamageManager.IsEnemy(obj, enimies[i].gameObject))
                {
                    continue;
                }
                if (IsObjectCanDamage(enimies[i]))
                {
                    damage_manager.SendImpactToObject(source_obj, enimies[i], m_StateImpacts, final_skill_id, hit_count_id);
                    DamageObjectInfo a = new DamageObjectInfo();
                    a.obj            = enimies[i];
                    a.remainDamageCD = m_DamageInterval / 1000.0f;
                    m_DamageCDObjects.Add(a);
                    is_damaged_somebody = true;
                }
            }

            /*
             * foreach (GameObject hit_obj in enimies) {
             * if (!SkillDamageManager.IsEnemy(obj, hit_obj.gameObject)) {
             *  continue;
             * }
             * if (IsObjectCanDamage(hit_obj)) {
             *  damage_manager.SendImpactToObject(source_obj, hit_obj, m_StateImpacts, final_skill_id, hit_count_id);
             *  DamageObjectInfo a = new DamageObjectInfo();
             *  a.obj = hit_obj;
             *  a.remainDamageCD = m_DamageInterval / 1000.0f;
             *  m_DamageCDObjects.Add(a);
             *  is_damaged_somebody = true;
             * }
             * }*/
            if (is_damaged_somebody)
            {
                damage_manager.IsDamagedEnemy = true;
                instance.SendMessage("oncollide");
            }
            return(is_damaged_somebody);
        }
Beispiel #2
0
        public static List <GameObject> FiltEnimy(GameObject source, List <GameObject> list)
        {
            List <GameObject> result = new List <GameObject>();

            for (int i = 0; i < list.Count; i++)
            {
                if (SkillDamageManager.IsEnemy(source, list[i]) && !IsObjectDead(list[i]))
                {
                    result.Add(list[i]);
                }
            }

            /*
             * foreach (GameObject obj in list) {
             * if (SkillDamageManager.IsEnemy(source, obj) && !IsObjectDead(obj)) {
             *  result.Add(obj);
             * }
             * }*/
            return(result);
        }
Beispiel #3
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            if (curSectionTime >= m_StartTime)
            {
                GameObject obj = sender as GameObject;
                if (null == obj)
                {
                    return(false);
                }
                if (!instance.IsDamageEnable)
                {
                    return(false);
                }

                UnityEngine.Vector3 center         = obj.transform.TransformPoint(m_RelativeCenter);
                Collider[]          hits           = Physics.OverlapSphere(center, m_Range, TriggerUtil.CHARACTER_LAYER);
                SkillDamageManager  damage_manager = instance.CustomDatas.GetData <SkillDamageManager>();
                if (damage_manager == null)
                {
                    damage_manager = new SkillDamageManager(obj);
                    instance.CustomDatas.AddData <SkillDamageManager>(damage_manager);
                }
                if (m_IsShowTip)
                {
                    GameObject circle = TriggerUtil.DrawCircle(center, m_Range, m_Color);
                    GameObject.Destroy(circle, m_ShowTime / 1000.0f);
                }
                long hit_count_id = TriggerUtil.NextHitCountId();
                for (int i = 0; i < hits.Length; i++)
                {
                    if (!SkillDamageManager.IsEnemy(obj, hits[i].gameObject))
                    {
                        continue;
                    }
                    if (SkillDamageManager.IsUserStandUp(hits[i].gameObject))
                    {
                        continue;
                    }
                    if (!damage_manager.IsContainObject(hits[i].gameObject))
                    {
                        damage_manager.IsDamagedEnemy = true;
                        damage_manager.SendImpactToObject(obj, hits[i].gameObject, m_StateImpacts, instance.SkillId, hit_count_id);
                        if (!m_IsClearWhenFinish)
                        {
                            damage_manager.AddDamagedObject(hits[i].gameObject);
                        }
                    }
                }

                /*
                 * foreach (Collider hit in hits) {
                 * if (!SkillDamageManager.IsEnemy(obj, hit.gameObject)) {
                 *  continue;
                 * }
                 * if (SkillDamageManager.IsUserStandUp(hit.gameObject)) {
                 *  continue;
                 * }
                 * if (!damage_manager.IsContainObject(hit.gameObject)) {
                 *  damage_manager.IsDamagedEnemy = true;
                 *  damage_manager.SendImpactToObject(obj, hit.gameObject, m_StateImpacts, instance.SkillId, hit_count_id);
                 *  if (!m_IsClearWhenFinish) {
                 *    damage_manager.AddDamagedObject(hit.gameObject);
                 *  }
                 * }
                 * }*/
                if (damage_manager.IsDamagedEnemy)
                {
                    instance.SendMessage("oncollide");
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }