private void ClearPopup() { healthChange = 0; popupText.text = ""; currentPopupType = DamagePopupType.None; popupTimer = popupDuration; }
public static DamagePopup Create(Vector3 position, int damageAmount, DamagePopupType damageType) { Transform damagePopupTransform = Instantiate(GameAssets.Instance.pfDamagePopup, position, Quaternion.identity).transform; DamagePopup damagePopup = damagePopupTransform.GetComponent <DamagePopup>(); damagePopup.Setup(damageAmount, damageType); return(damagePopup); }
public void UpdatePopup(DamagePopupType popupType, float amount) { //if new incoming damage/heal isn't 0 if (amount > 0) { //if displayed damage/heal isn't 0, add new incoming damage/heal to it and reset timer if (healthChange > 0 && popupType == currentPopupType) { healthChange += amount; popupTimer = popupDuration; } //else, just display new incoming damage else { healthChange = amount; currentPopupType = popupType; SetPopupColor(); } popupText.text = healthChange.ToString("n0"); } }
public void Setup(int popupAmount, DamagePopupType damageType) { if (damageType == DamagePopupType.Blocked) { //Blocked Hit textMesh.SetText("Block"); textMesh.fontSize = 25; textColor = new Color(72, 219, 255); } else if (damageType == DamagePopupType.Heal) { //Healing textMesh.SetText(popupAmount.ToString()); textMesh.fontSize = 18; textColor = Color.green; } else if (damageType == DamagePopupType.Critical) { //Critical Hit textMesh.SetText(popupAmount.ToString() + "!"); textMesh.fontSize = 25; textColor = new Color(255, 197, 0); } else if (damageType == DamagePopupType.Damage) { //Regular Damage textMesh.SetText(popupAmount.ToString()); textMesh.fontSize = 18; textColor = Color.red; } textMesh.color = textColor; disappearTimer = DISSAPEAR_TIMER_MAX; sortingOrder++; textMesh.sortingOrder = sortingOrder; moveVector = new Vector3(1f, 0.2f) * 3f; }
public virtual void HandleHealthChange(DamagePopupType popupType, float amount) { damagePopup.UpdatePopup(popupType, amount); }
public override void HandleHealthChange(DamagePopupType popupType, float amount) { base.HandleHealthChange(popupType, amount); sliderBar.UpdateSlider(character.characterInfo.health.GetCurrentValue()); }