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); }
private void UpdateHitCount() { if (m_Owner == null) { return; } long now = m_OwnSkill.CurTime; if (m_LastHitCountTime + TriggerUtil.MinHitCountCD() > now) { m_CurHitCountId = TriggerUtil.NextHitCountId(); m_LastHitCountTime = now; } }
private void Init(GameObject obj, SkillInstance instance) { m_IsInited = true; m_Owner = obj; m_OwnSkill = instance; m_CurHitCountId = TriggerUtil.NextHitCountId(); m_LastHitCountTime = instance.CurTime; m_DamageManager = instance.CustomDatas.GetData <SkillDamageManager>(); if (m_DamageManager == null) { m_DamageManager = new SkillDamageManager(obj); instance.CustomDatas.AddData <SkillDamageManager>(m_DamageManager); } m_ColliderInfo.CreateTriger(obj, m_RemainTime / 1000.0f, (object)(MyAction <Collider>) this.OnTriggerEnter, (object)(MyAction <Collider>) this.OnTriggerExit, (object)(MyAction)this.OnDestroy); }
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); } }