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.
 
 
 

56 lines
1.4 KiB

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;
private void Start()
{
// Player
}
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
}
}
}
}