private void UpdateHungerUI() { health = DragonAIScript_.health; float percentage = health / (float)max_health; float x = width * percentage; HungerBar.localPosition = new Vector3(0, -x, 0); if (health == 0) { //StartCoroutine("EndLevel"); DragonAIScript_.isFed = true; int temp1 = max_health; int temp2 = DragonAIScript_.dragonlength; GameObject obj = Instantiate(dragonhead, Respawn, Quaternion.identity); obj.name = "dragonhead"; DragonAIScript_ = obj.GetComponent <DragonAIScript>(); DragonAIScript_.dragonlength = temp2 + 1; DragonAIScript_.health = temp1 + 10; max_health = DragonAIScript_.health; health = DragonAIScript_.health; GameObject.Find("DontDestroyOnLoad").GetComponent <ScoreLevelScript>().RaiseLevel(); } if (Input.GetKeyDown("k")) { DragonAIScript_.health = 0; } }
void Start() { max_x = 7; max_y = 3; min_x = -8; min_y = -3; DragonAIScript_ = GameObject.Find("dragonhead").GetComponent <DragonAIScript>(); Transition = GameObject.Find("TransitionCanvas"); SceneTransition = Transition.GetComponent <SceneTransitionScript>(); max_health = DragonAIScript_.health; InvokeRepeating("SpawnFood", 2f, 2f); StartCoroutine("StartLevel"); }