|
|
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Networking.Client;
-
- public class ShootingCannon : MonoBehaviour
- {
- public bool shootingRight;
- public GameObject shootingObject;
- public ConnectedClients clientData;
- bool characterOnBelt = false;
- GameObject player;
- string charname;
- private List<string> Names;
-
- private void Start()
- {
- for (int i = 0; i < clientData.AllClients.Count; i++)
- {
- Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)");
- }
- }
-
- void OnTriggerEnter(Collider other)
- {
- for (int i = 0; i < Names.Count; i++)
- {
- if (other.gameObject.name == Names[i])
- {
- characterOnBelt = true;
- charname = other.gameObject.name;
- }
- }
- }
-
- public void Animate()
- {
- Vector3 position = new Vector3(0.0f, 1.338f, 0.25f);
- GameObject shot = Instantiate(shootingObject, position, Quaternion.identity);
-
- player = GameObject.Find(charname);
- if(shootingRight == true)
- {
- player.GetComponent<Character>().CannonRMove(Direction.Forward, 1.0f);
- }
- else
- {
- player.GetComponent<Character>().CannonLMove(Direction.Forward, 1.0f);
- }
- }
- }
|