// Update is called once per frame public float Playertakedamage(float health) { health -= Se.EnemyDamage; healthBar.UpdateBar(health, maxhealth); return(health); }
private void Update() { if (reloading == true) { if ((int)Time.time - reloadstarttimer == reloadtime) { reloading = false; ammoleft = ammocount; ammotext.text = ammoleft.ToString(); ammoBar.UpdateBar(ammoleft, ammocount); } } if (Input.GetKey("space") && reloading == false) { if (playershooting.enabled == false) { ammoleft = ammoleft - 1f; ammotext.text = ammoleft.ToString(); ammoBar.UpdateBar(ammoleft, ammocount); } playershooting.enabled = true; if (ammoleft == 0f) { reloadstarttimer = (int)Time.time; reloading = true; } } else { playershooting.enabled = false; } }
// Update is called once per frame public void Start() { startingHealth = 100; currentHealth = startingHealth; healthBar.UpdateBar(startingHealth, currentHealth); // A1=GetComponent<AudioSource>(); }
public void Init() { if (GetComponent <PlayerInput>().isActiveAndEnabled == false) { GetComponent <PlayerInput>().enabled = true; } if (GetComponent <PlayerController>().isActiveAndEnabled == false) { GetComponent <PlayerController>().enabled = true; } if (transform.GetComponentInChildren <PlayerAttack>().isActiveAndEnabled == false) { transform.GetComponentInChildren <PlayerAttack>().enabled = true; } _healthPoint = _maxHp; _manaPoint = 100; _isPlayerDeath = false; _isDamageable = true; _healthBar.UpdateBar(_healthPoint, _maxHp); }
private void Attack() { var currTriggerList = attackCollider.TriggerList; foreach (var other in attackCollider.TriggerList) { if (other.gameObject.tag == "enemy") { Destroy(other.gameObject); FindObjectOfType <AudioManager>().Play("Kill"); count2++; } else if (other.gameObject.tag == "shotgunGuy") { FindObjectOfType <AudioManager>().Play("Kill"); Instantiate(healthPack, (Vector2)other.transform.position, Quaternion.identity); Destroy(other.gameObject); } else if (other.gameObject.tag == "bullet") { health += bulletHealthDecrease; healthBar.UpdateBar(health, 100f); Bullet bullet = other.gameObject.GetComponent <Bullet>(); bullet.direction = lookDir.normalized; bullet.isDeflected = true; FindObjectOfType <AudioManager>().Play("Deflect"); } } }
private void OnTriggerStay2D(Collider2D other) { if (other.gameObject.CompareTag("Pilot")) { if (Input.GetMouseButtonDown(1) && !Sc.GrabberOn) { if (Cp.food != Cp.initialFood && shipRes.food > 5) { var diff = Cp.initialFood - Cp.food; if (diff < 5) { incHealthEffect.Play(); Cp.food += diff; shipRes.food -= diff; var current = shipRes.food; var max = shipRes.initialFood; foodBar.UpdateBar(current, max); } else { incHealthEffect.Play(); shipRes.food -= 5; var current = shipRes.food; var max = shipRes.initialFood; foodBar.UpdateBar(current, max); Cp.food += 5; } } //Remove from shipRes //Debug.Log("minus ship res"); } } }
public void AddPlayerHealthPoint(int hurtDamage, int caseHeal) { if (caseHeal == 0) { cameraController.StopAllCoroutines(); cameraController.StartCoroutine(cameraController.ShakeCamera(0.1f, 0.05f)); playerStatistics.AddCharactorHealthPoint(hurtDamage); if (playerStatistics.HP > 0) { CurPlayerStatus(PlayerState.Player_Hurt); } else if (playerStatistics.HP <= 0) { playerStatistics.HP = 0; playerDeath = true; CurPlayerStatus(PlayerState.Player_Death); StartCoroutine(PlayerDeath()); } } else if (caseHeal == 1) { playerStatistics.DrinkPotion(hurtDamage); } healthBar.UpdateBar(playerStatistics.HP, playerStatistics.hpMax); healthBar.transform.GetChild(0).GetComponent <Text>().text = playerStatistics.HP.ToString() + "/" + playerStatistics.hpMax.ToString(); }
// Start is called before the first frame update void Start() { currentHealth = 10f; //Remove later healthbar.UpdateBar(currentHealth, maxHealth); anim = this.GetComponent <Animator>(); }
// Update is called once per frame void FixedUpdate() { if (IsDead()) { healthBar.UpdateBar(CurrentHealth, MaximumHealth); return; } isGrounded = IsGrounded(); if (!control) { return; } if (CheckStun()) { return; } HandleMovement(); FlipPlayer(); //Handle Attacks ResetValues(); healthBar.UpdateBar(CurrentHealth, MaximumHealth); }
void Start() { rb2d = GetComponent <Rigidbody2D>(); currentLife = startLife; healthBar.UpdateBar(currentLife, maxHealth); }
private void Start() { expBar.UpdateBar(_currExp, expToNextLevel); levelText.text = "Level: " + _level.ToString(); health = GetComponentInParent <Health>(); playerAttack = GetComponentInChildren <PlayerAttack>(); }
public void UpdateHealth() { healthBar.UpdateBar(health, maxHealth); if (health <= 0) { SceneManager.LoadScene("Dead"); } }
// Use this for initialization void Start() { maxShield = maxHealth / 2; currentHealth = maxHealth; currentShield = maxShield; healthBar.UpdateBar(currentHealth, maxHealth); healthBar.UpdateBar(currentShield, maxShield); }
// Use this for initialization void Start() { Cursor.lockState = CursorLockMode.None; Cursor.visible = false; controller = GameObject.FindObjectOfType <FirstPersonController>(); dmgTaken = false; healthBar2.UpdateBar(currentHealth, maxHealth); }
// Use this for initialization void Start() { //MaxHp = getMaxHp(); //Hp = getHp(); gameObject.layer = LayerMask.NameToLayer("Ignore Raycast"); fireSpawn = transform.GetChild(0).GetChild(0).transform; healthBar.UpdateBar(Hp, MaxHp); }
// Start is called before the first frame update void Start() { currentHealth = maxHealth; currentMana = maxMana; healthBar.UpdateBar(currentHealth, maxHealth); manaBar.UpdateBar(currentMana, maxMana); }
void Update() { // Run the CheckExitScreen function to see if the player has left the screen. CheckExitScreen(); // If the user cannot control the player, then return. if (canControl == false) { return; } // Store the input positions rotation = Input.GetAxis("Horizontal"); acceleration = Input.GetAxis("Vertical"); if (canShoot == true) { // If the shooting button is being used... if (Input.GetMouseButton(0)) { // If the gun is not overheated, then increase the timer. if (overheatTimer < overheatTimerMax) { overheatTimer += Time.deltaTime; } // Else the gun has overheated, so start the overheat coroutine. else { canShoot = false; StartCoroutine("DelayOverheat"); } if (shootingTimer <= 0) { // Then reset the timer and shoot a bullet. shootingTimer = shootingCooldown; CreateBullets(); } } else { if (overheatTimer > 0) { overheatTimer -= Time.deltaTime * cooldownSpeed; } } gunHeatBar.UpdateBar(overheatTimer, overheatTimerMax); } // If the shoot timer is above zero, reduce it. if (shootingTimer > 0) { shootingTimer -= Time.deltaTime; } Aiming(); }
public void Init(int max) { maxHealth = max; currHealth = max; displayHealth = max; healthBar.UpdateBar(currHealth, maxHealth); textMeshPro.text = currHealth + "/" + maxHealth; }
public void HealthUpdate(float value) { if (health == maxHealth || health >= value) { health = value; } maxHealth = value; healthBar.UpdateBar(health, maxHealth); }
virtual public void Start() { animator = GetComponentInChildren<Animator>(); currhealth = maxHealth; if (hasHealthBar) { healthBar.UpdateBar(currhealth, maxHealth); } }
void Start() { // Set the current health and shield to max values. currentHealth = maxHealth; currentShield = maxShield; // Update the Simple Health Bar with the updated values of Health and Shield. healthBar.UpdateBar(currentHealth, maxHealth); shieldBar.UpdateBar(currentShield, maxShield); }
void Start() { //Initialize Player currentHealth = maxHealth; currentOxygen = maxOxygen; // Update Health Bar with the updated values of Health and Oxygen healthBar.UpdateBar(currentHealth, maxHealth); oxygenBar.UpdateBar(currentOxygen, maxOxygen); }
void Start() { // PARA ESTABLECER LA VIDA MAXIMA Y EL ESCUDO currentHealth = maxHealth; Escudito = maxEscudito; // SE van actualizando la vida y los escudos healthBar.UpdateBar(currentHealth, maxHealth); shieldBar.UpdateBar(Escudito, maxEscudito); }
void UpdatePower() { m_CurrPower += m_AdjustSpeed * Time.deltaTime; m_CurrPower = Mathf.Clamp(m_CurrPower, 0.0f, MAX_POWER); if (m_CurrPower == 0 || m_CurrPower == MAX_POWER) { m_AdjustSpeed = -m_AdjustSpeed; } m_SimpleBar.UpdateBar(m_CurrPower, MAX_POWER); }
// Use this for initialization void Start() { playerRigidbody = GetComponent <Rigidbody2D>(); currHealth = maxHealth; healthBar.UpdateBar(currHealth, maxHealth); specialAvailable = false; }
public void attack() { if (currentEnergy > attackCost) { currentEnergy -= attackCost; energyBar.UpdateBar(currentEnergy, maxEnergy); rayo.SetActive(true); Invoke("apagaRayo", 0.5f); } }
void Start() { // Set the current health max currentHealth = maxHealth; // Update the Simple Health Bar with the updated value of Health healthBar.UpdateBar(currentHealth, maxHealth); //sheildBar.UpdateBar(currentHealth, maxHealth); game = GameManager.Instance; }
void Start() { blockrend = holdingBlock.GetComponent <Renderer>(); GlobalVariables.currentHP = 100; GlobalVariables.kills = 0; GlobalVariables.coins = 0; PlayerController = GetComponent <CharacterController>(); Cursor.visible = false; healthBar.UpdateBar(currHp, maxHp); startRotSword = armsSword.transform.localRotation; }
// Use this for initialization void Start() { playerRigidbody = GetComponent <Rigidbody2D>(); currHealth = maxHealth; healthBar.UpdateBar(currHealth, maxHealth); specialAvailable = false; retryButton.SetActive(false); }
public void GetAttacked(float decrease) { towerCurrentHealth -= decrease; if (towerCurrentHealth <= 0) { Die(); } else { healthBar.UpdateBar(towerCurrentHealth, towerTotalHealth); } }