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;
|
|
GameObject LocalPlayer;
|
|
public CharacterMovement charMove;
|
|
|
|
public Timer timer;
|
|
public GameObject winCanvas;
|
|
public GameObject loseCanvas;
|
|
|
|
private void Start()
|
|
{
|
|
LocalPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer;
|
|
Players.Add(LocalPlayer);
|
|
foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values)
|
|
{
|
|
Players.Add(curPlayer);
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
|
|
//CheckValues();
|
|
if (charMove.CheckNearby())
|
|
{
|
|
if (recipe.CheckVictory())
|
|
{
|
|
PreGameWin();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void EndGame()
|
|
{
|
|
Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Lobby);
|
|
}
|
|
|
|
public void PreGameWin()
|
|
{
|
|
|
|
}
|
|
|
|
public void PreGameLose()
|
|
{
|
|
|
|
}
|
|
|
|
public void GameWin()
|
|
{
|
|
winCanvas.SetActive(true);
|
|
timer.enabled = false;
|
|
}
|
|
|
|
public void GameLose()
|
|
{
|
|
loseCanvas.SetActive(true);
|
|
timer.enabled = false;
|
|
}
|
|
|
|
/*
|
|
//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
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
}
|