Guest User

Untitled

a guest
Apr 2nd, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class PlayerMove : MonoBehaviour
  7. {
  8. [SerializeField] public static float _speed = 3f;
  9. private float _oldMousePositionX;
  10. private float _eulerY;
  11.  
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. _oldMousePositionX = Input.mousePosition.x;
  16. }
  17.  
  18. // Update is called once per frame
  19. void Update()
  20. {
  21.  
  22.  
  23. Vector3 newPosition = transform.position + transform.forward * Time.deltaTime * _speed;
  24. newPosition.x = Mathf.Clamp(newPosition.x, -2f, 2f);
  25. transform.position = newPosition;
  26.  
  27.  
  28. float deltaX = Input.mousePosition.x - _oldMousePositionX;
  29. _oldMousePositionX = Input.mousePosition.x;
  30.  
  31. _eulerY += deltaX;
  32. _eulerY = Mathf.Clamp(_eulerY, -60, 60);
  33. transform.eulerAngles = new Vector3(0, _eulerY, 0);
  34. }
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. =================================================================================================================
  44.  
  45.  
  46.  
  47. using System.Collections;
  48. using System.Collections.Generic;
  49. using TMPro;
  50. using Unity.VisualScripting;
  51. using UnityEngine;
  52. using System;
  53.  
  54. public class PassengerManager : MonoBehaviour
  55. {
  56. [SerializeField] int _numberOfPassengersInLevel;
  57. [SerializeField] int _moneyCount = 0;
  58. [SerializeField] int _moneyPerPassenger;
  59. [SerializeField] float _speedCount;
  60. [SerializeField] float _roundedSpeedCount;
  61. [SerializeField] TextMeshProUGUI _passengersText;
  62. [SerializeField] TextMeshProUGUI _moneyText;
  63. [SerializeField] TextMeshProUGUI _speedText;
  64.  
  65. public void AddOne()
  66. {
  67. _speedCount = PlayerMove._speed += 0.05f;
  68. _roundedSpeedCount = (float)Math.Round(_speedCount, 2);
  69.  
  70. _numberOfPassengersInLevel++;
  71. _moneyCount += _moneyPerPassenger;
  72. _passengersText.text = _numberOfPassengersInLevel.ToString();
  73. _moneyText.text = "$" + _moneyCount.ToString();
  74. _speedText.text = Mathf.RoundToInt(_roundedSpeedCount * 10).ToString() + " км/ч";
  75. }
  76. }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
Advertisement
Add Comment
Please, Sign In to add comment