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.8 KiB

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