diff --git a/Assets/Scipts/GameMode.cs b/Assets/Scipts/GameMode.cs new file mode 100644 index 0000000..4727573 --- /dev/null +++ b/Assets/Scipts/GameMode.cs @@ -0,0 +1,84 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class GameMode : MonoBehaviour { + + //references to all players + List Players = new List(); + + public float XDistanceToWin = 10.0f; + public float ZDistanceToWin = 10.0f; + + //Min and max values + float minX = 0; + float maxX = 0; + float minZ = 0; + float maxZ = 0; + + //Time stuff + public float MaxTimer = 120.0f; + float Timer = 0.0f; + + void Start() + { + Timer = MaxTimer; + } + + void Update() + { + //Handle timer + Timer -= 1.0f * Time.deltaTime; + if (Timer <= 0.0f) + { + //Game Lose code here + } + //Check for win condition + minX = Players[0].transform.position.x; + maxX = minX; + minZ = Players[0].transform.position.z; + maxZ = minZ; + + foreach (GameObject player in Players) + { + CheckValues(player.transform.position); + } + CheckForVictory(); + + } + + //Check the values for player to see if it changes the minimum or maximum values of all players + void CheckValues(Vector3 player) + { + if (player.x > maxX) + { + maxX = player.x; + } + else if (player.x < minX) + { + minX = player.x; + } + + if (player.z > maxZ) + { + maxZ = player.z; + } + else if (player.z < minZ) + { + minZ = player.z; + } + } + + //Check to see if the players win + void CheckForVictory() + { + if ((maxX - minX) < XDistanceToWin) + { + if ((maxZ - minZ) < ZDistanceToWin) + { + //Game Win goes here + } + } + } + +} diff --git a/Assets/Scipts/GameMode.cs.meta b/Assets/Scipts/GameMode.cs.meta new file mode 100644 index 0000000..1e97a23 --- /dev/null +++ b/Assets/Scipts/GameMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 553b7b4f739e7334b9e1055b3688e5e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: