Exemplo n.º 1
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            BaseMissile m = collision.GetComponent <BaseMissile>();

            if (m != null)
            {
                GameSceneCtrl.Instance.RefreshEmitter(this);
            }
        }
Exemplo n.º 2
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            BaseMissile m = collision.gameObject.GetComponent <BaseMissile>();

            if (m != null)
            {
                RaycastHit2D[] rs = null;
                collision.Raycast(collision.transform.right, rs, 100);
                Vector3 dir = collision.transform.position - m_ConnectRigi.transform.position;
                m_ConnectRigi.AddForce(dir * 10);
                RaycastHit2D[] hits = Physics2D.RaycastAll(collision.transform.position, collision.transform.right, 100);
                for (int i = 0; i < hits.Length; i++)
                {
                    if (hits[i].collider.transform != collision.transform)
                    {
                        Break(hits[i].point);
                        break;
                    }
                }
            }
        }
        protected override void OnCollision(GameObject collision)
        {
            if (m_Status == Status.Fixed)
            {
                if (collision.gameObject.tag.EndsWith("Ground"))
                {
                    return;
                }
            }

            IHealth health = collision.gameObject.GetComponent <IHealth>();

            if (health != null)
            {
                health.OnHit(this.gameObject);
            }
            if (m_Status == Status.Fixed)
            {
                BaseMissile m = collision.gameObject.GetComponent <BaseMissile>();
                if (m != null)
                {
                    m_NextStatus = Status.Shoot;
                    if (m.Type == MissileType.Fixed)
                    {
                        ConnectMissile = m.ConnectMissile;
                    }
                    else
                    {
                        ConnectMissile = m;
                    }
                }
                else
                {
                    GameObject go = ResourcesMrg.Instance.Load(ResourcesMrg.ResourceType.Effect, "Explode", isCache: true);
                    go.transform.position = transform.position;
                    Destroy(this.gameObject);
                }
            }
            base.OnCollision(collision);
        }