public void damagePlayer(int damageAmt) { for (int i = 0; i < damageAmt; i++) { if (numShields > 0) { Destroy(shieldCells [--numShields].gameObject); if (numShields == 0) { shieldToggle.hide(); } } else { playerHP.Damage(1); //replace full cell with empty cell Vector2 cellLocation = new Vector2(HPBarPosition.x + (HPCellSpacing * lastFullCell), HPBarPosition.y); Destroy(HPCells [lastFullCell].gameObject); HPCells[lastFullCell] = Instantiate(HPCellEmpty, cellLocation, Quaternion.identity); lastFullCell--; } if (lastFullCell < 0) { break; } } }
private void OnHit(int damage) { hp.Damage(damage); if (!hp.IsAlive()) { gameObject.SetActive(false); onHandleDeath.Invoke(); } }