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.

65 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. /*
  28. //Check the values for player to see if it changes the minimum or maximum values of all players
  29. void CheckValues()
  30. {
  31. float maxDistance = 0;
  32. foreach(GameObject gamePlayer in Players)
  33. {
  34. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  35. Player playerScript = gamePlayer.GetComponent<Player>();
  36. foreach (GameObject dummy in playerScript.dummies)
  37. {
  38. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  39. if (newDis < distance)
  40. {
  41. distance = newDis;
  42. }
  43. }
  44. if (distance > maxDistance)
  45. {
  46. maxDistance = distance;
  47. }
  48. }
  49. if (maxDistance < DistanceToWin)
  50. {
  51. if (recipe.CheckVictory())
  52. {
  53. //Win Game here
  54. }
  55. }
  56. }
  57. */
  58. }