using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Map : MonoBehaviour {
|
|
|
|
public GameMode mode; //Reference to the scenes gamemode script
|
|
GameObject LocalPlayer;
|
|
|
|
//Minimum and maximum values for the map
|
|
public float minX;
|
|
public float maxX;
|
|
public float minZ;
|
|
public float maxZ;
|
|
|
|
public GameObject TopCam;
|
|
public GameObject BotCam;
|
|
public GameObject LeftCam;
|
|
public GameObject RightCam;
|
|
|
|
//How wide halfd the camera is for the resizing
|
|
public float camWidth = 8.0f;
|
|
public float camHeight = 5.0f;
|
|
|
|
void Update()
|
|
{
|
|
Teleport();
|
|
HandleCameraMovement(TopCam, true);
|
|
HandleCameraMovement(BotCam, true);
|
|
HandleCameraMovement(LeftCam, false);
|
|
HandleCameraMovement(RightCam, false);
|
|
|
|
}
|
|
|
|
void Teleport()
|
|
{
|
|
Transform PT = LocalPlayer.transform;
|
|
if (PT.position.x > maxX)
|
|
{
|
|
PT.position = new Vector3(minX, PT.position.y, PT.position.z);
|
|
}
|
|
else if (PT.position.x < minX)
|
|
{
|
|
PT.position = new Vector3(maxX, PT.position.y, PT.position.z);
|
|
}
|
|
if (PT.position.z > maxZ)
|
|
{
|
|
PT.position = new Vector3(PT.position.x, PT.position.y, minZ);
|
|
}
|
|
else if (PT.position.x < minX)
|
|
{
|
|
PT.position = new Vector3(PT.position.x, PT.position.y, maxZ);
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="Cam"> The camera to move</param>
|
|
/// <param name="Xmove">Do we move in the X axis or the Z?</param>
|
|
void HandleCameraMovement(GameObject Cam, bool Xmove)
|
|
{
|
|
if (Xmove == true)
|
|
{
|
|
Cam.transform.position = new Vector3(LocalPlayer.transform.position.x, Cam.transform.position.y, Cam.transform.position.z);
|
|
}
|
|
else
|
|
{
|
|
Cam.transform.position = new Vector3(Cam.transform.position.x, Cam.transform.position.y, LocalPlayer.transform.position.z);
|
|
}
|
|
}
|
|
|
|
void HandleCamSizing()
|
|
{
|
|
}
|
|
}
|