From b6e018ada33f3fd05d9435b0bc5862f2d4e8a3a0 Mon Sep 17 00:00:00 2001 From: Marc Tismonar Date: Thu, 20 Jun 2024 11:35:17 +0200 Subject: [PATCH] SharpBlock - Object improved --- .../Enemys/SharpBlock/Scripts/SharpBlock.cs | 43 +++++++++----- Assets/game/Scenes/level2.unity | 4 +- UserSettings/Layouts/default-2021.dwlt | 59 ++++++++++++------- 3 files changed, 69 insertions(+), 37 deletions(-) diff --git a/Assets/game/Enemys/SharpBlock/Scripts/SharpBlock.cs b/Assets/game/Enemys/SharpBlock/Scripts/SharpBlock.cs index 5dff4403..5464de1f 100644 --- a/Assets/game/Enemys/SharpBlock/Scripts/SharpBlock.cs +++ b/Assets/game/Enemys/SharpBlock/Scripts/SharpBlock.cs @@ -10,15 +10,16 @@ public class SharpBlock : MonoBehaviour public Animator animator; [Header("Variables")] - public float speed = 0; - public float timeDelayOnHit = 1.0f; - public bool isMovingRight = true; + public float speed = 10; + public float timeDelayOnHit = 5.0f; + public bool isMovingRightOrUp = true; + public bool horizontal = true; bool isChangingDirection = false; void Awake() { rb = GetComponent(); - animator.SetInteger("AnimSpeedDecider", isMovingRight ? 1 : -1); + animator.SetInteger("AnimSpeedDecider", isMovingRightOrUp ? 1 : -1); } void Update() @@ -29,13 +30,27 @@ public class SharpBlock : MonoBehaviour } else { - if (isMovingRight && !isChangingDirection) + if (horizontal) { - rb.velocity = new Vector2(speed, rb.velocity.y); + if (isMovingRightOrUp && !isChangingDirection) + { + rb.velocity = new Vector2(speed, rb.velocity.y); + } + else if (!isMovingRightOrUp && !isChangingDirection) + { + rb.velocity = new Vector2(-speed, rb.velocity.y); + } } - else if (!isMovingRight && !isChangingDirection) + else { - rb.velocity = new Vector2(-speed, rb.velocity.y); + if (isMovingRightOrUp && !isChangingDirection) + { + rb.velocity = new Vector2(rb.velocity.x, speed); + } + else if (!isMovingRightOrUp && !isChangingDirection) + { + rb.velocity = new Vector2(rb.velocity.x, -speed); + } } } } @@ -47,7 +62,7 @@ public class SharpBlock : MonoBehaviour StartCoroutine(ChangeDirection()); audioSource.Play(); } - + if (collision.gameObject.CompareTag("Player")) { LevelMgr.killPlayer = true; @@ -58,13 +73,13 @@ public class SharpBlock : MonoBehaviour { isChangingDirection = true; rb.velocity = Vector2.zero; - - yield return new WaitForSeconds(timeDelayOnHit/2); - isMovingRight = !isMovingRight; - animator.SetInteger("AnimSpeedDecider", isMovingRight ? 1 : -1); + yield return new WaitForSeconds(timeDelayOnHit / 2); - yield return new WaitForSeconds(timeDelayOnHit/2); + isMovingRightOrUp = !isMovingRightOrUp; + animator.SetInteger("AnimSpeedDecider", isMovingRightOrUp ? 1 : -1); + + yield return new WaitForSeconds(timeDelayOnHit / 2); isChangingDirection = false; } } \ No newline at end of file diff --git a/Assets/game/Scenes/level2.unity b/Assets/game/Scenes/level2.unity index dda42102..914dc18b 100644 --- a/Assets/game/Scenes/level2.unity +++ b/Assets/game/Scenes/level2.unity @@ -2641,8 +2641,8 @@ MonoBehaviour: m_EditorClassIdentifier: audioSource: {fileID: 406194642} animator: {fileID: 406194637} - speed: 5 - timeDelayOnHit: 1 + speed: 10 + timeDelayOnHit: 5 isMovingRight: 0 --- !u!1 &417760883 GameObject: diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 17557046..27a7ffd3 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -19,7 +19,7 @@ MonoBehaviour: width: 1600 height: 817 m_ShowMode: 4 - m_Title: Game + m_Title: Project m_RootView: {fileID: 2} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} @@ -120,7 +120,7 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 93 + controlID: 124 --- !u!114 &6 MonoBehaviour: m_ObjectHideFlags: 52 @@ -145,7 +145,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 100 + controlID: 125 --- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 @@ -192,8 +192,8 @@ MonoBehaviour: y: 392 width: 680 height: 375 - m_MinSize: {x: 201, y: 221} - m_MaxSize: {x: 4001, y: 4021} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 13} m_Panes: - {fileID: 13} @@ -226,7 +226,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 123 + controlID: 65 --- !u!114 &10 MonoBehaviour: m_ObjectHideFlags: 52 @@ -298,8 +298,8 @@ MonoBehaviour: y: 0 width: 374 height: 767 - m_MinSize: {x: 276, y: 71} - m_MaxSize: {x: 4001, y: 4021} + m_MinSize: {x: 275, y: 50} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 21} m_Panes: - {fileID: 21} @@ -765,6 +765,7 @@ MonoBehaviour: - {fileID: -6854107038944686753, guid: 9941e73f825ec92499165b0615533f68, type: 2} - {fileID: 1766154229804822364, guid: a4e29ec1b853f234c8ce7b88b5a3ea39, type: 2} - {fileID: 1191776569487272199, guid: b022e0107310a0745a6942b46cdb72c6, type: 2} + - {fileID: 1191776569487272199, guid: dae0a2438d6ef974d921647304d32b50, type: 2} m_ValueSerializationHelper: - e00: 1 e01: 0 @@ -862,10 +863,26 @@ MonoBehaviour: e31: 0 e32: 0 e33: 1 + - e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 m_PreviewAnimator: {fileID: 0} - m_AnimatorController: {fileID: 9100000, guid: b022e0107310a0745a6942b46cdb72c6, type: 2} + m_AnimatorController: {fileID: 9100000, guid: dae0a2438d6ef974d921647304d32b50, type: 2} m_BreadCrumbs: - - m_Target: {fileID: 1191776569487272199, guid: b022e0107310a0745a6942b46cdb72c6, type: 2} + - m_Target: {fileID: 1191776569487272199, guid: dae0a2438d6ef974d921647304d32b50, type: 2} m_ScrollPosition: {x: 0, y: 0} stateMachineGraph: {fileID: 0} stateMachineGraphGUI: {fileID: 0} @@ -938,7 +955,7 @@ MonoBehaviour: m_OverlaysVisible: 1 m_LockTracker: m_IsLocked: 0 - m_LastSelectedObjectID: 30066 + m_LastSelectedObjectID: -2904 --- !u!114 &18 MonoBehaviour: m_ObjectHideFlags: 52 @@ -1001,9 +1018,9 @@ MonoBehaviour: m_SceneHierarchy: m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: + m_SelectedIDs: b65e0000 m_LastClickedID: 0 - m_ExpandedIDs: + m_ExpandedIDs: dcfaffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -1067,23 +1084,23 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Assets/game/player + - Assets/game/Scripts/Save m_Globs: [] m_OriginalText: m_FilterByTypeIntersection: 0 m_ViewMode: 1 m_StartGridSize: 64 m_LastFolders: - - Assets/game/player + - Assets/game/Scripts/Save m_LastFoldersGridSize: 64 m_LastProjectPath: C:\Users\Marc Tismonar\unity\SynthMaze m_LockTracker: m_IsLocked: 0 m_FolderTreeState: - scrollPos: {x: 0, y: 223} - m_SelectedIDs: 187d0000 - m_LastClickedID: 32024 - m_ExpandedIDs: 00000000b67c0000c87c000000ca9a3bffffff7f + scrollPos: {x: 0, y: 159} + m_SelectedIDs: b2800000 + m_LastClickedID: 32946 + m_ExpandedIDs: 00000000e27c0000f47c0000467d0000487d0000647d000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -1111,7 +1128,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 00000000b67c0000 + m_ExpandedIDs: 00000000e27c0000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -1138,7 +1155,7 @@ MonoBehaviour: m_ListAreaState: m_SelectedInstanceIDs: m_LastClickedInstanceID: 0 - m_HadKeyboardFocusLastEvent: 0 + m_HadKeyboardFocusLastEvent: 1 m_ExpandedInstanceIDs: 92db0000 m_RenameOverlay: m_UserAcceptedRename: 0