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.

51 lines
1.3 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Networking.Client;
  5. public class ShootingCannon : MonoBehaviour
  6. {
  7. public bool shootingRight;
  8. public GameObject shootingObject;
  9. public ConnectedClients clientData;
  10. bool characterOnBelt = false;
  11. GameObject player;
  12. string charname;
  13. private List<string> Names;
  14. private void Start()
  15. {
  16. for (int i = 0; i < clientData.AllClients.Count; i++)
  17. {
  18. Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
  19. }
  20. }
  21. void OnTriggerEnter(Collider other)
  22. {
  23. for (int i = 0; i < Names.Count; i++)
  24. {
  25. if (other.gameObject.name == Names[i])
  26. {
  27. characterOnBelt = true;
  28. charname = other.gameObject.name;
  29. }
  30. }
  31. }
  32. public void Animate()
  33. {
  34. Vector3 position = new Vector3(0.0f, 1.338f, 0.25f);
  35. GameObject shot = Instantiate(shootingObject, position, Quaternion.identity);
  36. player = GameObject.Find(charname);
  37. if(shootingRight == true)
  38. {
  39. player.GetComponent<Character>().CannonRMove(Direction.Forward, 1.0f);
  40. }
  41. else
  42. {
  43. player.GetComponent<Character>().CannonLMove(Direction.Forward, 1.0f);
  44. }
  45. }
  46. }