示例#1
0
    public void Die(Vector3 explosionPosition)
    {
        if (index >= 0)
        {
            DisableCollider();
            if (GetComponent <Rigidbody> () != null)
            {
                GetComponent <Rigidbody> ().velocity = Vector3.zero;
            }
            if (GetComponent <ConstantForwardMotion> () != null)
            {
                GetComponent <ConstantForwardMotion> ().speed = 0.0f;
            }

            if (shouldShatter)
            {
                displayScoreText();
                PlayRandomGlassBreak();
                TriangleExplosion te = gameObject.AddComponent <TriangleExplosion> ();
                StartCoroutine(te.SplitMesh(true, explosionPosition));
            }
            else
            {
                StartShrinkDie();
            }

            RegisterDeath(shouldShatter);
            index = -1;
        }
    }
示例#2
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject particle;

        if (collision.gameObject.CompareTag("Stone"))
        {
            particle = PoolObject.GetObject(Globals.PoolKey.VFXStone);
            particle.transform.position = transform.position;
        }

        if (collision.gameObject.CompareTag("Metal"))
        {
            particle = PoolObject.GetObject(Globals.PoolKey.VFXMetal);
            particle.transform.position = transform.position;
            particle.transform.rotation = Quaternion.FromToRotation(Vector3.up, collision.contacts[0].normal);;
        }

        if (collision.gameObject.CompareTag("Ground"))
        {
            particle = PoolObject.GetObject(Globals.PoolKey.VFXSend);
            particle.transform.position = transform.position;
        }

        if (collision.gameObject.CompareTag("Glass"))
        {
            TriangleExplosion explosion = collision.gameObject.GetComponent <TriangleExplosion>();
            explosion.StartCoroutine(explosion.SplitMesh(false));
        }
        StopCoroutine(BulletLifeTime());
        gameObject.SetActive(false);
    }
示例#3
0
文件: Health.cs 项目: psturmfels/Axis
    public void Die()
    {
        if (isPlayer)
        {
            PlayRandomGlassBreak();
            TriangleExplosion te = gameObject.AddComponent <TriangleExplosion>();
            GetComponent <MeshCollider> ().enabled = false;

            StartCoroutine(te.SplitMesh(true, transform.position));

            gameOverWatcher.StartEnablePanel();
            return;
        }
    }