@ -1,3 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:9b3eb5b014234b0d7d70f386fca2cb0bad8d1c78c801f973239658d26b6f8529 | |||
size 176471 | |||
oid sha256:57a10796a4b6ae47785d5aff82e05827e60c3c87a05107f924f289f3bd48265b | |||
size 175456 |
@ -1,3 +1,3 @@ | |||
version https://git-lfs.github.com/spec/v1 | |||
oid sha256:153aef7b45a8aadfaedd2163e8244b73d7ba415080bd40510823bcecd1d69fae | |||
size 24764 | |||
oid sha256:80df00e537192d540e13c331dab9d71395b5c35ff337d240795774117fb0478f | |||
size 23536 |
@ -0,0 +1,45 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using UnityEngine; | |||
using Networking.Client; | |||
public class CannonShot : MonoBehaviour | |||
{ | |||
public bool shootingRight; | |||
public ConnectedClients clientData; | |||
GameObject player; | |||
string charname; | |||
public List<string> Names; | |||
private void Start() | |||
{ | |||
Names.Add("Character"); | |||
/*for (int i = 0; i < clientData.AllClients.Count; i++) | |||
{ | |||
Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)"); | |||
}*/ | |||
} | |||
void OnTriggerEnter(Collider other) | |||
{ | |||
foreach (string name in Names) | |||
{ | |||
Debug.Log(name); | |||
if (other.gameObject.name == name) | |||
{ | |||
charname = other.gameObject.name; | |||
Debug.Log(charname); | |||
player = GameObject.Find(charname); | |||
if (shootingRight == true) | |||
{ | |||
player.GetComponent<Character>().CannonLMove(1.0f); | |||
} | |||
else | |||
{ | |||
player.GetComponent<Character>().CannonLMove(1.0f); | |||
} | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,11 @@ | |||
fileFormatVersion: 2 | |||
guid: 20a19dbbf99278d49837cc757add262e | |||
MonoImporter: | |||
externalObjects: {} | |||
serializedVersion: 2 | |||
defaultReferences: [] | |||
executionOrder: 0 | |||
icon: {instanceID: 0} | |||
userData: | |||
assetBundleName: | |||
assetBundleVariant: |
@ -1,51 +1,35 @@ | |||
using System.Collections; | |||
using System.Collections.Generic; | |||
using UnityEngine; | |||
using Networking.Client; | |||
public class ShootingCannon : MonoBehaviour | |||
{ | |||
public bool shootingRight; | |||
public bool triggeranimate; | |||
public GameObject shootingObject; | |||
public ConnectedClients clientData; | |||
bool characterOnBelt = false; | |||
GameObject player; | |||
string charname; | |||
private List<string> Names; | |||
public Transform spawnLocation; | |||
private void Start() | |||
private void Update() | |||
{ | |||
for (int i = 0; i < clientData.AllClients.Count; i++) | |||
//for testing purposes | |||
if (triggeranimate == true) | |||
{ | |||
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; | |||
} | |||
Animate(); | |||
triggeranimate = false; | |||
} | |||
} | |||
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) | |||
GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity); | |||
if (shootingRight == true) | |||
{ | |||
player.GetComponent<Character>().CannonRMove(Direction.Forward, 1.0f); | |||
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * -500); | |||
} | |||
else | |||
{ | |||
player.GetComponent<Character>().CannonLMove(Direction.Forward, 1.0f); | |||
shot.GetComponent<Rigidbody>().AddForce(shot.transform.forward * 500); | |||
} | |||
} | |||
} |