|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
-
- public class GameMode : MonoBehaviour {
-
- //references to all players
- List<GameObject> Players = new List<GameObject>();
- public Recipe recipe;
- public GameObject LocalPlayer;
-
- public float DistanceToWin;
-
-
-
- void Update()
- {
-
- CheckValues();
-
- }
-
- //Check the values for player to see if it changes the minimum or maximum values of all players
- void CheckValues()
- {
- float maxDistance = 0;
- foreach(GameObject gamePlayer in Players)
- {
- float distance = (transform.position - gamePlayer.transform.position).magnitude;
- Player playerScript = gamePlayer.GetComponent<Player>();
- foreach (GameObject dummy in playerScript.dummies)
- {
- float newDis = (transform.position - gamePlayer.transform.position).magnitude;
- if (newDis < distance)
- {
- distance = newDis;
- }
- }
- if (distance > maxDistance)
- {
- maxDistance = distance;
- }
- }
- if (maxDistance < DistanceToWin)
- {
- if (recipe.CheckVictory())
- {
- //Win Game here
- }
- }
- }
- }
|