void Start() { gameTimer = this.gameObject.GetComponentInChildren <timer>(); this.gameObject.GetComponent <SpriteRenderer>().sprite = frog; life = 3; coin_counter = this.gameObject.GetComponentInChildren <coinCounter>(); if (playermovment.numclones == 0) { healthBar.SetMaxHealth(life); } GameObject ngr = GameObject.FindWithTag("Manager"); if (ngr) { _freezer = ngr.GetComponent <Freezer>(); _freezer.Reset(duration); } frogMove = this.gameObject.GetComponent <playermovment>(); levelText = GameObject.Find("game levels").GetComponent <text_announcments>(); }
//================================================================================= //=================================== Functions =================================== //================================================================================= void Start() { //get coincounter in order to add and keep track of coins //received from counter = FindObjectOfType <coinCounter>(); position = transform.position; //Set Health and Coins to Enemies depending on Tags if (gameObject.tag == "Spinning-blade") { health = 30f; coins = 10; } else if (gameObject.tag == "small-spinning-blade") { health = 10f; coins = 15; } else if (gameObject.tag == "big-spinning-blade") { health = 60f; coins = 20; } }
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(""); } }