private void FixedUpdate() { // if (Vector2.Distance(transform.position , PoziceHrace.position) > 1) { // transform.position = Vector2.MoveTowards(transform.position, PoziceHrace.position, enemy.rychlost * Time.deltaTime); // } if (Vector2.Distance(transform.position, PoziceHrace.position) < 1.5) { if (hrac.zivoty > 0 && Time.time > _pomocna) { hit.Play(); hrac.ChangeHp(-enemy.dmg); _pomocna = Time.time + 0.5f; } } }
void potionCol() { if (Input.GetKeyDown(KeyCode.F) && hrac.potiony >= 1 && hrac.zivoty < hrac.zivotyMax) { coolDown4 = true; if (potion.fillAmount == 0) { potion.fillAmount = 1; } hrac.potiony -= 1; hrac.potioinAmount.text = hrac.potiony.ToString(); hrac.potioinAmount.color = Color.white; hrac.ChangeHp(hrac.zivotyMax / 4); } if (coolDown4) { potion.fillAmount -= 0.01f * Time.deltaTime; if (potion.fillAmount <= 0.9) { hrac.potioinAmount.color = Color.black; } if (potion.fillAmount <= 0) { potion.fillAmount = 0; hrac.potiony += 1; hrac.potioinAmount.text = hrac.potiony.ToString(); hrac.potioinAmount.color = Color.black; if (hrac.potiony == 3) { coolDown4 = false; } else { potion.fillAmount = 1; } } } }