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.

82 lines
2.4 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Networking.Server;
  5. public class PortalSetup : MonoBehaviour
  6. {
  7. public ClientList clientDataList;
  8. public List<ClientData> ConnectedClients;
  9. public Color[] playerColours;
  10. public List<int> validIndex;
  11. public float collectAmount;
  12. public float waitTime;
  13. int currentIndex = 0;
  14. Color deactiveGrey = new Color32 (120, 120, 120, 255);
  15. Color deactiveGreyA = new Color32 (120, 120, 120, 0);
  16. bool collectedFive = false;
  17. //load portal
  18. public ParticleSystem Edge;
  19. public ParticleSystem InSpark;
  20. public ParticleSystem RandomSparks;
  21. public ParticleSystem Ring;
  22. public ParticleSystem Smoke;
  23. ParticleSystem.MainModule mainEdge;
  24. ParticleSystem.MainModule mainInSpark;
  25. ParticleSystem.MainModule mainRandomSparks;
  26. ParticleSystem.MainModule mainRing;
  27. ParticleSystem.MainModule mainSmoke;
  28. IEnumerator ColorChange ()
  29. {
  30. while(true){
  31. mainEdge.startColor = playerColours[validIndex[currentIndex]];
  32. mainInSpark.startColor = playerColours[validIndex[currentIndex]];
  33. mainRandomSparks.startColor = playerColours[validIndex[currentIndex]];
  34. mainRing.startColor = playerColours[validIndex[currentIndex]];
  35. mainSmoke.startColor = playerColours[validIndex[currentIndex]];
  36. currentIndex++;
  37. if(currentIndex >= validIndex.Count){
  38. currentIndex = 0;
  39. }
  40. yield return new WaitForSeconds (5.0f);
  41. }
  42. }
  43. void Update()
  44. {
  45. /*if (!collectedFive && (ConnectedClients[0].SceneScore >= collectAmount || ConnectedClients[1].SceneScore >= collectAmount || ConnectedClients[2].SceneScore >= collectAmount || ConnectedClients[3].SceneScore >= collectAmount)){
  46. collectedFive = true;
  47. StartCoroutine (ColorChange ());
  48. }*/
  49. }
  50. private void Awake ()
  51. {
  52. //get list of players
  53. ConnectedClients = clientDataList.ConnectedClients;
  54. playerColours = new Color[ConnectedClients.Count];
  55. validIndex = new List<int>();
  56. for (int i = 0; i < ConnectedClients.Count; i++){
  57. playerColours[i] = ConnectedClients[i].Color;
  58. }
  59. //link portal particle sections
  60. mainEdge = Edge.main;
  61. mainInSpark = InSpark.main;
  62. mainRandomSparks = RandomSparks.main;
  63. mainRing = Ring.main;
  64. mainSmoke = Smoke.main;
  65. //set start mode for portal
  66. mainEdge.startColor = deactiveGrey;
  67. mainInSpark.startColor = deactiveGreyA;
  68. mainRandomSparks.startColor = deactiveGreyA;
  69. mainRing.startColor = deactiveGrey;
  70. mainSmoke.startColor = deactiveGreyA;
  71. }
  72. }