// Start is called before the first frame update void Start() { highScoreData = XMIManager.ReadData(); if (highScoreData != null) { EnemyHandler.highScore = highScoreData.highScore; } else { highScoreData = new HighScores(); } //healthCanvas = GameObject.FindGameObjectWithTag(healthCanvas); healthBar = GameObject.FindGameObjectWithTag("healthBar").GetComponent <Image>(); isDead = false; death.SetActive(false); curHealth = 2900; }
// Update is called once per frame void Update() { if ((curHealth / maxHealth) != healthBar.fillAmount) { healthBar.fillAmount = (curHealth / maxHealth); } if (curHealth <= 0) { isDead = true; death.SetActive(true); } else if (curHealth >= 0) { isDead = false; } if (Input.GetKeyDown(KeyCode.R) || isDead) { EnemyHandler.killPlayer = false; highScoreData.highScore = EnemyHandler.highScore; XMIManager.WriteData(highScoreData); EnemyHandler.score = 0; menu.ChangeScene(1); } if (!Input.GetKeyDown(KeyCode.R)) { } else { Scene activeScene = SceneManager.GetActiveScene(); SceneManager.LoadScene(activeScene.buildIndex); } //if (healthBar.fillAmount < 1 && healthBar.fillAmount > 0) //{ // healthCanvas.transform.LookAt(Camera.main.transform); // healthCanvas.transform.Rotate(0, 180, 0); //} }