Пример #1
0
    public override void CollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag != "Arrow")
        {
            //箭头停止运动
            M_Rigidbody.Sleep();
            //如果碰到了障碍物
            if (collision.collider.gameObject.layer == LayerMask.NameToLayer("Env"))
            {//计算伤害
                collision.collider.GetComponent <BulletMarks>().Hp -= Demage;
                collision.collider.GetComponent <BulletMarks>().PlayAudio(hit);
                //移除刚体
                Destroy(M_Rigidbody);
                //移除碰撞器
                Destroy(m_BoxCollider);
                //设置父物体跟随
                M_Transform.SetParent(collision.gameObject.transform);

                StartCoroutine("TileAnimation", pivot_Transform);
            }
            if (collision.collider.gameObject.layer == LayerMask.NameToLayer("AI"))
            {//计算伤害
                collision.collider.GetComponentInParent <AI>().HP -= Demage;
                collision.collider.GetComponentInParent <AI>().PlayFleshEffect(hit);
                //移除刚体
                Destroy(M_Rigidbody);
                //移除碰撞器
                Destroy(m_BoxCollider);
                //设置父物体跟随
                M_Transform.SetParent(collision.gameObject.transform);

                StartCoroutine("TileAnimation", pivot_Transform);
            }
        }
    }
Пример #2
0
    protected override void Collision(Collision coll)
    {
        M_Rigidbody.Sleep();
        if (coll.gameObject.layer == LayerMask.NameToLayer("Envionment"))
        {
            GameObject.Destroy(m_BoxCollider);
            GameObject.Destroy(M_Rigidbody);
            BulletMark tempBulletMark = coll.collider.GetComponent <BulletMark>();
            if (tempBulletMark != null)
            {
                tempBulletMark.HP -= Damage;
            }
            StartCoroutine("AnimationPlay", m_Pivot);
            M_Transform.SetParent(coll.gameObject.transform);
        }
        else if (coll.gameObject.layer == LayerMask.NameToLayer("AI"))
        {
            GameObject.Destroy(m_BoxCollider);
            GameObject.Destroy(M_Rigidbody);
            AI tempAI = coll.collider.GetComponentInParent <AI>();
            if (tempAI != null)
            {
                // 头部伤害加倍
                if (coll.collider.gameObject.name == "Head")
                {
                    tempAI.HeadGetHit(Damage);
                }
                else
                {
                    tempAI.NormalHit(Damage);
                }

                // 播放血液特效
                tempAI.PlayBloodEffect(aiEffectHit);
            }
            StartCoroutine("AnimationPlay", m_Pivot);
            M_Transform.SetParent(coll.gameObject.transform);
        }
    }
Пример #3
0
    /// <summary>
    /// 碰撞事件.
    /// </summary>
    protected override void CollisionEnter(Collision other)
    {
        GameObject.Destroy(M_Rigidbody);
        GameObject.Destroy(m_BoxCollider);

        BulletMark bulletMark = other.gameObject.GetComponent <BulletMark>();
        AIBase     ai         = other.gameObject.GetComponentInParent <AIBase>();

        // 攻击环境物体.
        if (bulletMark != null)
        {
            bulletMark.Hp -= Damage;
            bulletMark.PlayHitAudio(hit);
        }

        // 攻击AI角色.
        else if (ai != null)
        {
            // 头部伤害加倍.
            if (other.gameObject.name == "Head")
            {
                ai.Life -= 2 * Damage;
                ai.HitHeadState();
            }
            else
            {
                ai.Life -= Damage;
                ai.HitNormalState();
            }

            ai.PlayEffect(hit);
        }

        // 通用效果展现.
        M_Transform.SetParent(other.gameObject.GetComponent <Transform>());
        StartCoroutine("TailAnimation", m_PivotTransform);
    }