void Start() { SoundManager.GetInstance().PlayOneShot(AudioRepository.LoadExplosionAudio(weapon.audioID)); animator.AnimationCompleted = delegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip) { animator.AnimationCompleted = null; weapon = null; Destroy(gameObject); }; if (weapon.WOE != 0) { Collider2D[] hits = Physics2D.OverlapCircleAll(this.transform.position, this.weapon.WOE); IList <GameObject> hitedCache = new List <GameObject>(); foreach (Collider2D hit in hits) { MonsterEntity2D entity = hit.gameObject.GetComponent <MonsterEntity2D>(); if (entity != null && !hitedCache.Contains(entity.gameObject)) { entity.OnWeaponHit(sender, weapon, this.transform.position); hitedCache.Add(hit.gameObject); } } hitedCache.Clear(); } }
void Start() { animator.AnimationCompleted = delegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip) { animator.AnimationCompleted = null; skill = null; Destroy(gameObject); }; if (skill.WOE != 0) { Collider2D[] hits = Physics2D.OverlapCircleAll(this.transform.position, this.skill.WOE); IList <GameObject> hitedCache = new List <GameObject>(); foreach (Collider2D hit in hits) { MonsterEntity2D entity = hit.gameObject.GetComponent <MonsterEntity2D>(); if (entity != null && !hitedCache.Contains(entity.gameObject)) { entity.OnSkillHit(sender, skill, this.transform.position); hitedCache.Add(hit.gameObject); } } hitedCache.Clear(); } }
private void OnCollisionEnter2D(Collision2D coll) { #region Hit Monster if (coll.gameObject.layer == LayerMaskDefines.MONSTER.id) { MonsterEntity2D entity = coll.gameObject.GetComponent <MonsterEntity2D>(); if (entity.machine.currentState.GetName() != StateTypes.Dead.ToString()) { if (OnHit != null) { OnHit(); } if (data.WOE == 0) { entity.OnSkillHit(owner, data, coll.contacts[0].point); } ProcessCollision(coll); ProcessPhsysicsType(coll.gameObject, data.physicsType); if (data.vibrateType == SkillVibrateType.Hit) { CameraUtils.Shake(); } } else { body2D.velocity = velocity; Collider2D[] colliders = coll.gameObject.GetComponents <Collider2D>(); for (int index = 0; index < colliders.Length; index++) { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), colliders[index]); } } } #endregion #region Hit Missile if (coll.gameObject.layer == LayerMaskDefines.MONSTER_MISSILE.id) { ProcessCollision(coll); ProcessPhsysicsType(coll.gameObject, data.physicsType); if (data.vibrateType == SkillVibrateType.Hit) { CameraUtils.Shake(); } } #endregion }
void OnCollisionEnter2D(Collision2D coll) { #region Hit Monster if (coll.gameObject.layer == LayerMaskDefines.MONSTER.id) { MonsterEntity2D entity = coll.gameObject.GetComponent <MonsterEntity2D>(); if (entity.machine.currentState.GetName() != StateTypes.Dead.ToString()) { if (data.WOE == 0) { entity.OnWeaponHit(owner, data, coll.contacts[0].point); } ProcessCollision(coll.contacts[0].point); ProcessPhsysicsType(coll.gameObject, data.physicsType); } else { body2D.velocity = velocity; Collider2D[] colliders = coll.gameObject.GetComponents <Collider2D>(); for (int index = 0; index < colliders.Length; index++) { Physics2D.IgnoreCollision(GetComponent <Collider2D>(), colliders[index]); } } } #endregion #region Hit Missile if (coll.gameObject.layer == LayerMaskDefines.MONSTER_MISSILE.id) { EventBox.Send(CustomEvent.TROPHY_UPDATE, new KeyValuePair <TrophyType, float>(TrophyType.DungeonKillMissile, 1)); ProcessCollision(coll.contacts[0].point); ProcessPhsysicsType(coll.gameObject, data.physicsType); } #endregion }