//called from the StatusTimer public void TriggerStatus(Status status, StatusTimer timer, float acumTime, StatusEffects effect) { if (isEnemy) { effect.ProcEffect(timer); enemy.CalculateStatus(effect); //if the monster has been inflicted with the status for longer than the duration that the status can be inflicted for, then it is no longer afflicted. if not, run the status trigger again if (acumTime <= status.duration) { StartCoroutine(timer.TriggerEffect()); var display = Instantiate(enemy.damageText, transform.position, Quaternion.identity); display.transform.SetParent(enemy.enemyCanvas.transform, true); display.GetComponentInChildren <TMP_Text>().text = "-" + status.name; Destroy(display, display.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length); } else { if (statuses.Contains(status)) { effect.HealStatus(this, status); } } } else { //StatusEffects effect = new StatusEffects(this, status, false); effect.ProcEffect(timer); CalculateStatus(effect); //if the monster has been inflicted with the status for longer than the duration that the status can be inflicted for, then it is no longer afflicted. if not, run the status trigger again if (acumTime <= status.duration) { StartCoroutine(timer.TriggerEffect()); var display = Instantiate(enemy.damageText, transform.position, Quaternion.identity); display.transform.SetParent(enemy.enemyCanvas.transform, false); display.GetComponentInChildren <TMP_Text>().text = "-" + status.name; Destroy(display, display.GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).length); } else { if (statuses.Contains(status)) { effect.HealStatus(this, status); } } } }
//statuses are added from monster attacks or from tiles on the map. they are added here and the statuses being calculating public void AddStatus(Status status) { StatusTimer timer = new StatusTimer(gameObject.GetComponent <Monster>(), status); StartCoroutine(timer.TriggerEffect()); if (statuses.Contains(status)) { // } else { statuses.Add(status); if (GameManager.Instance.GetComponent <AllStatusEffects>().allStatusDict.ContainsKey(status.name)) { statusIcons[statuses.Count - 1].GetComponent <SpriteRenderer>().sprite = GameManager.Instance.GetComponent <AllStatusEffects>().allStatusDict[status.name].statusSprite; } } }