public void Attack(int dmg) //damage player { DamageScreen.SetActive(true); playerHealth -= dmg; hpBar.SetHP(playerHealth); hpBar.UpdatePlayerBar(); //Debug.Log("HEALTH: " + playerHealth); Invoke("DisplayDamage", 0.1f); timeCheck = Time.time; }
public void RecieveDamage(float inflicted) //pass the amount of damage taken { targetHealth -= inflicted; //take damage off health hpBar.SetHP(targetHealth); if (targetHealth <= 0.0f) { ammoBoxRNG = Random.Range(1, 5); Vector3 deathPOS = this.gameObject.transform.position; TargetDie(); if (ammoBoxCount == 1 && ammoBoxRNG == 1) { GameObject ammoBoxGO = Instantiate(spawnAmmoBox, deathPOS + (Vector3.up * 1), Quaternion.identity); Destroy(ammoBoxGO, 60f); } if (PlayerMovement.increasePoisonCharge) //count kills during starstone effects { FixGeneratorScript.poisonKills += 1; } if (PlayerMovement.increaseSpeedCharge) { FixGeneratorScript.speedKills += 1; } if (PlayerMovement.increaseSnareCharge) { FixGeneratorScript.snareKills += 1; } if (PlayerMovement.increaseFloatCharge) { FixGeneratorScript.floatKills += 1; } if (FixGeneratorScript.poisonKills == 15) //have to get 15 kills to drop part { GameObject poisonCogGO = Instantiate(poisonCog, deathPOS + (Vector3.up * 1), Quaternion.identity); FixGeneratorScript.poisonKills += 1; } if (FixGeneratorScript.speedKills == 15) { GameObject speedCogGO = Instantiate(speedCog, deathPOS + (Vector3.up * 1), Quaternion.identity); FixGeneratorScript.speedKills += 1; } if (FixGeneratorScript.snareKills == 15) { GameObject snareCogGO = Instantiate(snareCog, deathPOS + (Vector3.up * 1), Quaternion.identity); FixGeneratorScript.snareKills += 1; } if (FixGeneratorScript.floatKills == 15) { GameObject floatCogGO = Instantiate(floatCog, deathPOS + (Vector3.up * 1), Quaternion.identity); FixGeneratorScript.floatKills += 1; } //Debug.Log(FixGeneratorScript.poisonKills); } }
// Update is called once per frame void Update() { if (Time.time > abilityUp) //Used to check whether the time conditions for the defensive ability are met { if (Input.GetKeyDown(KeyCode.U) && PlayerStats.playerHealth <= 100) //allows the player to activate shield with the U key only if the player is at 100 health or lower { PlayerStats.playerHealth += 50; abilityUp = Time.time + cooldownDefensive; print("defensive ability used"); currentHP = PlayerStats.playerHealth; HealthBar.SetHP(currentHP); HealthBar.UpdatePlayerBar(); } } }
public void SetHP(int amount) { hpScript.SetHP(amount); }