You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.0 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Map : MonoBehaviour {
  5. public GameMode mode; //Reference to the scenes gamemode script
  6. GameObject LocalPlayer;
  7. //Minimum and maximum values for the map
  8. public float minX;
  9. public float maxX;
  10. public float minZ;
  11. public float maxZ;
  12. public GameObject TopCam;
  13. public GameObject BotCam;
  14. public GameObject LeftCam;
  15. public GameObject RightCam;
  16. //How wide halfd the camera is for the resizing
  17. public float camWidth = 8.0f;
  18. public float camHeight = 5.0f;
  19. void Update()
  20. {
  21. Teleport();
  22. HandleCameraMovement(TopCam, true);
  23. HandleCameraMovement(BotCam, true);
  24. HandleCameraMovement(LeftCam, false);
  25. HandleCameraMovement(RightCam, false);
  26. }
  27. void Teleport()
  28. {
  29. Transform PT = localPlayer.Transform;
  30. if (PT.position.x > maxX)
  31. {
  32. PT.position = new Vector3(minX, PT.position.y, PT.position.z);
  33. }
  34. else if (PT.position.x < minX)
  35. {
  36. PT.position = new Vector3(maxX, PT.position.y, PT.position.z);
  37. }
  38. if (PT.position.z > maxZ)
  39. {
  40. PT.position = new Vector3(PT.position.x, PT.position.y, minZ);
  41. }
  42. else if (PT.position.x < minX)
  43. {
  44. PT.position = new Vector3(PT.position.x, PT.position.y, maxZ);
  45. }
  46. }
  47. /// <summary>
  48. ///
  49. /// </summary>
  50. /// <param name="Cam"> The camera to move</param>
  51. /// <param name="Xmove">Do we move in the X axis or the Z?</param>
  52. void HandleCameraMovement(GameObject Cam, bool Xmove)
  53. {
  54. if (Xmove == true)
  55. {
  56. Cam.transform.position = new Vector3(LocalPlayer.transform.position.x, Cam.transform.position.y, Cam.transform.position.z);
  57. }
  58. else
  59. {
  60. Cam.transform.position = new Vector3(Cam.transform.position.x, Cam.transform.position.y, LocalPlayer.transform.position.z);
  61. }
  62. }
  63. void HandleCamSizing
  64. {
  65. }
  66. }