예제 #1
0
    public IEnumerator respawnPlayerCorutine()
    {
        player = FindObjectOfType <LightMasterController>();
        Instantiate(deathParticle, player.gameObject.transform.position, Quaternion.identity);
        player.gameObject.SetActive(false);
        player.GetComponent <Renderer> ().enabled = false;
        //player.GetComponent<Rigidbody2D> ().gravityScale = 0.0f;
        player.GetComponent <Rigidbody2D> ().velocity = Vector2.zero;

        yield return(new WaitForSeconds(respawnDelay));

        if (!player.isDead())
        {
            player.transform.position  = new Vector3(currentCheckPoint.transform.position.x, currentCheckPoint.transform.position.y, player.transform.position.z);
            mainCam.transform.position = new Vector3(player.transform.position.x, player.transform.position.y, mainCam.transform.position.z);
            Instantiate(respawnParticle, player.transform.position, Quaternion.identity);
            player.gameObject.SetActive(true);
            player.GetComponent <Renderer> ().enabled = true;
            //player.GetComponent<Rigidbody2D>().gravityScale = gravityStore;
        }
        else
        {
            //saveBTsFitness();
            string currentScene = SceneManager.GetActiveScene().name;
            SceneManager.LoadScene(currentScene);
        }
    }
예제 #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         LightMasterController controller = other.gameObject.GetComponent <LightMasterController> ();
         controller.isOnExit = true;
     }
 }
예제 #3
0
 // Use this for initialization
 void Awake()
 {
     player            = FindObjectOfType <LightMasterController> ();
     currentCheckPoint = GameObject.FindGameObjectWithTag("StartPoint");
     respawnDelay      = 1.5f;
     gravityStore      = player.GetComponent <Rigidbody2D> ().gravityScale;
     mainCam           = Camera.main;
 }
예제 #4
0
 // Use this for initialization
 public void initManager()
 {
     //wormObjects = new List<WormBTController>();
     player            = FindObjectOfType <LightMasterController> ();
     currentCheckPoint = GameObject.FindGameObjectWithTag("StartPoint");
     respawnDelay      = 1.5f;
     gravityStore      = player.GetComponent <Rigidbody2D> ().gravityScale;
     //wormEvolver = FindObjectOfType<BTEvolver>();
     //wormEvolver.initEvolver();
 }