public void RestartGame() { Debug.Log("RESTART"); //EditorApplication.isPlaying = false; timer gameTimer = GameObject.FindWithTag("timer").GetComponent <timer>(); Debug.Log("RESTART"); gameTimer.restart(0.2f); }
void checkDead() { if (healthBar.GetLife() == 0) { dieSound(); changeImage(); //audioSrc.PlayOneShot(splatSound); //this.gameObject.GetComponent<SpriteRenderer>().sprite = splash; //_freezer.Freeze(); frogMove.enabled = false; //_freezer.freezebackMusic(); audioSrc.PlayOneShot(trombone); Debug.Log("You loose!"); //timer gameTimer = this.gameObject.GetComponentInChildren<timer>(); //gameTimer.waitForSong(trombone); Debug.Log("trombone.lengt: " + trombone.length); isDead = false; frogMove.RemoteSettingsnumClones(); gameTimer.restart(trombone.length); } }
public string levelPoint(string name) { if (name == "level2" && countlevel2 == 0) { startPos = rb.position;//tofo check if works countlevel2++; easyrotateControls(); Debug.Log("easy controls rotate"); audioSrc.PlayOneShot(levelup); return("Keys rotation!!"); } if (name == "level2.5" && countlevel2H == 0) { startPos = rb.position;//tofo check if works countlevel2H++; hardrotateControls(); Debug.Log("hard controls rotate,startPos: " + startPos); return("CRAZY KEYS ROTATION!!"); } if (name == "level3" && countlevel3 == 0) { startPos = rb.position;//tofo check if works countlevel3++; normalControlls(); Debug.Log("normal controls,startPos: " + startPos); audioSrc.PlayOneShot(levelup); //spawn if (numclones == 0) { GameObject clone = Instantiate(frog, spawnPoint1.position, spawnPoint1.rotation); rb.position = spawnPoint2.position; startPos = new Vector2(spawnPoint2.position.x, spawnPoint2.position.y); Debug.Log("in spawn, this startPos " + startPos); Vector2 start = new Vector2(spawnPoint1.position.x, spawnPoint1.position.y); clone.GetComponent <playermovment>().setStartPoint(start); Debug.Log("in spawn, spawn startPos " + start); gameObject.AddComponent <FixedJoint2D>(); gameObject.GetComponent <FixedJoint2D>().connectedBody = clone.GetComponent <Rigidbody2D>(); clone.gameObject.GetComponent <Frog>().healthBar = gameObject.GetComponent <Frog>().healthBar; foreach (Transform child in clone.transform) { GameObject.Destroy(child.gameObject); } coinCounter co = gameObject.GetComponent <Frog>().coin_counter; clone.gameObject.GetComponent <Frog>().coin_counter = gameObject.GetComponent <Frog>().coin_counter; co = clone.gameObject.GetComponent <Frog>().coin_counter; clone.gameObject.GetComponent <playermovment>().jump = null; clone.gameObject.GetComponent <playermovment>().levelup = null; clone.gameObject.GetComponent <playermovment>().winSound = null; clone.gameObject.GetComponent <playermovment>().rb = clone.GetComponent <Rigidbody2D>(); clone.gameObject.GetComponent <Frog>().gameTimer = gameObject.GetComponent <Frog>().gameTimer; numclones = 1; } Vector3 vec = new Vector3(-2, 0, 0); GameObject camera = GameObject.Find("Main Camera"); camera.gameObject.GetComponent <CameraControler>().shiftOffset(vec); return("TWINZIES!"); } if (name == "win") { audioSrc.PlayOneShot(winSound); Debug.Log("Youve won!"); //Scene scene = SceneManager.GetActiveScene(); //SceneManager.LoadScene(scene.name); this.gameObject.GetComponent <playermovment>().enabled = false; timer gameTimer = this.gameObject.GetComponentInChildren <timer>(); //gameTimer.waitForSong(winSound); Debug.Log("winSound.lengt: " + winSound.length); gameTimer.restart(winSound.length); return("YOU WIN!!"); } else { return(""); } }