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.

57 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. void Update()
  11. {
  12. CheckValues();
  13. }
  14. //Check the values for player to see if it changes the minimum or maximum values of all players
  15. void CheckValues()
  16. {
  17. float maxDistance = 0;
  18. foreach(GameObject gamePlayer in Players)
  19. {
  20. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  21. Player playerScript = gamePlayer.GetComponent<Player>();
  22. foreach (GameObject dummy in playerScript.dummies)
  23. {
  24. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  25. if (newDis < distance)
  26. {
  27. distance = newDis;
  28. }
  29. }
  30. if (distance > maxDistance)
  31. {
  32. maxDistance = distance;
  33. }
  34. }
  35. if (maxDistance < DistanceToWin)
  36. {
  37. //GameWinHere
  38. }
  39. }
  40. void CheckIngredients()
  41. {
  42. foreach(GameObject gamePlayer in Players)
  43. {
  44. }
  45. }
  46. }