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.

98 lines
2.3 KiB

5 years ago
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 Timer 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. if (recipe.CheckVictory())
  28. {
  29. PreGameWin();
  30. }
  31. }
  32. }
  33. public void EndGame()
  34. {
  35. Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.Lobby);
  36. }
  37. public void PreGameWin()
  38. {
  39. }
  40. public void PreGameLose()
  41. {
  42. }
  43. public void GameWin()
  44. {
  45. winCanvas.SetActive(true);
  46. timer.enabled = false;
  47. }
  48. public void GameLose()
  49. {
  50. loseCanvas.SetActive(true);
  51. timer.enabled = false;
  52. }
  53. /*
  54. //Check the values for player to see if it changes the minimum or maximum values of all players
  55. void CheckValues()
  56. {
  57. float maxDistance = 0;
  58. foreach(GameObject gamePlayer in Players)
  59. {
  60. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  61. Player playerScript = gamePlayer.GetComponent<Player>();
  62. foreach (GameObject dummy in playerScript.dummies)
  63. {
  64. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  65. if (newDis < distance)
  66. {
  67. distance = newDis;
  68. }
  69. }
  70. if (distance > maxDistance)
  71. {
  72. maxDistance = distance;
  73. }
  74. }
  75. if (maxDistance < DistanceToWin)
  76. {
  77. if (recipe.CheckVictory())
  78. {
  79. //Win Game here
  80. }
  81. }
  82. }
  83. */
  84. }