mirror of
https://github.com/Kizuren/SynthMaze.git
synced 2025-12-21 21:16:08 +01:00
SharpBlock - Object improved
This commit is contained in:
parent
cead3ff93c
commit
b6e018ada3
3 changed files with 69 additions and 37 deletions
|
|
@ -10,15 +10,16 @@ public class SharpBlock : MonoBehaviour
|
||||||
public Animator animator;
|
public Animator animator;
|
||||||
|
|
||||||
[Header("Variables")]
|
[Header("Variables")]
|
||||||
public float speed = 0;
|
public float speed = 10;
|
||||||
public float timeDelayOnHit = 1.0f;
|
public float timeDelayOnHit = 5.0f;
|
||||||
public bool isMovingRight = true;
|
public bool isMovingRightOrUp = true;
|
||||||
|
public bool horizontal = true;
|
||||||
bool isChangingDirection = false;
|
bool isChangingDirection = false;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
animator.SetInteger("AnimSpeedDecider", isMovingRight ? 1 : -1);
|
animator.SetInteger("AnimSpeedDecider", isMovingRightOrUp ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
|
|
@ -29,13 +30,27 @@ public class SharpBlock : MonoBehaviour
|
||||||
}
|
}
|
||||||
else
|
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());
|
StartCoroutine(ChangeDirection());
|
||||||
audioSource.Play();
|
audioSource.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision.gameObject.CompareTag("Player"))
|
if (collision.gameObject.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
LevelMgr.killPlayer = true;
|
LevelMgr.killPlayer = true;
|
||||||
|
|
@ -58,13 +73,13 @@ public class SharpBlock : MonoBehaviour
|
||||||
{
|
{
|
||||||
isChangingDirection = true;
|
isChangingDirection = true;
|
||||||
rb.velocity = Vector2.zero;
|
rb.velocity = Vector2.zero;
|
||||||
|
|
||||||
yield return new WaitForSeconds(timeDelayOnHit/2);
|
|
||||||
|
|
||||||
isMovingRight = !isMovingRight;
|
yield return new WaitForSeconds(timeDelayOnHit / 2);
|
||||||
animator.SetInteger("AnimSpeedDecider", isMovingRight ? 1 : -1);
|
|
||||||
|
|
||||||
yield return new WaitForSeconds(timeDelayOnHit/2);
|
isMovingRightOrUp = !isMovingRightOrUp;
|
||||||
|
animator.SetInteger("AnimSpeedDecider", isMovingRightOrUp ? 1 : -1);
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(timeDelayOnHit / 2);
|
||||||
isChangingDirection = false;
|
isChangingDirection = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2641,8 +2641,8 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
audioSource: {fileID: 406194642}
|
audioSource: {fileID: 406194642}
|
||||||
animator: {fileID: 406194637}
|
animator: {fileID: 406194637}
|
||||||
speed: 5
|
speed: 10
|
||||||
timeDelayOnHit: 1
|
timeDelayOnHit: 5
|
||||||
isMovingRight: 0
|
isMovingRight: 0
|
||||||
--- !u!1 &417760883
|
--- !u!1 &417760883
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ MonoBehaviour:
|
||||||
width: 1600
|
width: 1600
|
||||||
height: 817
|
height: 817
|
||||||
m_ShowMode: 4
|
m_ShowMode: 4
|
||||||
m_Title: Game
|
m_Title: Project
|
||||||
m_RootView: {fileID: 2}
|
m_RootView: {fileID: 2}
|
||||||
m_MinSize: {x: 875, y: 300}
|
m_MinSize: {x: 875, y: 300}
|
||||||
m_MaxSize: {x: 10000, y: 10000}
|
m_MaxSize: {x: 10000, y: 10000}
|
||||||
|
|
@ -120,7 +120,7 @@ MonoBehaviour:
|
||||||
m_MinSize: {x: 300, y: 200}
|
m_MinSize: {x: 300, y: 200}
|
||||||
m_MaxSize: {x: 24288, y: 16192}
|
m_MaxSize: {x: 24288, y: 16192}
|
||||||
vertical: 0
|
vertical: 0
|
||||||
controlID: 93
|
controlID: 124
|
||||||
--- !u!114 &6
|
--- !u!114 &6
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
|
|
@ -145,7 +145,7 @@ MonoBehaviour:
|
||||||
m_MinSize: {x: 100, y: 200}
|
m_MinSize: {x: 100, y: 200}
|
||||||
m_MaxSize: {x: 8096, y: 16192}
|
m_MaxSize: {x: 8096, y: 16192}
|
||||||
vertical: 1
|
vertical: 1
|
||||||
controlID: 100
|
controlID: 125
|
||||||
--- !u!114 &7
|
--- !u!114 &7
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
|
|
@ -192,8 +192,8 @@ MonoBehaviour:
|
||||||
y: 392
|
y: 392
|
||||||
width: 680
|
width: 680
|
||||||
height: 375
|
height: 375
|
||||||
m_MinSize: {x: 201, y: 221}
|
m_MinSize: {x: 200, y: 200}
|
||||||
m_MaxSize: {x: 4001, y: 4021}
|
m_MaxSize: {x: 4000, y: 4000}
|
||||||
m_ActualView: {fileID: 13}
|
m_ActualView: {fileID: 13}
|
||||||
m_Panes:
|
m_Panes:
|
||||||
- {fileID: 13}
|
- {fileID: 13}
|
||||||
|
|
@ -226,7 +226,7 @@ MonoBehaviour:
|
||||||
m_MinSize: {x: 100, y: 200}
|
m_MinSize: {x: 100, y: 200}
|
||||||
m_MaxSize: {x: 8096, y: 16192}
|
m_MaxSize: {x: 8096, y: 16192}
|
||||||
vertical: 1
|
vertical: 1
|
||||||
controlID: 123
|
controlID: 65
|
||||||
--- !u!114 &10
|
--- !u!114 &10
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
|
|
@ -298,8 +298,8 @@ MonoBehaviour:
|
||||||
y: 0
|
y: 0
|
||||||
width: 374
|
width: 374
|
||||||
height: 767
|
height: 767
|
||||||
m_MinSize: {x: 276, y: 71}
|
m_MinSize: {x: 275, y: 50}
|
||||||
m_MaxSize: {x: 4001, y: 4021}
|
m_MaxSize: {x: 4000, y: 4000}
|
||||||
m_ActualView: {fileID: 21}
|
m_ActualView: {fileID: 21}
|
||||||
m_Panes:
|
m_Panes:
|
||||||
- {fileID: 21}
|
- {fileID: 21}
|
||||||
|
|
@ -765,6 +765,7 @@ MonoBehaviour:
|
||||||
- {fileID: -6854107038944686753, guid: 9941e73f825ec92499165b0615533f68, type: 2}
|
- {fileID: -6854107038944686753, guid: 9941e73f825ec92499165b0615533f68, type: 2}
|
||||||
- {fileID: 1766154229804822364, guid: a4e29ec1b853f234c8ce7b88b5a3ea39, type: 2}
|
- {fileID: 1766154229804822364, guid: a4e29ec1b853f234c8ce7b88b5a3ea39, type: 2}
|
||||||
- {fileID: 1191776569487272199, guid: b022e0107310a0745a6942b46cdb72c6, type: 2}
|
- {fileID: 1191776569487272199, guid: b022e0107310a0745a6942b46cdb72c6, type: 2}
|
||||||
|
- {fileID: 1191776569487272199, guid: dae0a2438d6ef974d921647304d32b50, type: 2}
|
||||||
m_ValueSerializationHelper:
|
m_ValueSerializationHelper:
|
||||||
- e00: 1
|
- e00: 1
|
||||||
e01: 0
|
e01: 0
|
||||||
|
|
@ -862,10 +863,26 @@ MonoBehaviour:
|
||||||
e31: 0
|
e31: 0
|
||||||
e32: 0
|
e32: 0
|
||||||
e33: 1
|
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_PreviewAnimator: {fileID: 0}
|
||||||
m_AnimatorController: {fileID: 9100000, guid: b022e0107310a0745a6942b46cdb72c6, type: 2}
|
m_AnimatorController: {fileID: 9100000, guid: dae0a2438d6ef974d921647304d32b50, type: 2}
|
||||||
m_BreadCrumbs:
|
m_BreadCrumbs:
|
||||||
- m_Target: {fileID: 1191776569487272199, guid: b022e0107310a0745a6942b46cdb72c6, type: 2}
|
- m_Target: {fileID: 1191776569487272199, guid: dae0a2438d6ef974d921647304d32b50, type: 2}
|
||||||
m_ScrollPosition: {x: 0, y: 0}
|
m_ScrollPosition: {x: 0, y: 0}
|
||||||
stateMachineGraph: {fileID: 0}
|
stateMachineGraph: {fileID: 0}
|
||||||
stateMachineGraphGUI: {fileID: 0}
|
stateMachineGraphGUI: {fileID: 0}
|
||||||
|
|
@ -938,7 +955,7 @@ MonoBehaviour:
|
||||||
m_OverlaysVisible: 1
|
m_OverlaysVisible: 1
|
||||||
m_LockTracker:
|
m_LockTracker:
|
||||||
m_IsLocked: 0
|
m_IsLocked: 0
|
||||||
m_LastSelectedObjectID: 30066
|
m_LastSelectedObjectID: -2904
|
||||||
--- !u!114 &18
|
--- !u!114 &18
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
|
|
@ -1001,9 +1018,9 @@ MonoBehaviour:
|
||||||
m_SceneHierarchy:
|
m_SceneHierarchy:
|
||||||
m_TreeViewState:
|
m_TreeViewState:
|
||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs:
|
m_SelectedIDs: b65e0000
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 0
|
||||||
m_ExpandedIDs:
|
m_ExpandedIDs: dcfaffff
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|
@ -1067,23 +1084,23 @@ MonoBehaviour:
|
||||||
m_SkipHidden: 0
|
m_SkipHidden: 0
|
||||||
m_SearchArea: 1
|
m_SearchArea: 1
|
||||||
m_Folders:
|
m_Folders:
|
||||||
- Assets/game/player
|
- Assets/game/Scripts/Save
|
||||||
m_Globs: []
|
m_Globs: []
|
||||||
m_OriginalText:
|
m_OriginalText:
|
||||||
m_FilterByTypeIntersection: 0
|
m_FilterByTypeIntersection: 0
|
||||||
m_ViewMode: 1
|
m_ViewMode: 1
|
||||||
m_StartGridSize: 64
|
m_StartGridSize: 64
|
||||||
m_LastFolders:
|
m_LastFolders:
|
||||||
- Assets/game/player
|
- Assets/game/Scripts/Save
|
||||||
m_LastFoldersGridSize: 64
|
m_LastFoldersGridSize: 64
|
||||||
m_LastProjectPath: C:\Users\Marc Tismonar\unity\SynthMaze
|
m_LastProjectPath: C:\Users\Marc Tismonar\unity\SynthMaze
|
||||||
m_LockTracker:
|
m_LockTracker:
|
||||||
m_IsLocked: 0
|
m_IsLocked: 0
|
||||||
m_FolderTreeState:
|
m_FolderTreeState:
|
||||||
scrollPos: {x: 0, y: 223}
|
scrollPos: {x: 0, y: 159}
|
||||||
m_SelectedIDs: 187d0000
|
m_SelectedIDs: b2800000
|
||||||
m_LastClickedID: 32024
|
m_LastClickedID: 32946
|
||||||
m_ExpandedIDs: 00000000b67c0000c87c000000ca9a3bffffff7f
|
m_ExpandedIDs: 00000000e27c0000f47c0000467d0000487d0000647d000000ca9a3bffffff7f
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|
@ -1111,7 +1128,7 @@ MonoBehaviour:
|
||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs:
|
m_SelectedIDs:
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 0
|
||||||
m_ExpandedIDs: 00000000b67c0000
|
m_ExpandedIDs: 00000000e27c0000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
|
|
@ -1138,7 +1155,7 @@ MonoBehaviour:
|
||||||
m_ListAreaState:
|
m_ListAreaState:
|
||||||
m_SelectedInstanceIDs:
|
m_SelectedInstanceIDs:
|
||||||
m_LastClickedInstanceID: 0
|
m_LastClickedInstanceID: 0
|
||||||
m_HadKeyboardFocusLastEvent: 0
|
m_HadKeyboardFocusLastEvent: 1
|
||||||
m_ExpandedInstanceIDs: 92db0000
|
m_ExpandedInstanceIDs: 92db0000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue