public override IEnumerator playAttackAnimation(Skill skill, float attackTime) { int frame = 0; walkingFrame = 0; do { if (!isStunned()) { body.GetComponent<SpriteRenderer>().sprite = spriteAttack[frame]; if (frame == 6) skill.skillLogic(this, stats); frame++; } yield return new WaitForSeconds(attackTime / spriteAttack.Length); } while (frame < spriteAttack.Length); isAttacking = false; }
public override IEnumerator playAttackAnimation(Skill skill, float attackTime) { walkingFrame = 0; bool hasntAttacked = true; float endTime = Time.fixedTime + attackTime; float remainingTime = endTime - Time.fixedTime; while (remainingTime > 0) { int currentFrame = (int)(((attackTime - remainingTime) / attackTime) * spriteAttack.Length); body.GetComponent<SpriteRenderer>().sprite = spriteAttack[currentFrame]; if (hasntAttacked && currentFrame > 3) { hasntAttacked = false; skill.skillLogic(this, stats); } yield return new WaitForSeconds(0); remainingTime = endTime - Time.fixedTime; } body.GetComponent<SpriteRenderer>().sprite = spriteAttack[0]; if (hasntAttacked) skill.skillLogic(this, stats); isAttacking = false; }
public override IEnumerator playAttackAnimation(Skill skill, float attackTime) { float endTime = Time.fixedTime + attackTime; float remainingTime = endTime - Time.fixedTime; while (remainingTime > 0) { int currentFrame = (int)(((attackTime - remainingTime) / attackTime) * spriteAttack.Length); body.GetComponent<SpriteRenderer>().sprite = spriteAttack[currentFrame]; yield return new WaitForSeconds(0); remainingTime = endTime - Time.fixedTime; } skill.skillLogic(this, stats); }