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.

68 lines
1.7 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Networking.Client;
  5. using Networking.Server;
  6. public class ConveyorBelt : MonoBehaviour
  7. {
  8. public ClientList clientData;
  9. bool characterOnBelt = false;
  10. GameObject player;
  11. string charname;
  12. public List<string> Names = new List<string>();
  13. public bool left;
  14. public bool forward;
  15. public bool triggeranimate;
  16. private void Update()
  17. {
  18. //for testing purposes
  19. if (triggeranimate == true)
  20. {
  21. Animate();
  22. triggeranimate = false;
  23. }
  24. }
  25. private void Start()
  26. {
  27. for (int i = 0; i < clientData.ConnectedClients.Count; i++)
  28. {
  29. Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)");
  30. }
  31. }
  32. void OnTriggerEnter(Collider other)
  33. {
  34. for (int i = 0; i < Names.Count; i++)
  35. {
  36. if (other.gameObject.name == Names[i])
  37. {
  38. characterOnBelt = true;
  39. charname = other.gameObject.name;
  40. }
  41. }
  42. }
  43. public void Animate()
  44. {
  45. player = GameObject.Find(charname);
  46. if(forward == true)
  47. {
  48. player.GetComponent<Character>().conveyorMoveForward(Direction.Forward, 1.0f);
  49. }
  50. else if (forward == false)
  51. {
  52. player.GetComponent<Character>().conveyorMoveBackward(Direction.Forward, 1.0f);
  53. }
  54. else if (left == true)
  55. {
  56. player.GetComponent<Character>().conveyorMoveLeft(Direction.Forward, 1.0f);
  57. }
  58. else if (left == false)
  59. {
  60. player.GetComponent<Character>().conveyorMoveRight(Direction.Forward, 1.0f);
  61. }
  62. }
  63. }