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;

    
    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())
        {
            recipe.CheckVictory();
        }
    }

    public void EndGame()
    {
        Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Lobby);
    }

    /*
    //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
            }
        }
    }
    */
}
