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.

45 lines
1.1 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Networking.Client;
  5. public class CannonShot : MonoBehaviour
  6. {
  7. public bool shootingRight;
  8. public ConnectedClients clientData;
  9. GameObject player;
  10. string charname;
  11. public List<string> Names;
  12. private void Start()
  13. {
  14. Names.Add("Character");
  15. /*for (int i = 0; i < clientData.AllClients.Count; i++)
  16. {
  17. Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
  18. }*/
  19. }
  20. void OnTriggerEnter(Collider other)
  21. {
  22. foreach (string name in Names)
  23. {
  24. Debug.Log(name);
  25. if (other.gameObject.name == name)
  26. {
  27. charname = other.gameObject.name;
  28. Debug.Log(charname);
  29. player = GameObject.Find(charname);
  30. if (shootingRight == true)
  31. {
  32. player.GetComponent<Character>().CannonLMove(1.0f);
  33. }
  34. else
  35. {
  36. player.GetComponent<Character>().CannonLMove(1.0f);
  37. }
  38. }
  39. }
  40. }
  41. }