Player.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Cinemachine;
  2. using DG.Tweening;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. public class Player : EntityBase {
  8. internal override bool isPressingCrouch() => InputM.GetKeyEvent(InputM.KeyType.Crouch);
  9. internal override bool isPressDownJump() => InputM.GetKeyEvent(InputM.KeyType.Jump);
  10. internal override bool isPressingLeft() => InputM.GetKeyEvent(InputM.KeyType.Left);
  11. internal override bool isPressingRight() => InputM.GetKeyEvent(InputM.KeyType.Right);
  12. internal override void OnHitBorder() {
  13. Hurt();
  14. transform.position = new Vector3(0, 8, 0);
  15. }
  16. public float knockbackForceH = 30f, knockbackForceV = 15f;
  17. internal override void OnHitEnemy(Collision2D collision) {
  18. Hurt();
  19. int face = collision.transform.position.x < transform.position.x ? 1 : -1;
  20. rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
  21. }
  22. public void Hurt() {
  23. AudioM.Play("hurt");
  24. rb.velocity = Vector2.zero;
  25. DOTween.Kill("ScreenShake");
  26. Camera.current.DOShakePosition(0.3f, 0.3f, 20).SetId("ScreenShake");
  27. }
  28. // Éä»÷
  29. internal override void OnUpdate() {
  30. }
  31. }