void Start() { health = 100; score = 0; updateScore(); gameOver = false; GameObject gameControlObject = GameObject.FindWithTag("ui"); if (gameControlObject != null) { gameOverScript = gameControlObject.GetComponent <GameOverScript>(); healthInstance = healthBarController.GetComponent <HealthBarController>(); healthInstance.setMaxHealth(100.0f); healthInstance.setHealth(100.0f); } if (gameControlObject == null) { Debug.Log("Sorry ,Couldn't find object"); } StartCoroutine(SpawnWaves()); StartCoroutine(spawnPowerUps()); }
protected new void Start() { base.Start(); status = StatusType.Live; if (showHealthBar) { var hb = Instantiate(Resources.Load(configs.prefabPaths.uiHealthbar), new Vector3(transform.position.x, transform.position.y - transform.lossyScale.y), Quaternion.identity) as GameObject; hb.transform.parent = transform; healthBar = hb.GetComponent <HealthBarController>(); healthBar.setHealth(health); healthBar.divider = health; healthBar.yMargin = healthBarYMargin; } OnHit += (o) => { if (o.hits != null && System.Array.IndexOf(o.hits, this.GetType()) > -1) { decHealth(o.damage); spriteRenderer.color = Color.red; CancelInvoke("switchBackToOriginalColor"); Invoke("switchBackToOriginalColor", .2f); } }; build(); }
// Start is called before the first frame update void Start() { health = 100; power = 100; //gameOver = false; GameObject gameControlObject = GameObject.FindWithTag("UI"); if (gameControlObject != null) { //gameOverScript = gameControlObject.GetComponent<GameOverScript>(); healthInstance = healthBarController.GetComponent <HealthBarController>(); powerInstance = powerBarController.GetComponent <PowerBarController>(); healthInstance.setMaxHealth(100.0f); healthInstance.setHealth(100.0f); powerInstance.setMaxPower(100.0f); powerInstance.setPower(100.0f); } if (gameControlObject == null) { Debug.Log("Sorry ,Couldn't find object"); } }
public void decHealth(int by) { health -= by; if (OnHealthChanged != null) { OnHealthChanged(health); } healthBar.setHealth(health); if (health <= 0) //DIE!!! { if (OnDie != null) { OnDie(); } Destroy(gameObject); } }
public void usePotion(int healedAmount) { //Todo: comprobar si el jugador tiene pociones en su inventario. //^Como en el prototipo no se ha planificado crear un inventario ni objetos coleccionables, las pociones son infinitas. exitCombatMenu(); //Sale del slow motion para realizar la accion health = health + healedAmount; health = Mathf.Clamp(health, 0, maxHealth); healthBar.setHealth(health); //Todo: play heal FX //Accion realizada playerInput.SwitchCurrentActionMap("Player"); //AUDIO AudioManager.engine.usePotion(); // }
public void TakeDamage() { healthLevel = healthLevel - 10; audio.PlayOneShot(painSound); healthBar.setHealth(healthLevel); }
void updateHealth(float health2) { healthInstance.setHealth(health2); }
protected new void Start() { base.Start(); status = StatusType.Live; if (showHealthBar) { var hb = Instantiate(Resources.Load(configs.prefabPaths.uiHealthbar),new Vector3(transform.position.x, transform.position.y - transform.lossyScale.y),Quaternion.identity) as GameObject; hb.transform.parent = transform; healthBar = hb.GetComponent<HealthBarController>(); healthBar.setHealth(health); healthBar.divider = health; healthBar.yMargin = healthBarYMargin; } OnHit += (o) => { if (o.hits!=null && System.Array.IndexOf(o.hits, this.GetType()) > -1 ){ decHealth(o.damage); spriteRenderer.color = Color.red; CancelInvoke("switchBackToOriginalColor"); Invoke("switchBackToOriginalColor", .2f); } }; build(); }