Beispiel #1
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (m_IsInDelayDestroy)
            {
                return;
            }
            GameObject obj = collision.gameObject;

            if (obj.CompareTag(GameConstVal.MapTag))
            {
                Global.gApp.gAudioSource.PlayOneShot(HittedEnemyClip);
                //m_IsInDelayDestroy = true;
                AddHittedWallEffect();
                //Recycle();
            }
            else if (obj.CompareTag(GameConstVal.MonsterTag))
            {
                //m_IsInDelayDestroy = true;
                Global.gApp.gAudioSource.PlayOneShot(HittedEnemyClip);
                Monster monster = collision.gameObject.GetComponent <Monster>();
                monster.OnHit_Up(m_Damage, transform);
                if (LinkBullet != null)
                {
                    GameObject linkBullet = Instantiate(LinkBullet);
                    linkBullet.GetComponent <ElecPopBullet>().Init(monster.gameObject, m_Damage);
                }
                if (monster.CheckCanAddHittedEffect())
                {
                    GameObject effect = GetHittedEnemyEffect();
                    if (effect != null)
                    {
                        effect.transform.SetParent(monster.GetBodyNode(), false);
                        effect.transform.position = monster.GetBodyNode().position;
                    }
                }
                //Recycle();
            }
            //else if (obj.CompareTag(GameConstVal.ShieldTag))
            //{
            //    m_IsInDelayDestroy = true;
            //    Global.gApp.gAudioSource.PlayOneShot(HittedEnemyClip);
            //    collision.gameObject.GetComponent<AIShieldEvent>().AddHittedEffect(transform.position);
            //    //Recycle();
            //}
        }