Exemple #1
0
    //Called when we dead
    private void Dead()
    {
        //Set the entity state to dead
        entityState = EntityState.State.Dead;

        Destroy(GetComponent <PlayerDragController>());

        BOVibrate.Vibrate();
        BOVibrate.Vibrate();

        //Disable the renderer and collider
        gameObject.GetComponent <Renderer>().enabled   = false;
        gameObject.GetComponent <Collider2D>().enabled = false;

        //Destroy the particle tale on the object
        Destroy(gameObject.GetComponentInChildren <ParticleSystem>());

        //Instantiate the dead particle system at this location
        Instantiate(deadParticleSystem, gameObject.transform);

        GameObject.FindGameObjectWithTag("ObjectController").GetComponent <ObjectSpawner>().CancelSpawner();

        if (transform.GetComponentInParent <AudioSource>().enabled == true)
        {
            transform.GetComponentInParent <AudioSource>().Play();
        }

        //Call restartlevel in 0.4 secs
        Invoke("EndLevel", 0.4f);

        AnalyticsEvent.GameOver();
    }
Exemple #2
0
 public void PickedUp()
 {
     GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>().AddScore(points);
     Instantiate(particleSystem, this.gameObject.transform.position, this.gameObject.transform.rotation);
     gameObject.SetActive(false);
     if (transform.GetComponentInParent <AudioSource>().isActiveAndEnabled)
     {
         transform.GetComponentInParent <AudioSource>().Play();
     }
     BOVibrate.Vibrate();
 }