Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        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
        }