Example #1
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);
    }
Example #2
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;
        }
    }
Example #3
0
        public TestTriangleExplosion()
        {
            var explosion = new TriangleExplosion(20)
            {
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
            };

            Add(explosion.With(e => { e.Scale = new Vector2(3); }));
            AddStep("Explode", () => explosion.Show());
        }
Example #4
0
    private void OnCollisionEnter(Collision collision)
    {
        TriangleExplosion tr = collision.gameObject.GetComponentInChildren <TriangleExplosion>();

        if (collision.gameObject.tag == "ennemi" && tr != null)
        {
            tr.dead = true;
            GameObject impact = Instantiate(ImpactEffect, transform.position, Quaternion.LookRotation(transform.position));
            Destroy(impact, 0.3f);
        }
        Destroy(gameObject);
    }
Example #5
0
    public void Die()
    {
        if (isPlayer)
        {
            PlayRandomGlassBreak();
            TriangleExplosion te = gameObject.AddComponent <TriangleExplosion>();
            GetComponent <MeshCollider> ().enabled = false;

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

            gameOverWatcher.StartEnablePanel();
            return;
        }
    }
Example #6
0
 // Start is called before the first frame update
 void Awake()
 {
     explosion = GetComponent <TriangleExplosion>();
 }