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

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class GameMode : MonoBehaviour {
  5. //references to all players
  6. List<GameObject> Players = new List<GameObject>();
  7. public Recipe recipe;
  8. public GameObject LocalPlayer;
  9. public float DistanceToWin;
  10. private void Start()
  11. {
  12. // Player
  13. }
  14. void Update()
  15. {
  16. CheckValues();
  17. }
  18. //Check the values for player to see if it changes the minimum or maximum values of all players
  19. void CheckValues()
  20. {
  21. float maxDistance = 0;
  22. foreach(GameObject gamePlayer in Players)
  23. {
  24. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  25. Player playerScript = gamePlayer.GetComponent<Player>();
  26. foreach (GameObject dummy in playerScript.dummies)
  27. {
  28. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  29. if (newDis < distance)
  30. {
  31. distance = newDis;
  32. }
  33. }
  34. if (distance > maxDistance)
  35. {
  36. maxDistance = distance;
  37. }
  38. }
  39. if (maxDistance < DistanceToWin)
  40. {
  41. if (recipe.CheckVictory())
  42. {
  43. //Win Game here
  44. }
  45. }
  46. }
  47. }