Esempio n. 1
0
    //Coroutine function
    public IEnumerator RespawnPlayerCo()
    {
        //Generate Death Particle
        Instantiate(DeathParticle, Player.transform.position, Player.transform.rotation);
        //Hide Player
        //player.enabled = false;
        PC.SetActive(false);
        Player.GetComponent <Renderer> ().enabled = false;
        //Gravity Reset
        GravityStore = Player.GetComponent <Rigidbody2D> ().gravityScale;
        Player.GetComponent <Rigidbody2D>().gravityScale = 0f;
        Player.GetComponent <Rigidbody2D>().velocity     = Vector2.zero;
        //Point Penalty
        ScoreManager.AddPoints(-PointPenalty);
        //Life Penalty
        LifeCounter.AddLife(-LoseLife);
        //Debug Message
        Debug.Log("Player Respawn");
        //Respawn Delay
        yield return(new WaitForSeconds(RespawnDelay));

        //Gravity Restore
        Player.GetComponent <Rigidbody2D>().gravityScale = GravityStore;
        //Match Players transform position
        Player.transform.position = CurrentCheckPoint.transform.position;
        //Show Player
        //player.enabled = true;
        PC.SetActive(true);
        Player.GetComponent <Renderer> ().enabled = true;
        //Generate Spawn Particle
        Instantiate(RespawnParticle, CurrentCheckPoint.transform.position, CurrentCheckPoint.transform.rotation);
    }
    void OnTriggerEnter2D(Collider2D Other)
    {
        if (Other.GetComponent <Rigidbody2D>() == null)
        {
            return;
        }

        LifeCounter.AddLife(AddLife);

        Destroy(gameObject);
    }