Guest User

Untitled

a guest
Apr 2nd, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public class PlayerMove : MonoBehaviour
  2. {
  3. [SerializeField] public float _speed;
  4. private float _oldMousePositionX;
  5. private float _eulerY;
  6.  
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. _oldMousePositionX = Input.mousePosition.x;
  11. }
  12.  
  13. // Update is called once per frame
  14. void Update()
  15. {
  16.  
  17.  
  18. Vector3 newPosition = transform.position + transform.forward * Time.deltaTime * _speed;
  19. newPosition.x = Mathf.Clamp(newPosition.x, -2f, 2f);
  20. transform.position = newPosition;
  21.  
  22.  
  23. float deltaX = Input.mousePosition.x - _oldMousePositionX;
  24. _oldMousePositionX = Input.mousePosition.x;
  25.  
  26. _eulerY += deltaX;
  27. _eulerY = Mathf.Clamp(_eulerY, -60, 60);
  28. transform.eulerAngles = new Vector3(0, _eulerY, 0);
  29. }
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. public class PassengerManager : MonoBehaviour
  40. {
  41. [SerializeField] int _numberOfPassengersInLevel;
  42. [SerializeField] int _moneyCount = 0;
  43. [SerializeField] int _moneyPerPassenger;
  44. [SerializeField] TextMeshProUGUI _passengersText;
  45. [SerializeField] TextMeshProUGUI _moneyText;
  46. [SerializeField] TextMeshProUGUI _speedText;
  47.  
  48. public void AddOne()
  49. {
  50. _numberOfPassengersInLevel++;
  51. _moneyCount += _moneyPerPassenger;
  52. _passengersText.text = _numberOfPassengersInLevel.ToString();
  53. _moneyText.text = "$" + _moneyCount.ToString();
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment