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.6 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 Start()
  17. {
  18. for (int i = 0; i < clientData.ConnectedClients.Count; i++)
  19. {
  20. Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)");
  21. }
  22. }
  23. private void Update()
  24. {
  25. }
  26. void OnTriggerEnter(Collider other)
  27. {
  28. for (int i = 0; i < Names.Count; i++)
  29. {
  30. if (other.gameObject.name == Names[i])
  31. {
  32. characterOnBelt = true;
  33. charname = other.gameObject.name;
  34. }
  35. }
  36. }
  37. public void Animate()
  38. {
  39. player = GameObject.Find(charname);
  40. if(forward == true)
  41. {
  42. player.GetComponent<Character>().conveyorMoveForward(Direction.Forward, 1.0f);
  43. }
  44. else if (forward == false)
  45. {
  46. player.GetComponent<Character>().conveyorMoveBackward(Direction.Back, 1.0f);
  47. }
  48. if (left == true)
  49. {
  50. player.GetComponent<Character>().conveyorMoveLeft(Direction.Left, 1.0f);
  51. }
  52. else if (left == false)
  53. {
  54. player.GetComponent<Character>().conveyorMoveRight(Direction.Right, 1.0f);
  55. }
  56. }
  57. }