public void Configure(ShieldConfig config) { ShieldConfig = config; SpriteRenderer.sprite = config.Sprite; CurrentEnergy = config.Energy; OnChangeEnergyEvent?.Invoke(); }
public void IncreaseEnergy(int value) { int valueToIncrease = Mathf.Abs(value); if (!gameObject.activeInHierarchy) { gameObject.SetActive(true); LeanTween.alpha(gameObject, 0, 0); LeanTween.alpha(gameObject, 1, 1); } CurrentEnergy += value; if (CurrentEnergy > MaxEnergy) { CurrentEnergy = MaxEnergy; } OnChangeEnergyEvent?.Invoke(); return; }
public void DecreaseEnergy(int value) { if (!_Indestructible) { int valueToDecrease = Mathf.Abs(value); CurrentEnergy -= valueToDecrease; LeanTween.alpha(gameObject, 0.6f, 0.04f).setLoopPingPong(Random.Range(2, 8)); //LeanTween.alpha(gameObject, 1, 1); if (CurrentEnergy <= 0) { CurrentEnergy = 0; gameObject.SetActive(false); } else { Coroutiner.Start(Cooldown()); } OnChangeEnergyEvent?.Invoke(); } return; }