// Update is called once per frame void Update() { if (!_oscillating) { return; } if (_factorGrowing) { if (_powerFactor + (float)(Time.deltaTime * 1.5) > _factorUpperBound) { _powerFactor = _factorUpperBound; _factorGrowing = false; } else { _powerFactor += (float)(Time.deltaTime * 1.5); } // print(_powerFactor); healthbar.SetHealth(GetPercentage(_powerFactor)); } else { if (_powerFactor - (float)(Time.deltaTime * 1.5) < _factorLowerBound) { _powerFactor = _factorLowerBound; _factorGrowing = true; } else { _powerFactor -= (float)(Time.deltaTime * 1.5); } // print(_powerFactor); healthbar.SetHealth(GetPercentage(_powerFactor)); } }
private void Start() { data.isAlive = true; healthbar.SetMaxHealth(data.maxHealth); healthbar.SetHealth(data.health); StartCoroutine(ShootingCoroutine()); if (data.boolSettings["SwipeMovement"]) { inputLayer.OnBeginDragAction += StartOffsetMovement; inputLayer.OnDragAction += DoOffsetMovement; } else { inputLayer.OnPointerDownAction += MouseFollowMovement; inputLayer.OnDragAction += MouseFollowMovement; } transform.localScale *= data.scaling; //if (!data.boolSettings["PlayMusic"]) //{ // audioSourceMusic.volume = 0; //} particleSystemFire1.Play(); particleSystemFire2.Play(); SetVolumes(); SetPlayerColor(); }
void TakeDamage(int damge) { currentHealth -= damge; if (currentHealth < minHealth) { currentHealth = minHealth; } healthBar.SetHealth(currentHealth); }
// Start is called before the first frame update void Start() { isRateIncreasing = true; quarantineTraker.SetMaxHealth(deathTreshold); lastIncreaseTime = Time.time; quarantineEnabled = false; virusCount = 0; quarantineTraker.SetHealth(virusCount); }
public void Heal(int amount) { currentHealth += amount; if (currentHealth > maxHealth) { currentHealth = maxHealth; } healthbar.SetHealth(currentHealth); }
public void HealToFull() { health = info.maxHealth; if (healthbar == null && _terrainInfo != null) { return; } healthbar.SetHealth(health, info.maxHealth); }
void TakeDamage(int damage) { if (currentHealth > 0) { currentHealth -= damage; healthbar.SetHealth(currentHealth); //Sets our animator to show "damage taken" animator.SetTrigger("playerHurt"); } }
public void RecieveDamage(float damageTaken) { health -= Mathf.FloorToInt(damageTaken); healthBar.SetHealth(health); if (health <= 0f) { Death(); } }
void UpdateFood() { if (foodLvl.health > 0) { foodLvl.SetHealth(foodLvl.health - 10); } if (foodLvl.health <= 0) { healthLvl.SetHealth(healthLvl.health - 25f); } }
void TakeDamage(int damage) { Animator.SetBool("hurt", true); currentHealth -= damage; Healthbar.SetHealth(currentHealth); StartCoroutine(AnimationDisableCoroutine()); }
private void Electrocute() { m_Healthbar.SetHealth(0); m_Animator.SetTrigger("Electrocuted"); m_Rigidbody2D.velocity = new Vector2(0, 0); m_Rigidbody2D.gravityScale = 0; }
IEnumerator Init() { yield return(new WaitForSeconds(0.5f)); oxygenLvl = GameObject.Find("oxygenValue").GetComponent <Healthbar>(); healthLvl = GameObject.Find("healthValue").GetComponent <Healthbar>(); powerLvl = GameObject.Find("powerValue").GetComponent <Healthbar>(); suitTempLvl = GameObject.Find("suitTempValue").GetComponent <Healthbar>(); foodLvl = GameObject.Find("hungerValue").GetComponent <Healthbar>(); tempText = GameObject.Find("tempValue").GetComponent <Text>(); playerAstronaut = GameObject.Find("Player_Astronaut"); InvokeRepeating(nameof(UpdateOxygen), 4, 4.0f); InvokeRepeating(nameof(UpdatePower), 60, 180); InvokeRepeating(nameof(UpdateTemp), 0, 5.0f); InvokeRepeating(nameof(UpdateSuitTemp), 0, 5.0f); InvokeRepeating(nameof(UpdateFood), 120, 120); oxygenLvl.SetHealth(100); healthLvl.SetHealth(100); powerLvl.SetHealth(100); foodLvl.SetHealth(100); temp = 100f; }
private void Awake() { enemy = GetComponent <Enemy>(); healthbar.maximumHealth = enemy.Hp; healthbar.health = enemy.Hp; enemy.OnHpChanged += (hp) => healthbar.SetHealth(hp); }
void onUpdate(GameObject obj, Healthbar bar) { if (inspector.setScriptsFrom(obj)) { bar.SetHealth(inspector.getLives()); } }
void Start() { currentHealth = maxHealth / 2; currentArmor = 0f; gasOn = false; if (SaveManager.instance.hasLoaded) { currentHealth = SaveManager.instance.activeSave.health; currentArmor = SaveManager.instance.activeSave.armor; gasOn = SaveManager.instance.activeSave.gasOn; } healthBar.SetMaxHealth(maxHealth); healthBar.SetHealth(currentHealth); armorBar.SetMaxArmor(maxArmor); armorBar.SetArmor(currentArmor); }
void Update() { staminaBar.SetHealth((int)stamina); staminaText.text = (int)stamina + "/" + (int)maxStamina; timer += Time.deltaTime; movement.x = joystick.Horizontal; movement.y = joystick.Vertical; if (movement.x != 0) { memoryMovementX = movement.x; } if (movement.x == 0 && movement.y == 0) { resetNeeded = false; } if (joystick.Direction.sqrMagnitude >= distanceFromCenterToRun && stamina > 0 && !resetNeeded) { isRunning = true; animator.SetBool("isRunning", true); } else if (joystick.Direction.sqrMagnitude >= distanceFromCenterToRun && stamina == 0) { resetNeeded = true; isRunning = false; animator.SetBool("isRunning", false); } else { isRunning = false; animator.SetBool("isRunning", false); } if (memoryMovementX < 0) { GetComponent <SpriteRenderer>().flipX = true; } else { GetComponent <SpriteRenderer>().flipX = false; } if (timer >= 1) { if (isRunning) { stamina -= staminaLostOnRun; } if (!isRunning && stamina < maxStamina) { stamina += staminaGainedOnRest; } timer = 0; } animator.SetFloat("Speed", joystick.Direction.sqrMagnitude); }
// Update is called once per frame void Update() { healthText = playerCombat.currentHealth + "/" + playerCombat.maxHealth; setHpText(healthText); playerHealthbar.SetHealth(playerCombat.currentHealth); attackSpeedBarUpdate(); }
void TakeDamage(int damage) { currentHealth -= damage; healthbar.SetHealth(currentHealth); if (currentHealth == 10) { InvokeRepeating("Fire", 3, 5f); } if (currentHealth == 7) { // InvokeRepeating("Fire", 3, 5f); CancelInvoke(); } if (currentHealth <= 5) { InvokeRepeating("Fire", 3, 5f); } if (currentHealth <= 0) { Destroy(bossone); Transform newExplosion = Instantiate(B1explosion, transform.position, transform.rotation); Destroy(newExplosion.gameObject, 6.5f); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag.Equals("Enemy")) { currenthealth = currenthealth - damage; healthbar.SetHealth(currenthealth); } }
void TakeDamage(int damage) { if (currentHealth > 0) { currentHealth -= damage; healthbar.SetHealth(currentHealth); } }
public virtual void Update() { if (healthbar) { healthbar.SetHealth(GetHealthPercentage()); healthbar.transform.position = Camera.main.WorldToScreenPoint(transform.position + Vector3.right * width / 2f + Vector3.right); } }
void OnTriggerEnter2D(Collider2D other) { if (other.name == "NewPC") { PlayerHealth.SetHealth(PlayerHealth.CurrentValue - 10); LevelManager.RespawnPlayer(); } }
//fall sem lætur leikmann fá damage void TakeDamage(int damage) { currentHealth -= damage; healthbar.SetHealth(currentHealth); if (currentHealth <= 0) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }
private void UpdateHealth() { if (currentHealth < 6) { currentHealth = 6; } healthbar.SetHealth(currentHealth, maxHealth); }
public void TakeDamage() { int damage = 10; health = Max(health - damage, 0); animator.SetInteger("Health", health); animator.SetTrigger("TookDamage"); healthbar.SetHealth(health); }
public void TakeDamage(int damage) { //Increase the affection with the amount of damage the player takes currentAffection += damage; healthBar.SetHealth(currentAffection); //If affection reaches 10, player gets "stunned" by love if (currentAffection == maxAffection) { playerStunned = true; movement2.enabled = false; Rigidbody2D rb = gameObject.GetComponent <Rigidbody2D>(); rb.constraints = RigidbodyConstraints2D.FreezeAll; Debug.Log("Stunned"); StartCoroutine("StunDuration"); heartBig.SetActive(true); Destroy(gameObject); } }
//Getter und Setter public void TakeDamage(int damage) { currentHealth -= damage; healthbar.SetHealth(currentHealth); //if <= 0 do kill, gamehandler check ob alle units kill, then if yes win for other player if (currentHealth <= 0) { SetAlive(false); } }
public void AttackDamageRecieved(int damage) { // Takes damage when in a certain range if (InRange(100f)) { health -= damage; healthBar.SetHealth(health); healthBar.gameObject.SetActive(true); } }
private void Start() { healthbar.maximumHealth = playerData.maxHp; healthbar.health = playerData.maxHp; Enemy.OnAnyEnemyDie += () => AddKillCount(); PlayerData.inst.OnDamaged += (dmg) => OnPlayerDamaged(dmg); PlayerData.inst.OnHpUpdated += (value) => healthbar.SetHealth(value); PlayerData.inst.OnDied += () => OnPlayerDied(); }
void Start() { gameMaster = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); move = GetComponent <MoveableObject>(); live = GetComponent <LiveThing>(); anim = GetComponent <Animator>(); player = gameMaster.GetPlayer(); healthbar.SetMaxHealth(live.health.initValue); healthbar.SetHealth(live.health.initValue); }