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.

85 lines
2.1 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 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 GameWin()
  35. {
  36. winCanvas.SetActive(true);
  37. timer.SetActive(false);
  38. }
  39. public void GameLose()
  40. {
  41. loseCanvas.SetActive(true);
  42. timer.SetActive(false);
  43. }
  44. /*
  45. //Check the values for player to see if it changes the minimum or maximum values of all players
  46. void CheckValues()
  47. {
  48. float maxDistance = 0;
  49. foreach(GameObject gamePlayer in Players)
  50. {
  51. float distance = (transform.position - gamePlayer.transform.position).magnitude;
  52. Player playerScript = gamePlayer.GetComponent<Player>();
  53. foreach (GameObject dummy in playerScript.dummies)
  54. {
  55. float newDis = (transform.position - gamePlayer.transform.position).magnitude;
  56. if (newDis < distance)
  57. {
  58. distance = newDis;
  59. }
  60. }
  61. if (distance > maxDistance)
  62. {
  63. maxDistance = distance;
  64. }
  65. }
  66. if (maxDistance < DistanceToWin)
  67. {
  68. if (recipe.CheckVictory())
  69. {
  70. //Win Game here
  71. }
  72. }
  73. }
  74. */
  75. }