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.

67 lines
1.7 KiB

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