Ejemplo n.º 1
0
    public IEnumerator Die(Vector3 position)
    {
        nav.enabled = false;
        _dead       = true;
        yield return(new WaitForSeconds(0.3f));

        _animator.enabled = false;
        foreach (Collider col in GetComponentsInChildren <Collider>())
        {
            col.enabled = false;
        }
        _appear.SetPoint(position);
        yield return(_appear.Disapear());

        //		yield return new WaitForSeconds(_animator.GetCurrentAnimatorClipInfo(0)[0].clip.length * _animator.GetCurrentAnimatorStateInfo(0).normalizedTime);

        int randomOrb = Random.Range(0, 100);

        if (randomOrb < orbs.GetComponent <Orb>().chance)
        {
            Vector3 orbPos = this.transform.position;
            orbPos.y += 1;
            Instantiate(orbs, orbPos, this.transform.rotation);
        }
        Destroy(this.gameObject);
    }
Ejemplo n.º 2
0
        protected IEnumerator DestroySelf()
        {
            Colliders.ForEach(col => { col.enabled = false; });
            AllRigidBodies.ForEach(rb =>
            {
                rb.collisionDetectionMode = StopedMode;
                rb.isKinematic            = true;
                rb.useGravity             = false;
                rb.velocity        = Vector3.zero;
                rb.angularVelocity = Vector3.zero;
            });

            yield return(AppearScript.Disapear());

            Destroy(gameObject);
        }