diff --git a/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab b/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab index 1fa3486..b041bb6 100644 --- a/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab +++ b/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab @@ -9,6 +9,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4787400513692267026} + - component: {fileID: 535408673737125727} + - component: {fileID: 3386372059152676518} + - component: {fileID: 3493367438702709850} m_Layer: 0 m_Name: Cannon_Shooting_Object m_TagString: Untagged @@ -31,6 +34,50 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &535408673737125727 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3506936643819969965} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 20a19dbbf99278d49837cc757add262e, type: 3} + m_Name: + m_EditorClassIdentifier: + shootingRight: 0 + clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2} + Names: [] +--- !u!54 &3386372059152676518 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3506936643819969965} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 1 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 +--- !u!65 &3493367438702709850 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3506936643819969965} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} --- !u!1001 &4032901744580679509 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Traps/Conveyor Belt.prefab b/Assets/Prefabs/Traps/Conveyor Belt.prefab index 327ec97..ffe59ec 100644 --- a/Assets/Prefabs/Traps/Conveyor Belt.prefab +++ b/Assets/Prefabs/Traps/Conveyor Belt.prefab @@ -44,6 +44,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6692f0c965cb4fa41b616ba0991653a3, type: 3} m_Name: m_EditorClassIdentifier: + clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2} --- !u!1 &6298733943245737397 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Traps/ShootingCannon.prefab b/Assets/Prefabs/Traps/ShootingCannon.prefab index 431b9d3..c8f4104 100644 --- a/Assets/Prefabs/Traps/ShootingCannon.prefab +++ b/Assets/Prefabs/Traps/ShootingCannon.prefab @@ -189,11 +189,11 @@ MonoBehaviour: lineCount: 1 pageCount: 1 materialCount: 1 - m_havePropertiesChanged: 0 + m_havePropertiesChanged: 1 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_spriteAnimator: {fileID: 0} - m_isInputParsingRequired: 0 + m_isInputParsingRequired: 1 m_inputSource: 0 m_hasFontAssetChanged: 0 m_renderer: {fileID: 1907555566} @@ -254,8 +254,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: shootingRight: 0 - shootingObject: {fileID: 0} - clientData: {fileID: 0} + shootingObject: {fileID: 3506936643819969965, guid: e8cf547bc36bd094f860f652fbe08047, + type: 3} + clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2} --- !u!65 &7713460145294617833 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity b/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity index df0c5d0..b887074 100644 --- a/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity +++ b/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b3eb5b014234b0d7d70f386fca2cb0bad8d1c78c801f973239658d26b6f8529 -size 176471 +oid sha256:57a10796a4b6ae47785d5aff82e05827e60c3c87a05107f924f289f3bd48265b +size 175456 diff --git a/Assets/Scenes/Trap Creation - Claire.unity b/Assets/Scenes/Trap Creation - Claire.unity index 0a1a88f..3a34268 100644 --- a/Assets/Scenes/Trap Creation - Claire.unity +++ b/Assets/Scenes/Trap Creation - Claire.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:153aef7b45a8aadfaedd2163e8244b73d7ba415080bd40510823bcecd1d69fae -size 24764 +oid sha256:80df00e537192d540e13c331dab9d71395b5c35ff337d240795774117fb0478f +size 23536 diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index a8c32bc..ccf2dd7 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -148,8 +148,8 @@ public class Character : MonoBehaviour IEnumerator PushLeftCoroutine(Transform Current, float time) { float elapsedTime = 0; - Vector3 startPosition = Current.position; - Vector3 endPosition = new Vector3(Current.position.x - 1, Current.position.y, Current.position.z); + Vector3 startPosition = Current.transform.position; + Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 10); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -164,8 +164,8 @@ public class Character : MonoBehaviour IEnumerator PushRightCoroutine(Transform Current, float time) { float elapsedTime = 0; - Vector3 startPosition = Current.position; - Vector3 endPosition = new Vector3(Current.position.x + 1, Current.position.y, Current.position.z); + Vector3 startPosition = Current.transform.position; + Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 10); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -253,11 +253,11 @@ public class Character : MonoBehaviour Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted StartCoroutine(MoveConveyorCoroutine(_currentBlock, transform, speed, 0.3f)); } - public void CannonRMove(Direction direction, float speed) + public void CannonRMove(float speed) { StartCoroutine(PushRightCoroutine(transform, speed)); } - public void CannonLMove(Direction direction, float speed) + public void CannonLMove(float speed) { StartCoroutine(PushLeftCoroutine(transform, speed)); } diff --git a/Assets/Scripts/Traps/CannonShot.cs b/Assets/Scripts/Traps/CannonShot.cs new file mode 100644 index 0000000..9a4a3ff --- /dev/null +++ b/Assets/Scripts/Traps/CannonShot.cs @@ -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 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().CannonLMove(1.0f); + } + else + { + player.GetComponent().CannonLMove(1.0f); + } + } + } + } + +} diff --git a/Assets/Scripts/Traps/CannonShot.cs.meta b/Assets/Scripts/Traps/CannonShot.cs.meta new file mode 100644 index 0000000..f9e175f --- /dev/null +++ b/Assets/Scripts/Traps/CannonShot.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 20a19dbbf99278d49837cc757add262e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Traps/ShootingCannon.cs b/Assets/Scripts/Traps/ShootingCannon.cs index 0cffe04..a6eec42 100644 --- a/Assets/Scripts/Traps/ShootingCannon.cs +++ b/Assets/Scripts/Traps/ShootingCannon.cs @@ -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 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().CannonRMove(Direction.Forward, 1.0f); + shot.GetComponent().AddForce(shot.transform.forward * -500); } else { - player.GetComponent().CannonLMove(Direction.Forward, 1.0f); + shot.GetComponent().AddForce(shot.transform.forward * 500); } } }