Browse Source

Camera modifications added

master
MB 5 years ago
parent
commit
6415a5b071
4 changed files with 113 additions and 11 deletions
  1. +5
    -0
      Assets/Scipts/GameMode.cs
  2. +78
    -0
      Assets/Scipts/Map.cs
  3. +11
    -0
      Assets/Scipts/Map.cs.meta
  4. +19
    -11
      Assets/Scipts/Timer.cs

+ 5
- 0
Assets/Scipts/GameMode.cs View File

@ -68,4 +68,9 @@ public class GameMode : MonoBehaviour {
} }
} }
public List<GameObject> GetPlayers()
{
return Players;
}
} }

+ 78
- 0
Assets/Scipts/Map.cs View File

@ -0,0 +1,78 @@
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
{
}
}

+ 11
- 0
Assets/Scipts/Map.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb1b808875f0dab4f9905cced86ca98a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 19
- 11
Assets/Scipts/Timer.cs View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
public class Timer : MonoBehaviour { public class Timer : MonoBehaviour {
@ -14,9 +15,18 @@ public class Timer : MonoBehaviour {
public Color Dawn; public Color Dawn;
public Color Noon; public Color Noon;
float DawnValue;
float NoonValue;
float colorDif;
Image SunImage;
void Start() void Start()
{ {
Sun.gameObject.GetComponent<Image>().Color = Dawn;
SunImage = Sun.gameObject.GetComponent<Image>();
SunImage.color = Dawn;
DawnValue = Dawn.b;
NoonValue = Noon.b;
colorDif = Mathf.Abs(NoonValue - DawnValue);
} }
void Update () { void Update () {
@ -26,20 +36,18 @@ public class Timer : MonoBehaviour {
//Game Lose code here //Game Lose code here
} }
/*
//Move the sun
float reqRot = (curTime / MaxTimer) * 180;
if (reqRot > 180)
Color newColor;
if (curTime > MaxTimer / 2)
{ {
reqRot = 180;
newColor = new Color(SunImage.color.r, SunImage.color.g - colorDif * ((90 / MaxTimer) * Time.deltaTime), SunImage.color.b );
} }
if (reqRot > curRot)
else
{ {
float rotDistance = reqRot - curRot;
// Sun.RotateAround(Pivot.transform.position, Sun.transform.forward, rotDistance);
curRot = reqRot;
newColor = new Color(SunImage.color.r, SunImage.color.g + colorDif * ((90 / MaxTimer) * Time.deltaTime), SunImage.color.b);
} }
*/
SunImage.color = newColor;
Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime); Sun.RotateAround(Pivot.transform.position, -1 * Sun.transform.forward, (180 / MaxTimer) * Time.deltaTime);
} }

Loading…
Cancel
Save