/* * private void OnDrawGizmos() { * Gizmos.color = Color.green; * Vector3 temp = new Vector3(5,0); * * Gizmos.DrawLine(transform.position + new Vector3(-0.3f,0), transform.position + new Vector3(-0.3f,0) + Vector3.down * 0.8f); * Gizmos.DrawLine(transform.position + new Vector3(0.3f,0), transform.position + new Vector3(0.3f,0) + Vector3.down * 0.8f); * Gizmos.DrawLine(transform.position, transform.position + Vector3.down * 0.8f); * } */ // private PlayerInfo playerInfo = new PlayerInfo(); private void OnCollisionEnter2D(Collision2D col) { if (col.gameObject.tag == "DeathCollider") { playerInfo.DecreaseLives(); if (Level9LonelySpikeBall != null) { Level9LonelySpikeBall.SetStartingPosition(); } Debug.Log("Lives: " + playerInfo.playerLives); // Kun menettää elämän, niin menee checkpointin positioon gameObject.transform.position = gameMaster.lastCheckpoint; for (int i = 0; i < movingSpikes.Length; i++) { movingSpikes[i].transform.position = originalPos[i]; } Debug.Log("Player spawned at: " + gameObject.transform.position); if (playerInfo.PlayerDead()) { deadScreen.SetActive(true); Time.timeScale = 0f; // deathScreen.SetActive(true); } } }
public void Restart() { if (level9LonelySpikeBall != null) { level9LonelySpikeBall.SetStartingPosition(); } gameMaster.lastCheckpoint = gameMaster.startCheckpoint; playerInfo.ResetLives(); ScoreScript.ResetLevel(); GameIsPaused = false; Time.timeScale = 1f; SceneManager.LoadScene(SceneManager.GetActiveScene().name); Debug.Log("Restarted Scene"); }