Ejemplo n.º 1
0
    public IEnumerator RespawnPlayerCo()
    {
        respawning = true;

        // Instantiate the particle system representing the death of the player
        Instantiate(deathParticle, player.transform.position, player.transform.rotation);
        if (playerGovernor.IsP1Active())
        {
            GetComponent <AudioSource> ().clip = osirisDeathClip;
        }
        else
        {
            GetComponent <AudioSource>().clip = isisDeathClip;
        }
        GetComponent <AudioSource> ().Play();
        player.GetComponent <Player>().ManageShapeOnRespawn();
        player.GetComponent <Player> ().enabled   = false;
        player.GetComponent <Renderer> ().enabled = false;
        //Debug.Log ("Player respawn");

        // Now we wait the respawn delay so the death animation can be seen and then the player respawn
        // to the last activated chekpoint

        yield return(new WaitForSeconds(respawnDelay));

        playerGovernor.canSwitchPlayer = false;

        if (playerGovernor.IsP1Active())
        {
            Vector3 respawnPos = currentCheckpointP1.transform.position;
            respawnPos.z = -2;
            player.transform.position = respawnPos;
        }
        else
        {
            Vector3 respawnPos = currentCheckpointP2.transform.position;
            respawnPos.z = -2;
            player.transform.position = respawnPos;
        }
        player.GetComponent <Player> ().enabled   = true;
        player.GetComponent <Renderer> ().enabled = true;
        Instantiate(respawnParticle, player.transform.position, player.transform.rotation);
        if (!speedRun)
        {
            playerGovernor.canSwitchPlayer = true;
        }
        respawning = false;
    }
Ejemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.tag == "Player")
     {
         if (playerGovernor.IsP1Active())
         {
             if (levelManager.currentCheckpointP1 != null)
             {
                 //levelManager.currentCheckpointP1.GetComponent<MeshRenderer> ().material.color = inactiveCheckPoint;
                 levelManager.currentCheckpointP1.GetComponent <CheckPoint>().DisableCheckpoint();
             }
             levelManager.currentCheckpointP1 = gameObject;
         }
         else
         {
             if (levelManager.currentCheckpointP2 != null)
             {
                 //levelManager.currentCheckpointP2.GetComponent<MeshRenderer> ().material.color = inactiveCheckPoint;
                 levelManager.currentCheckpointP1.GetComponent <CheckPoint>().DisableCheckpoint();
             }
             levelManager.currentCheckpointP2 = gameObject;
         }
         //gameObject.GetComponent<MeshRenderer> ().material.color = activeCheckpoint;
         EnableCheckpoint();
         // Debug.Log("Activated checkpoint " + transform.position);
     }
 }