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.

95 lines
2.2 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. public GameObject timer;
  11. public GameObject winCanvas;
  12. public GameObject loseCanvas;
  13. private void Start()
  14. {
  15. LocalPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer;
  16. Players.Add(LocalPlayer);
  17. foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values)
  18. {
  19. Players.Add(curPlayer);
  20. }
  21. }
  22. void Update()
  23. {
  24. //CheckValues();
  25. if (charMove.CheckNearby())
  26. {
  27. recipe.CheckVictory();
  28. }
  29. }
  30. public void EndGame()
  31. {
  32. Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Lobby);
  33. }
  34. public void PreGameWin()
  35. {
  36. }
  37. public void PreGameLose()
  38. {
  39. }
  40. public void GameWin()
  41. {
  42. winCanvas.SetActive(true);
  43. timer.SetActive(false);
  44. }
  45. public void GameLose()
  46. {
  47. loseCanvas.SetActive(true);
  48. timer.SetActive(false);
  49. }
  50. /*
  51. //Check the values for player to see if it changes the minimum or maximum values of all players
  52. void CheckValues()
  53. {
  54. float maxDistance = 0;
  55. foreach(GameObject gamePlayer in Players)
  56. {
  57. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  58. Player playerScript = gamePlayer.GetComponent<Player>();
  59. foreach (GameObject dummy in playerScript.dummies)
  60. {
  61. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  62. if (newDis < distance)
  63. {
  64. distance = newDis;
  65. }
  66. }
  67. if (distance > maxDistance)
  68. {
  69. maxDistance = distance;
  70. }
  71. }
  72. if (maxDistance < DistanceToWin)
  73. {
  74. if (recipe.CheckVictory())
  75. {
  76. //Win Game here
  77. }
  78. }
  79. }
  80. */
  81. }