EnemyHeavy.cs 887 B

1234567891011121314151617181920212223
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class EnemyHeavy : EnemyBase {
  5. internal override bool isPressingCrouch() => false;
  6. internal override bool isPressDownJump() => false;
  7. internal override bool isPressingLeft() => movingLeft;
  8. internal override bool isPressingRight() => !movingLeft;
  9. //internal override void OnUpdate() {
  10. // bool shouldTurn = false;
  11. // if (Mathf.Abs(rb.velocity.x) > 0.001f && (rb.velocity.x > 0 == movingLeft)) shouldTurn = true;
  12. // if (shouldTurn) movingLeft = !movingLeft;
  13. //}
  14. public float knockbackForceH = 30f, knockbackForceV = 15f;
  15. internal override void OnHitEnemy(Collision2D collision) {
  16. int face = collision.transform.position.x < transform.position.x ? 1 : -1;
  17. rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
  18. }
  19. }