Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : Character
  6. {
  7. [SerializeField]
  8. private Stat health;
  9.  
  10. [SerializeField]
  11. private float maxHealth;
  12.  
  13. // Use this for initialization
  14. protected override void Start ()
  15. {
  16.  
  17. health.Initialize(maxHealth, maxHealth);
  18.  
  19. base.Start();
  20. }
  21.  
  22. // Update is called once per frame
  23. protected override void Update ()
  24. {
  25. GetInpu();
  26. health.MyCurrentValue = 600;
  27. base.Update();
  28. }
  29.  
  30.  
  31.  
  32. public void GetInpu()
  33. {
  34. direction = Vector2.zero;
  35.  
  36. if (Input.GetKeyDown(KeyCode.I))
  37. {
  38. health.MyCurrentValue -= 100;
  39. }
  40. if (Input.GetKeyDown(KeyCode.O))
  41. {
  42. health.MyCurrentValue += 100;
  43. }
  44.  
  45. if (Input.GetKey(KeyCode.UpArrow))
  46. {
  47. direction += Vector2.up;
  48. }
  49. if (Input.GetKey(KeyCode.LeftArrow))
  50. {
  51. direction += Vector2.left;
  52. }
  53. if (Input.GetKey(KeyCode.DownArrow))
  54. {
  55. direction += Vector2.down;
  56. }
  57. if (Input.GetKey(KeyCode.RightArrow))
  58. {
  59. direction += Vector2.right;
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement