Advertisement
Guest User

Untitled

a guest
Aug 5th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. using System.Collections; //Unity
  2. using System.Collections.Generic; //Unity
  3. using UnityEngine; //UnityEngine namespace
  4.  
  5.  
  6. public class Player : MonoBehaviour //Public script player
  7.  
  8. {
  9.  
  10. [SerializeField] Sprite scissor; //Create asset-drop field called "scissor" to assign the scissor sprite
  11. [SerializeField] Sprite rock; //Create asset-drop field called "rock" to assign the rock sprite
  12. [SerializeField] Sprite paper; //Create asset-drop field called "paper" to assign the paper sprite
  13. int PlayerValue; //Create integer that will receive player value from script "Player"
  14.  
  15.  
  16.  
  17. void Update()
  18.  
  19. {
  20.  
  21. if (Input.GetKeyDown(KeyCode.LeftArrow)) //If the left arrow is pressed
  22. {
  23. GetComponent<SpriteRenderer>().sprite = rock; //Get the actor component "Sprite Renderer" and change the sprite to the "rock" sprite
  24. PlayerValue = 1;
  25. }
  26.  
  27.  
  28. else if (Input.GetKeyDown(KeyCode.DownArrow)) //If the down arrow is pressed
  29. {
  30. GetComponent<SpriteRenderer>().sprite = scissor; //Get the actor component "Sprite Renderer" and change the sprite to the "scissor" sprite
  31. PlayerValue = 2;
  32. }
  33.  
  34.  
  35. else if (Input.GetKeyDown(KeyCode.RightArrow)) //If the right arrow is pressed
  36. {
  37. GetComponent<SpriteRenderer>().sprite = paper; //Get the actor component "Sprite Renderer" and change the sprite to the "scissor" sprite
  38. PlayerValue = 0;
  39. }
  40.  
  41.  
  42. }
  43.  
  44.  
  45. public int ReadPlayerValue()
  46. {
  47. return PlayerValue;
  48. }
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement