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.

66 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 CharacterMovement : MonoBehaviour {
  5. public float Speed;
  6. GameObject localPlayer;
  7. public List<GameObject> Players = new List<GameObject>();
  8. public List<bool> Nearby = new List<bool>();
  9. public float DistanceToWin;
  10. Camera cam;
  11. private void Start()
  12. {
  13. localPlayer = Multiplayer.PlayersManager.Instance.LocalPlayer;
  14. Players.Add(localPlayer);
  15. foreach (GameObject curPlayer in Multiplayer.PlayersManager.Instance.RemotePlayers.Values)
  16. {
  17. Players.Add(curPlayer);
  18. }
  19. cam = localPlayer.GetComponentInChildren<Camera>();
  20. }
  21. public bool CheckNearby()
  22. {
  23. for (int i = 0; i < Players.Count; i++)
  24. {
  25. if ((localPlayer.transform.position - Players[i].transform.position).magnitude < DistanceToWin)
  26. {
  27. Greet();
  28. }
  29. else
  30. {
  31. Player playerScript = Players[i].GetComponent<Player>();
  32. foreach (GameObject dummy in playerScript.dummies)
  33. {
  34. if ((localPlayer.transform.position - dummy.transform.position).magnitude < DistanceToWin)
  35. {
  36. Greet();
  37. }
  38. }
  39. }
  40. }
  41. return CheckWin();
  42. }
  43. bool CheckWin()
  44. {
  45. for (int i = 0; i < Nearby.Count; i++)
  46. {
  47. if (Nearby[i] == false)
  48. {
  49. return false;
  50. }
  51. }
  52. return true;
  53. }
  54. public void Greet()
  55. {
  56. //Play audio
  57. //Trigger animation
  58. }
  59. }