public void ShowHitEffect(Vector3 position) { GameObject showHit = HitEffectsPool.GetObject(); showHit.transform.position = position; showHit.transform.rotation = Quaternion.identity; showHit.SetActive(true); }
public void ShowDamage(float damage, Vector3 position, bool crit = false) { //Vector3 tempTransform = transform.position; //randomize damage number position /*Vector3 tempPos = transform.position; * tempPos.x += Random.Range(-.1f, .1f); * tempPos.y += Random.Range(-.9f, .1f);*/ float fontSize = 1.2f; GameObject showDmg = TextPopupsPool.GetObject(); showDmg.transform.position = position; showDmg.transform.rotation = Quaternion.identity; showDmg.SetActive(true); showDmg.GetComponent <TextMeshProUGUI>().fontSize = fontSize; //resetting to normal font size if (damage > 0) { if (crit) { showDmg.GetComponent <TextMeshProUGUI>().color = new Color32(255, 70, 0, 255); //orange text //255, 120 showDmg.GetComponent <TextMeshProUGUI>().fontSize = fontSize * 1.5f; //showDmg.GetComponent<Animator>().SetBool //showDmg.GetComponent<TextMeshProUGUI>().color = new Color32(255, 0, 0, 255); //red text } else { showDmg.GetComponent <TextMeshProUGUI>().color = new Color32(255, 255, 255, 255); //white text } showDmg.GetComponent <TextMeshProUGUI>().text = damage.ToString(); } else if (damage < 0) //healing { showDmg.GetComponent <TextMeshProUGUI>().text = Mathf.Abs(damage).ToString(); showDmg.GetComponent <TextMeshProUGUI>().color = new Color32(35, 220, 0, 255); //green text } else //0 damage, blocked { showDmg.GetComponent <TextMeshProUGUI>().text = "Blocked!"; showDmg.GetComponent <TextMeshProUGUI>().color = new Color32(188, 188, 188, 255); //grey text } }