protected override IEnumerator StunEnemy(float stunDuration) { //return base.StunEnemy(stunDuration); if (!enStunned && isAlive) { enStunned = true; //enStunned is referenced in Controller, even if HeavyBandit uses Break instead isBroken = true; EnDisableMove(); enCanAttack = false; isAttacking = false; if (initialStunParticle != null) { Instantiate(initialStunParticle, transform.position, Quaternion.identity, transform); } yield return(new WaitForSeconds(.1f)); //short delay before starting slow motion TimeManager.Instance.CustomSlowMotion(.02f, .5f); Vector3 tempPos = transform.position; tempPos.y += TPOffset; AttackIndicator.ShowBreak(tempPos); EnAnimator.PlayStunned(); yield return(new WaitForSeconds(.5f)); //1.1f EnAnimator.PlayAnim(2); yield return(new WaitForSeconds(breakDuration)); //1.3f //recoverDuration, is based on current phase //EnAnimator.PlayIdle(isAttacking, enStunned, isHurt); //TODO: play StunRecover animation NOT IDLE EnableShield(); isBroken = false; yield return(new WaitForSeconds(.2f)); ShowAttackIndicator(); yield return(new WaitForSeconds(.5f)); enCanAttack = true; isAttacking = false; //in case of attack interrupted from stun //TODO: might not need, is called earlier ^ enStunned = false; EnEnableMove(); EnEnableFlip(); //precaution in case enemy is stunned during attack and can't flip } }
protected override IEnumerator StunEnemy(float stunDuration) { if (!enStunned) { enStunned = true; //enStunned is referenced in Controller, even if HeavyBandit uses Break instead isBroken = true; EnDisableMove(); enCanAttack = false; //yield return new WaitForSeconds(.1f); EnAnimator.PlayStunned(); /*if (timeManager != null) * { * timeManager.CustomSlowMotion(.02f, .5f); * }*/ if (initialStunParticle != null) { Vector3 tempLocation = transform.position; tempLocation.y += .5f; Instantiate(initialStunParticle, tempLocation, Quaternion.identity, transform); } if (isAlive) { Vector3 tempPos = transform.position; tempPos.y += TPOffset; AttackIndicator.ShowBreak(tempPos); } yield return(new WaitForSeconds(stunDuration)); EnableShield(); isBroken = false; EnAnimator.PlayAnim(0); //Stun Recover yield return(new WaitForSeconds(1f)); //time for recover animation, or short delay before moving again enStunned = false; enCanAttack = true; isAttacking = false; //in case of attack interrupted from stun EnEnableMove(); EnEnableFlip(); //precaution in case enemy is stunned during attack and can't flip } }