IEnumerator burn(GameObject burning, GameObject enemy, float timeFrame, int DamageEachFrame, float timeExist) { float elapsedTimeDamage = 0; float elapsedTimeExist = 0; BulletEffectController effectController = burning.GetComponent <BulletEffectController>(); EnemyController enemyController = enemy.GetComponent <EnemyController>(); while (true) { if (enemy != null) { if (effectController.reset) { elapsedTimeExist = 0; effectController.reset = false; } elapsedTimeDamage += Time.deltaTime; elapsedTimeExist += Time.deltaTime; if (enemyController.attribute.HP.Current <= 0 && !enemyController.isDie) { Animator animator = burning.GetComponentInChildren <Animator>(); animator.SetBool("Loop", false); animator.SetBool("Finish", true); enemyController.die(); yield break; } if (elapsedTimeDamage >= timeFrame) { PlayManager.Instance.pushDamageEffect(enemyController, DamageEachFrame); elapsedTimeDamage = 0; } if (elapsedTimeExist >= timeExist) { Animator animator = burning.GetComponentInChildren <Animator>(); animator.SetBool("Loop", false); animator.SetBool("Finish", true); enemy.GetComponent <EnemyController>().listEffected.Remove(EBulletEffect.BURN); yield break; } yield return(0); } else { yield break; } } }
IEnumerator stun(GameObject stun, GameObject enemy, float duration) { float elapsedTimeExist = 0; BulletEffectController effectController = enemy.GetComponent <BulletEffectController>(); EnemyController controller = enemy.GetComponent <EnemyController>(); controller.stop(); while (true) { if (enemy != null) { if (effectController.reset) { elapsedTimeExist = 0; effectController.reset = false; } elapsedTimeExist += Time.deltaTime; if (elapsedTimeExist >= duration) { ObjectController obj = stun.GetComponent <ObjectController>(); obj.listState[obj.StateAction].goNextState(); controller.resume(); controller.listEffected.Remove(EBulletEffect.STUN); Destroy(enemy.GetComponent <BulletEffectController>()); yield break; } yield return(0); } else { yield break; } } }
IEnumerator slow(GameObject enemy, float slowValue, float timeExist) { float elapsedTimeExist = 0; BulletEffectController effectController = enemy.GetComponent <BulletEffectController>(); while (true) { if (enemy != null) { if (effectController.reset) { elapsedTimeExist = 0; effectController.reset = false; } elapsedTimeExist += Time.deltaTime; if (elapsedTimeExist >= timeExist) { float timeFrame = enemy.transform.GetChild(0).gameObject.GetComponent <AnimationFrames>().timeFrame; enemy.GetComponentInChildren <AnimationFrames>().timeFrame = timeFrame * (1 - slowValue); enemy.GetComponentInChildren <SpriteRenderer>().color = Color.white; EnemyController controller = enemy.GetComponent <EnemyController>(); controller.speed /= (1 - slowValue); controller.listEffected.Remove(EBulletEffect.SLOW); Destroy(enemy.GetComponent <BulletEffectController>()); yield break; } yield return(0); } else { yield break; } } }