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.

70 lines
1.7 KiB

5 years ago
5 years ago
5 years ago
5 years ago
  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. GameObject LocalPlayer;
  9. public CharacterMovement charMove;
  10. private void Start()
  11. {
  12. LocalPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer;
  13. Players.Add(LocalPlayer);
  14. foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values)
  15. {
  16. Players.Add(curPlayer);
  17. }
  18. }
  19. void Update()
  20. {
  21. //CheckValues();
  22. if (charMove.CheckNearby())
  23. {
  24. recipe.CheckVictory();
  25. }
  26. }
  27. public void EndGame()
  28. {
  29. }
  30. /*
  31. //Check the values for player to see if it changes the minimum or maximum values of all players
  32. void CheckValues()
  33. {
  34. float maxDistance = 0;
  35. foreach(GameObject gamePlayer in Players)
  36. {
  37. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  38. Player playerScript = gamePlayer.GetComponent<Player>();
  39. foreach (GameObject dummy in playerScript.dummies)
  40. {
  41. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  42. if (newDis < distance)
  43. {
  44. distance = newDis;
  45. }
  46. }
  47. if (distance > maxDistance)
  48. {
  49. maxDistance = distance;
  50. }
  51. }
  52. if (maxDistance < DistanceToWin)
  53. {
  54. if (recipe.CheckVictory())
  55. {
  56. //Win Game here
  57. }
  58. }
  59. }
  60. */
  61. }