From 27ef03ad62cabd61d1cfafe63f2b297151150207 Mon Sep 17 00:00:00 2001 From: ClairePeta Date: Wed, 21 Aug 2019 18:29:50 +1000 Subject: [PATCH] Separated the traps that need to be called after each turn and then after each round in the traps script Tested it in the racetrack scene it gets a list of all the objects at runtime so when the functions are called will trigger them one at a time. Also got the characters moving correctly with the conveyor belts and the shooting cannon. --- .../Traps/Cannon_Shooting_Object.prefab | 2 +- Assets/Prefabs/Traps/CrushingBoulder.prefab | 22 +++--- Assets/Prefabs/Traps/InGroundTrap.prefab | 77 +++++++++++-------- Assets/Prefabs/Traps/ShootingCannon.prefab | 10 ++- Assets/Scenes/RaceTrack 4-player alpha.unity | 4 +- .../SinglePlayer Levels/TuteLevelOne.unity | 4 +- Assets/Scripts/Character.cs | 71 ++++++++++++++--- Assets/Scripts/Traps/CannonShot.cs | 14 ++-- Assets/Scripts/Traps/ConveyorBelt.cs | 25 +++--- Assets/Scripts/Traps/CrushingBoulder.cs | 17 +++- Assets/Scripts/Traps/ShootingCannon.cs | 32 +++++--- Assets/Scripts/Traps/Traps.cs | 69 ++++++++++++----- 12 files changed, 237 insertions(+), 110 deletions(-) diff --git a/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab b/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab index 844c159..1d3ecb8 100644 --- a/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab +++ b/Assets/Prefabs/Traps/Cannon_Shooting_Object.prefab @@ -46,7 +46,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 20a19dbbf99278d49837cc757add262e, type: 3} m_Name: m_EditorClassIdentifier: - shootingRight: 0 + shootingRight: 1 clientData: {fileID: 11400000, guid: 78d89605739516c4f9c66fb270137102, type: 2} Names: [] --- !u!54 &3386372059152676518 diff --git a/Assets/Prefabs/Traps/CrushingBoulder.prefab b/Assets/Prefabs/Traps/CrushingBoulder.prefab index 8c0a3be..a0bce27 100644 --- a/Assets/Prefabs/Traps/CrushingBoulder.prefab +++ b/Assets/Prefabs/Traps/CrushingBoulder.prefab @@ -19,7 +19,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &6745622315908332759 RectTransform: m_ObjectHideFlags: 0 @@ -112,7 +112,7 @@ MonoBehaviour: m_Calls: [] m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_text: 3 + m_text: 5 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -254,6 +254,8 @@ MonoBehaviour: m_EditorClassIdentifier: triggeranimate: 0 triggeranimate1: 0 + countdowntimer: 3 + counter: {fileID: 6745622315908332755} --- !u!1001 &6745622316608603784 PrefabInstance: m_ObjectHideFlags: 0 @@ -261,6 +263,14 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 6745622317302131140} m_Modifications: + - target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} + propertyPath: m_Name + value: Rock_2 (2) + objectReference: {fileID: 0} + - target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} + propertyPath: m_StaticEditorFlags + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4614242176542224, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -313,14 +323,6 @@ PrefabInstance: propertyPath: m_LocalScale.z value: 1.2289 objectReference: {fileID: 0} - - target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} - propertyPath: m_Name - value: Rock_2 (2) - objectReference: {fileID: 0} - - target: {fileID: 1252527896654764, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} - propertyPath: m_StaticEditorFlags - value: 0 - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d2a34a5082f5c524b845ab11a78a7214, type: 3} --- !u!4 &6741087515541790872 stripped diff --git a/Assets/Prefabs/Traps/InGroundTrap.prefab b/Assets/Prefabs/Traps/InGroundTrap.prefab index 5b4086d..c1dfff4 100644 --- a/Assets/Prefabs/Traps/InGroundTrap.prefab +++ b/Assets/Prefabs/Traps/InGroundTrap.prefab @@ -9,6 +9,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3281312547625224782} + - component: {fileID: 666895481879696395} m_Layer: 0 m_Name: InGroundTrap m_TagString: Untagged @@ -35,6 +36,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &666895481879696395 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3281312547625224785} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90d16cd20b1d52149ae6b3d4c15c79db, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1063799847781320221 PrefabInstance: m_ObjectHideFlags: 0 @@ -115,6 +128,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3280778023726093299} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (4) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -159,10 +176,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 180 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (4) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!1001 &3281312546064687605 @@ -172,6 +185,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3281312547625224782} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (3) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -220,10 +237,6 @@ PrefabInstance: propertyPath: m_LocalScale.x value: 0.9 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (3) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!4 &3280778022459986741 stripped @@ -239,6 +252,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3280778023471378434} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (4) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -283,10 +300,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 180 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (4) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!1001 &3281312547073059897 @@ -296,6 +309,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3280778023765625369} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (4) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -340,10 +357,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 180 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (4) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!1001 &3281312547210150594 @@ -353,6 +366,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3281312547625224782} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (4) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: -0.4 @@ -401,10 +418,6 @@ PrefabInstance: propertyPath: m_LocalScale.x value: 0.90000045 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (4) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!4 &3280778023471378434 stripped @@ -420,6 +433,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3280778022459986741} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (4) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -464,10 +481,6 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 180 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (4) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!1001 &3281312547451467993 @@ -477,6 +490,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3281312547625224782} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (1) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0 @@ -525,10 +542,6 @@ PrefabInstance: propertyPath: m_LocalScale.x value: 0.9 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (1) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!4 &3280778023765625369 stripped @@ -544,6 +557,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 3281312547625224782} m_Modifications: + - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} + propertyPath: m_Name + value: FanceWooden2 (2) + objectReference: {fileID: 0} - target: {fileID: 4004810153341632, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} propertyPath: m_LocalPosition.x value: 0.4 @@ -592,10 +609,6 @@ PrefabInstance: propertyPath: m_LocalScale.x value: 0.90000045 objectReference: {fileID: 0} - - target: {fileID: 1989401929107402, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} - propertyPath: m_Name - value: FanceWooden2 (2) - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 0247930279caa4341ab23ddd2d4b69f8, type: 3} --- !u!4 &3280778023726093299 stripped diff --git a/Assets/Prefabs/Traps/ShootingCannon.prefab b/Assets/Prefabs/Traps/ShootingCannon.prefab index b3de7e9..4363136 100644 --- a/Assets/Prefabs/Traps/ShootingCannon.prefab +++ b/Assets/Prefabs/Traps/ShootingCannon.prefab @@ -19,7 +19,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &1907555562 RectTransform: m_ObjectHideFlags: 0 @@ -112,7 +112,7 @@ MonoBehaviour: m_Calls: [] m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - m_text: 3 + m_text: 5 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -189,11 +189,11 @@ MonoBehaviour: lineCount: 1 pageCount: 1 materialCount: 1 - m_havePropertiesChanged: 1 + m_havePropertiesChanged: 0 m_isUsingLegacyAnimationComponent: 0 m_isVolumetricText: 0 m_spriteAnimator: {fileID: 0} - m_isInputParsingRequired: 1 + m_isInputParsingRequired: 0 m_inputSource: 0 m_hasFontAssetChanged: 0 m_renderer: {fileID: 1907555566} @@ -258,6 +258,8 @@ MonoBehaviour: shootingObject: {fileID: 3506936643819969965, guid: e8cf547bc36bd094f860f652fbe08047, type: 3} spawnLocation: {fileID: 4411312180479633393} + counter: {fileID: 1907555563} + countdowntimer: 3 --- !u!65 &7713460145294617833 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/RaceTrack 4-player alpha.unity b/Assets/Scenes/RaceTrack 4-player alpha.unity index 521fb9e..a7cf3a7 100644 --- a/Assets/Scenes/RaceTrack 4-player alpha.unity +++ b/Assets/Scenes/RaceTrack 4-player alpha.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8a88996c6bfd31688f0b46e64f918125b639084deb91f199c306dda93b01aca4 -size 2624360 +oid sha256:7be58d4f752cf70994f98e1f81da9f2ce27e73e9e95de716b444a88486600f4d +size 2625440 diff --git a/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity b/Assets/Scenes/SinglePlayer Levels/TuteLevelOne.unity index 5eaae95..126839d 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:c8e8d2f57e329f92cb93b55207f5503202561f255ea42a94928d442f2242f556 -size 214523 +oid sha256:c9f869597272fd86bfc59dfb1e3a8872795c1485a0ea1aa391eba0356ead9bbc +size 215101 diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 8567458..9beb1d1 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -203,7 +203,7 @@ public class Character : MonoBehaviour { float elapsedTime = 0; Vector3 startPosition = Current.transform.position; - Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f); + Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -219,7 +219,7 @@ public class Character : MonoBehaviour { float elapsedTime = 0; Vector3 startPosition = Current.transform.position; - Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z + 1.0f); + Vector3 endPosition = new Vector3(Current.position.x, Current.position.y, Current.position.z - 1.0f); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -296,36 +296,83 @@ public class Character : MonoBehaviour _currentBlock = moveTo; StartCoroutine(MoveDownCoroutine(_currentBlock, transform, speed, 0.3f)); } - //set current block && move - //CurrentBlock = moveTo; - //StartCoroutine(MoveCoroutine(CurrentBlock, transform, speed, 0.3f)); - //transform.position = CurrentBlock.VisualPosition; } public void conveyorMoveForward(Direction direction, float speed) { - StartCoroutine(MoveConveyorForwardCoroutine(_currentBlock, transform, speed, 0.3f)); + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(MoveConveyorForwardCoroutine(_currentBlock, transform, speed, 0.3f)); + } + } public void conveyorMoveBackward(Direction direction, float speed) { - StartCoroutine(MoveConveyorBackwardCoroutine(_currentBlock, transform, speed, 0.3f)); + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(MoveConveyorBackwardCoroutine(_currentBlock, transform, speed, 0.3f)); + } } public void conveyorMoveLeft(Direction direction, float speed) { - StartCoroutine(MoveConveyorLeftCoroutine(_currentBlock, transform, speed, 0.3f)); + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(MoveConveyorLeftCoroutine(_currentBlock, transform, speed, 0.3f)); + } } public void conveyorMoveRight(Direction direction, float speed) { - StartCoroutine(MoveConveyorRightCoroutine(_currentBlock, transform, speed, 0.3f)); + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(MoveConveyorRightCoroutine(_currentBlock, transform, speed, 0.3f)); + } } public void CannonRMove(float speed) { - StartCoroutine(PushRightCoroutine(transform, speed)); + Direction direction = Direction.Right; + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(PushRightCoroutine(transform, speed)); + } } public void CannonLMove(float speed) { - StartCoroutine(PushLeftCoroutine(transform, speed)); + Direction direction = Direction.Left; + Vector3 position = _currentBlock.position + direction.ToVector(transform); // position wanted + Block hit; //output of block detection + Block moveTo = _currentBlock; //block we'll actually move to + if (Block.isBlockAtPosition(position, 1, ~Ignore, out hit) && hit.isWalkable(~Ignore)) + { + moveTo = hit; + _currentBlock = moveTo; + StartCoroutine(PushLeftCoroutine(transform, speed)); + } } diff --git a/Assets/Scripts/Traps/CannonShot.cs b/Assets/Scripts/Traps/CannonShot.cs index 257f501..b8636b8 100644 --- a/Assets/Scripts/Traps/CannonShot.cs +++ b/Assets/Scripts/Traps/CannonShot.cs @@ -16,17 +16,17 @@ public class CannonShot : MonoBehaviour { Names.Add("Character"); rb = this.gameObject.GetComponent(); - for (int i = 0; i < clientData.AllClients.Count; i++) + /*for (int i = 0; i < clientData.AllClients.Count; i++) { Names.Add(clientData.AllClients[i].characterAnimal + "(Clone)"); - } + }*/ } IEnumerator PushLeftCoroutine(float time) { float elapsedTime = 0; Vector3 startPosition = transform.position; - Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f); + Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -38,11 +38,11 @@ public class CannonShot : MonoBehaviour transform.position = endPosition; Destroy(gameObject); } - IEnumerator PushRightCoroutine(Transform Current, float time) + IEnumerator PushRightCoroutine(float time) { float elapsedTime = 0; Vector3 startPosition = transform.position; - Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z + 1.0f); + Vector3 endPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.0f); time *= 0.8f; yield return new WaitForSeconds(0.05f); while (elapsedTime < time) @@ -66,8 +66,8 @@ public class CannonShot : MonoBehaviour Rigidbody playerRB = player.GetComponent(); if (shootingRight == true) { - StartCoroutine(PushLeftCoroutine(0.5f)); - player.GetComponent().CannonLMove(0.5f); + StartCoroutine(PushRightCoroutine(0.5f)); + player.GetComponent().CannonRMove(0.5f); } else { diff --git a/Assets/Scripts/Traps/ConveyorBelt.cs b/Assets/Scripts/Traps/ConveyorBelt.cs index 9316039..e885e10 100644 --- a/Assets/Scripts/Traps/ConveyorBelt.cs +++ b/Assets/Scripts/Traps/ConveyorBelt.cs @@ -9,12 +9,21 @@ public class ConveyorBelt : MonoBehaviour public ClientList clientData; bool characterOnBelt = false; GameObject player; - string charname; + string charname = "Character"; public List Names = new List(); public bool left; public bool forward; public bool triggeranimate; + + private void Start() + { + for (int i = 0; i < clientData.ConnectedClients.Count; i++) + { + Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)"); + } + } + private void Update() { //for testing purposes @@ -25,13 +34,7 @@ public class ConveyorBelt : MonoBehaviour } } - private void Start() - { - for (int i = 0; i < clientData.ConnectedClients.Count; i++) - { - Names.Add(clientData.ConnectedClients[i].characterAnimal + "(Clone)"); - } - } + void OnTriggerEnter(Collider other) { for (int i = 0; i < Names.Count; i++) @@ -54,15 +57,15 @@ public class ConveyorBelt : MonoBehaviour } else if (forward == false) { - player.GetComponent().conveyorMoveBackward(Direction.Forward, 1.0f); + player.GetComponent().conveyorMoveBackward(Direction.Back, 1.0f); } else if (left == true) { - player.GetComponent().conveyorMoveLeft(Direction.Forward, 1.0f); + player.GetComponent().conveyorMoveLeft(Direction.Left, 1.0f); } else if (left == false) { - player.GetComponent().conveyorMoveRight(Direction.Forward, 1.0f); + player.GetComponent().conveyorMoveRight(Direction.Right, 1.0f); } } } diff --git a/Assets/Scripts/Traps/CrushingBoulder.cs b/Assets/Scripts/Traps/CrushingBoulder.cs index 5614944..66489f8 100644 --- a/Assets/Scripts/Traps/CrushingBoulder.cs +++ b/Assets/Scripts/Traps/CrushingBoulder.cs @@ -1,14 +1,23 @@ using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; public class CrushingBoulder : MonoBehaviour { public bool triggeranimate; public bool triggeranimate1; + public int countdowntimer; + public TextMeshPro counter; + int countdown; + private void Start() + { + countdown = countdowntimer; + } private void Update() { + counter.text = countdown.ToString(); //for testing purposes if (triggeranimate == true) { @@ -39,7 +48,13 @@ public class CrushingBoulder : MonoBehaviour public void Animate() { - StartCoroutine(FallRaiseCoroutine(-2.0f)); + countdown--; + if (countdown == 0) + { + StartCoroutine(FallRaiseCoroutine(-2.0f)); + countdown = countdowntimer; + returnToPosition(); + } } public void returnToPosition() { diff --git a/Assets/Scripts/Traps/ShootingCannon.cs b/Assets/Scripts/Traps/ShootingCannon.cs index a6eec42..bf40bb8 100644 --- a/Assets/Scripts/Traps/ShootingCannon.cs +++ b/Assets/Scripts/Traps/ShootingCannon.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; @@ -9,9 +10,17 @@ public class ShootingCannon : MonoBehaviour public bool triggeranimate; public GameObject shootingObject; public Transform spawnLocation; + public TextMeshPro counter; + public int countdowntimer; + int countdown; + private void Start() + { + countdown = countdowntimer; + } private void Update() { + counter.text = countdown.ToString(); //for testing purposes if (triggeranimate == true) { @@ -22,14 +31,19 @@ public class ShootingCannon : MonoBehaviour public void Animate() { - GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity); - if (shootingRight == true) - { - shot.GetComponent().AddForce(shot.transform.forward * -500); - } - else - { - shot.GetComponent().AddForce(shot.transform.forward * 500); - } + countdown--; + // if (countdown == 0){ + GameObject shot = Instantiate(shootingObject, spawnLocation.position, Quaternion.identity); + if (shootingRight == true) + { + shot.GetComponent().AddForce(shot.transform.forward * -500); + } + else + { + shot.GetComponent().AddForce(shot.transform.forward * 500); + } + countdown = countdowntimer; + //} + } } diff --git a/Assets/Scripts/Traps/Traps.cs b/Assets/Scripts/Traps/Traps.cs index 02da176..0e64ba6 100644 --- a/Assets/Scripts/Traps/Traps.cs +++ b/Assets/Scripts/Traps/Traps.cs @@ -5,38 +5,69 @@ using UnityEngine; public class Traps : MonoBehaviour { - public List ConveyorBelts; - public List CrushingBoulders; - public List CubesWithCrystals; - public List FloatingOnWater; - //public List InGroundTraps; - public List ShootingCannons; + public List ConveyorBelts = new List(); + public List CrushingBoulders = new List(); + public List CubesWithCrystals = new List(); + public List FloatingOnWater = new List(); + public List InGroundTraps = new List(); + public List ShootingCannons = new List(); + + private void Start() + { + ConveyorBelts.AddRange(GameObject.FindObjectsOfType()); + CrushingBoulders.AddRange(GameObject.FindObjectsOfType()); + CubesWithCrystals.AddRange(GameObject.FindObjectsOfType()); + FloatingOnWater.AddRange(GameObject.FindObjectsOfType()); + InGroundTraps.AddRange(GameObject.FindObjectsOfType()); + ShootingCannons.AddRange(GameObject.FindObjectsOfType()); + } public void environmentTurn() { - for(int a = 0; a < ConveyorBelts.Count; a++) + if (ConveyorBelts.Count > 0) { - ConveyorBelts[a].GetComponent().Animate(); + foreach(ConveyorBelt belt in ConveyorBelts) + { + belt.Animate(); + } } - for (int b = 0; b < CrushingBoulders.Count; b++) + if (CrushingBoulders.Count > 0) { - CrushingBoulders[b].GetComponent().Animate(); + foreach (CrushingBoulder boulder in CrushingBoulders) + { + boulder.Animate(); + } } - for (int c = 0; c < CubesWithCrystals.Count; c++) + if (ShootingCannons.Count > 0) { - CubesWithCrystals[c].GetComponent().Animate(); + foreach (ShootingCannon cannon in ShootingCannons) + { + cannon.Animate(); + } } - for (int d = 0; d < FloatingOnWater.Count; d++) + } + public void environmentRound() + { + if (CubesWithCrystals.Count > 0) { - FloatingOnWater[d].GetComponent().Animate(); + foreach (CubeWithCrystals crystal in CubesWithCrystals) + { + crystal.Animate(); + } } - /*for (int e = 0; e < InGroundTraps.Count; e++) + if (FloatingOnWater.Count > 0) { - InGroundTraps[e].GetComponent().Animate(); - }*/ - for (int f = 0; f < ShootingCannons.Count; f++) + foreach (FloatingOnWater water in FloatingOnWater) + { + water.Animate(); + } + } + if (InGroundTraps.Count > 0) { - ShootingCannons[f].GetComponent().Animate(); + foreach (InGroundTrap ground in InGroundTraps) + { + ground.Animate(); + } } } }