From 111bb5e27e405cb513b3755d7e156355b177d49b Mon Sep 17 00:00:00 2001 From: Giovani Date: Fri, 31 Jan 2020 23:03:38 -0500 Subject: [PATCH] in progress bug movement --- Assets/BugMovement.cs | 54 +- Assets/Prefabs/Bug.prefab | 147 ++++ Assets/Prefabs/Bug.prefab.meta | 7 + Assets/Scenes/LevelOne.unity | 688 +++--------------- Assets/Scripts/LayerNames.cs | 8 + Assets/Scripts/LayerNames.cs.meta | 11 + Assets/Scripts/Player.cs | 12 +- Assets/Sprites/{Bug - Level 1.png => Bug.png} | Bin .../{Bug - Level 1.png.meta => Bug.png.meta} | 0 Assets/Sprites/Collectibles.meta | 8 + Assets/Sprites/Collectibles/pizza.png | Bin 0 -> 436 bytes Assets/Sprites/Collectibles/pizza.png.meta | 91 +++ Assets/Sprites/Player.meta | 8 + Assets/Sprites/Player/hero.png | Bin 0 -> 731 bytes Assets/Sprites/Player/hero.png.meta | 91 +++ ProjectSettings/TagManager.asset | 4 +- 16 files changed, 530 insertions(+), 599 deletions(-) create mode 100644 Assets/Prefabs/Bug.prefab create mode 100644 Assets/Prefabs/Bug.prefab.meta create mode 100644 Assets/Scripts/LayerNames.cs create mode 100644 Assets/Scripts/LayerNames.cs.meta rename Assets/Sprites/{Bug - Level 1.png => Bug.png} (100%) rename Assets/Sprites/{Bug - Level 1.png.meta => Bug.png.meta} (100%) create mode 100644 Assets/Sprites/Collectibles.meta create mode 100644 Assets/Sprites/Collectibles/pizza.png create mode 100644 Assets/Sprites/Collectibles/pizza.png.meta create mode 100644 Assets/Sprites/Player.meta create mode 100644 Assets/Sprites/Player/hero.png create mode 100644 Assets/Sprites/Player/hero.png.meta diff --git a/Assets/BugMovement.cs b/Assets/BugMovement.cs index ec77e93..91dbd42 100644 --- a/Assets/BugMovement.cs +++ b/Assets/BugMovement.cs @@ -4,22 +4,56 @@ using UnityEngine; public class BugMovement : MonoBehaviour { - public LayerMask layerMask; - public float speed; - private bool movingRight = true; - Rigidbody2D bugBody; - private Transform groundDetection; + [SerializeField] private int secondsGoingLeft = 1; + [SerializeField] private int secondsGoingRight = 1; + [SerializeField] private float movementSpeed = 10; - - // Update is called once per frame - void Update() + private int leftAccumalator = 0; + private int rightAccumalator = 0; + private Rigidbody2D rigidBody; + + private int framesPerSecond => 60; + + private void Start() { - transform.Translate(Vector2.right * speed * Time.deltaTime); + // Physics2D.IgnoreLayerCollision(LayerMask.GetMask()) + + rigidBody = GetComponent(); } - void FixedUpdate() + // Update is called once per frame + private void Update() { + var totalFramesGoingLeft = framesPerSecond * secondsGoingLeft; + var totalFramesGoingRight = framesPerSecond * secondsGoingRight; + if (leftAccumalator <= totalFramesGoingLeft) + { + MoveLeft(); + leftAccumalator++; + if (leftAccumalator == totalFramesGoingLeft) + rightAccumalator = 0; + } + else if (rightAccumalator <= totalFramesGoingRight) + { + MoveRight(); + rightAccumalator++; + + if (rightAccumalator == totalFramesGoingRight) + leftAccumalator = 0; + } + } + + private void MoveLeft() + { + var actualSpeed = movementSpeed * -1; + rigidBody.velocity += new Vector2(actualSpeed, 0); + } + + private void MoveRight() + { + var actualSpeed = movementSpeed; + rigidBody.velocity += new Vector2(actualSpeed, 0); } } diff --git a/Assets/Prefabs/Bug.prefab b/Assets/Prefabs/Bug.prefab new file mode 100644 index 0000000..f12375c --- /dev/null +++ b/Assets/Prefabs/Bug.prefab @@ -0,0 +1,147 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3827363133515929333 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3827363133515929330} + - component: {fileID: 3827363133515929329} + - component: {fileID: 3827363133515929328} + - component: {fileID: 3827363133515929335} + - component: {fileID: 3827363133515929334} + m_Layer: 9 + m_Name: Bug + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3827363133515929330 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3827363133515929333} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 5.78, y: -1.81, z: 0} + m_LocalScale: {x: 2.236, y: 2.236, z: 2.236} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &3827363133515929329 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3827363133515929333} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 96053fa04d918a448a0636f9fec1c373, type: 3} + m_Color: {r: 1, g: 0, b: 0, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!61 &3827363133515929328 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3827363133515929333} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1, y: 1} + newSize: {x: 1, y: 1} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!114 &3827363133515929335 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3827363133515929333} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e5f777aa09d2ced42baa1cc6bf9dbe54, type: 3} + m_Name: + m_EditorClassIdentifier: + secondsLeft: 1 + secondsRight: 1 + movementSpeed: 1 +--- !u!50 &3827363133515929334 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3827363133515929333} + m_BodyType: 0 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 0 + m_CollisionDetection: 1 + m_Constraints: 0 diff --git a/Assets/Prefabs/Bug.prefab.meta b/Assets/Prefabs/Bug.prefab.meta new file mode 100644 index 0000000..0937861 --- /dev/null +++ b/Assets/Prefabs/Bug.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/LevelOne.unity b/Assets/Scenes/LevelOne.unity index bcd5e3a..d4a2fd9 100644 --- a/Assets/Scenes/LevelOne.unity +++ b/Assets/Scenes/LevelOne.unity @@ -165,152 +165,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1247097593 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1247097598} - - component: {fileID: 1247097597} - - component: {fileID: 1247097596} - - component: {fileID: 1247097595} - - component: {fileID: 1247097594} - m_Layer: 0 - m_Name: Bug - Level 1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!50 &1247097594 -Rigidbody2D: - serializedVersion: 4 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247097593} - m_BodyType: 0 - m_Simulated: 1 - m_UseFullKinematicContacts: 0 - m_UseAutoMass: 0 - m_Mass: 1 - m_LinearDrag: 0 - m_AngularDrag: 0.05 - m_GravityScale: 1 - m_Material: {fileID: 0} - m_Interpolate: 0 - m_SleepingMode: 0 - m_CollisionDetection: 1 - m_Constraints: 0 ---- !u!114 &1247097595 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247097593} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: e5f777aa09d2ced42baa1cc6bf9dbe54, type: 3} - m_Name: - m_EditorClassIdentifier: - layerMask: - serializedVersion: 2 - m_Bits: 0 - speed: 5 ---- !u!61 &1247097596 -BoxCollider2D: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247097593} - m_Enabled: 1 - m_Density: 1 - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_UsedByEffector: 0 - m_UsedByComposite: 0 - m_Offset: {x: 0, y: 0} - m_SpriteTilingProperty: - border: {x: 0, y: 0, z: 0, w: 0} - pivot: {x: 0.5, y: 0.5} - oldSize: {x: 1, y: 1} - newSize: {x: 1, y: 1} - adaptiveTilingThreshold: 0.5 - drawMode: 0 - adaptiveTiling: 0 - m_AutoTiling: 0 - serializedVersion: 2 - m_Size: {x: 1, y: 1} - m_EdgeRadius: 0 ---- !u!212 &1247097597 -SpriteRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247097593} - m_Enabled: 1 - m_CastShadows: 0 - m_ReceiveShadows: 0 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 0 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Sprite: {fileID: 21300000, guid: 96053fa04d918a448a0636f9fec1c373, type: 3} - m_Color: {r: 1, g: 0, b: 0, a: 1} - m_FlipX: 0 - m_FlipY: 0 - m_DrawMode: 0 - m_Size: {x: 1, y: 1} - m_AdaptiveModeThreshold: 0.5 - m_SpriteTileMode: 0 - m_WasSpriteAssigned: 1 - m_MaskInteraction: 0 - m_SpriteSortPoint: 0 ---- !u!4 &1247097598 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1247097593} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 5.78, y: -1.81, z: 0} - m_LocalScale: {x: 2.236, y: 2.236, z: 2.236} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1146013786 stripped GameObject: m_CorrespondingSourceObject: {fileID: 5711328081315814053, guid: fe8fb0c1c30f84b43885e84de26e0f11, @@ -430,7 +284,7 @@ GameObject: - component: {fileID: 1671840918} - component: {fileID: 1671840921} - component: {fileID: 1671840922} - m_Layer: 0 + m_Layer: 10 m_Name: Player m_TagString: Untagged m_Icon: {fileID: 0} @@ -565,7 +419,6 @@ MonoBehaviour: runSpeed: 16 jumpSpeed: 20 runFasterFactor: 1.5 - ground: {fileID: 2120494076} --- !u!68 &1671840922 EdgeCollider2D: m_ObjectHideFlags: 0 @@ -800,79 +653,13 @@ CompositeCollider2D: - X: 100 Y: -29999900 - X: 100 - Y: -20000100 - - X: 9999900 - Y: -20000100 - - X: 9999900 - Y: -9999959 - - X: 9999959 - Y: -9999900 - - X: 20000041 - Y: -9999900 - - X: 20000100 - Y: -9999959 - - X: 20000100 - Y: -10000100 - - X: 30000041 - Y: -10000100 - - X: 30000100 - Y: -10000041 - - X: 30000100 - Y: -100 - - X: 40000041 - Y: -100 - - X: 40000100 - Y: -41 - - X: 40000100 - Y: 9999900 - - X: 150000041 - Y: 9999900 - - X: 150000100 - Y: 9999959 - - X: 150000100 - Y: 19999900 - - X: 190000041 - Y: 19999900 - - X: 190000100 - Y: 19999959 - - X: 190000100 - Y: 30000041 - - X: 190000041 - Y: 30000100 - - X: 139999959 - Y: 30000100 - - X: 139999900 - Y: 30000041 - - X: 139999900 - Y: 20000100 - - X: 29999959 - Y: 20000100 - - X: 29999900 - Y: 20000041 - - X: 29999900 - Y: 10000100 - - X: 19999959 - Y: 10000100 - - X: 19999900 - Y: 10000041 - - X: 19999900 - Y: 100 - - X: -41 - Y: 100 - - X: -100 - Y: 41 - - X: -100 - Y: -9999900 - - X: -10000041 - Y: -9999900 - - X: -10000100 - Y: -9999959 - - X: -10000100 - Y: -19999900 + Y: -30000041 + - X: 41 + Y: -30000100 - X: -20000041 - Y: -19999900 + Y: -30000100 - X: -20000100 - Y: -19999959 + Y: -30000041 - X: -20000100 Y: -30000000 - X: -160000000 @@ -887,76 +674,12 @@ CompositeCollider2D: Y: -40000100 - X: 300000041 Y: -40000100 - - - X: 269999900 - Y: 19999959 - - X: 269999900 - Y: 30000041 - - X: 269999959 - Y: 30000100 - - X: 239999959 - Y: 30000100 - - X: 239999900 - Y: 30000041 - - X: 239999900 - Y: 19999959 - - X: 239999959 - Y: 19999900 - - X: 269999959 - Y: 19999900 - - - X: 360000100 - Y: 19999959 - - X: 360000100 - Y: 30000041 - - X: 360000041 - Y: 30000100 - - X: 319999959 - Y: 30000100 - - X: 319999900 - Y: 30000041 - - X: 319999900 - Y: 19999959 - - X: 319999959 - Y: 19999900 - - X: 360000041 - Y: 19999900 m_CompositePaths: m_Paths: - - {x: 29.999975, y: -4.00001} - {x: 29.999975, y: -2.99999} - - {x: 0.00001, y: -2.9999607} - - {x: 0.0000394, y: -2.00001} - - {x: 0.99999, y: -1.9999808} - - {x: 1.0000253, y: -0.99999} - - {x: 3.00001, y: -0.9999748} - - {x: 3.0000393, y: -0.00001} - - {x: 4.00001, y: 0.0000252} - - {x: 4.000039, y: 0.99999} - - {x: 15.00001, y: 1.0000252} - - {x: 15.00004, y: 1.99999} - - {x: 19.00001, y: 2.0000253} - - {x: 18.999975, y: 3.00001} - - {x: 13.99999, y: 2.9999747} - - {x: 13.99996, y: 2.00001} - - {x: 2.99999, y: 1.9999748} - - {x: 2.9999607, y: 1.00001} - - {x: 1.99999, y: 0.9999748} - - {x: 1.9999607, y: 0.00001} - - {x: -0.00001, y: -0.0000252} - - {x: -0.0000394, y: -0.99999} - - {x: -1.00001, y: -1.0000252} - - {x: -1.0000395, y: -1.99999} - - {x: -2.00001, y: -2.0000253} - - {x: -2.0000393, y: -3} - {x: -16, y: -3.0000293} - {x: -15.999971, y: -4} - - - {x: 26.999968, y: 1.99999} - - {x: 26.999968, y: 3.00001} - - {x: 23.99999, y: 2.9999747} - - {x: 24.000027, y: 1.99999} - - - {x: 35.999973, y: 1.99999} - - {x: 35.999973, y: 3.00001} - - {x: 31.99999, y: 2.9999747} - - {x: 32.000027, y: 1.99999} m_VertexDistance: 0.0005 m_OffsetDistance: 0.00005 --- !u!50 &2120494079 @@ -1465,312 +1188,15 @@ Tilemap: m_ObjectToInstantiate: {fileID: 0} m_TileFlags: 1 m_ColliderType: 1 - - first: {x: -2, y: -3, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: -1, y: -3, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: -1, y: -2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 0, y: -2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 0, y: -1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 1, y: -1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 2, y: -1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 2, y: 0, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 3, y: 0, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 3, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 4, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 5, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 6, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 7, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 8, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 9, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 10, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 11, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 12, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 13, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 14, y: 1, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 14, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 15, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 16, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 17, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 18, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 24, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 25, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 26, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 32, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 33, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 34, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 - - first: {x: 35, y: 2, z: 0} - second: - m_TileIndex: 0 - m_TileSpriteIndex: 0 - m_TileMatrixIndex: 0 - m_TileColorIndex: 0 - m_ObjectToInstantiate: {fileID: 0} - m_TileFlags: 1 - m_ColliderType: 1 m_AnimatedTiles: {} m_TileAssetArray: - - m_RefCount: 79 + - m_RefCount: 46 m_Data: {fileID: 11400000, guid: 45e32cdeeb7c7994cbd282d9fd4279ec, type: 2} m_TileSpriteArray: - - m_RefCount: 79 + - m_RefCount: 46 m_Data: {fileID: 21300000, guid: 37077009adda5004cad02be3083a5bff, type: 3} m_TileMatrixArray: - - m_RefCount: 79 + - m_RefCount: 46 m_Data: e00: 1 e01: 0 @@ -1789,7 +1215,7 @@ Tilemap: e32: 0 e33: 1 m_TileColorArray: - - m_RefCount: 79 + - m_RefCount: 46 m_Data: {r: 1, g: 1, b: 1, a: 1} m_AnimationFrameRate: 1 m_Color: {r: 1, g: 1, b: 1, a: 1} @@ -1814,3 +1240,97 @@ Tilemap: e31: 0 e32: 0 e33: 1 +--- !u!1001 &3827363132279464972 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3827363133515929328, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_IsTrigger + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalPosition.x + value: 5.78 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalPosition.y + value: -1.81 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929330, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929333, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_Name + value: Bug + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929334, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: m_BodyType + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929335, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: movementSpeed + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929335, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: secondsGoingLeft + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 3827363133515929335, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, + type: 3} + propertyPath: secondsGoingRight + value: 2 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, type: 3} diff --git a/Assets/Scripts/LayerNames.cs b/Assets/Scripts/LayerNames.cs new file mode 100644 index 0000000..8383d19 --- /dev/null +++ b/Assets/Scripts/LayerNames.cs @@ -0,0 +1,8 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class LayerNames +{ + +} diff --git a/Assets/Scripts/LayerNames.cs.meta b/Assets/Scripts/LayerNames.cs.meta new file mode 100644 index 0000000..0902e1c --- /dev/null +++ b/Assets/Scripts/LayerNames.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f390aa3a3cda63143bdb8159cf98b63d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 29894a5..9b08306 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -7,9 +7,10 @@ public class Player : MonoBehaviour [SerializeField] private float runSpeed = 10f; [SerializeField] private float jumpSpeed = 10f; [SerializeField] private float runFasterFactor = 1.5f; - [SerializeField] GameObject ground; - Rigidbody2D rigidbody; + private Rigidbody2D rigidbody; + private string enemiesLayerName => "Enemies"; + private string groundLayerName => "Ground"; private void Start() { @@ -18,6 +19,7 @@ public class Player : MonoBehaviour private void Update() { + Debug.Log(HasEncounteredEnemy()); MovePlayer(); } @@ -29,7 +31,7 @@ public class Player : MonoBehaviour private void Jump() { - var playerOnGround = rigidbody.IsTouching(ground.GetComponent()); + var playerOnGround = rigidbody.IsTouchingLayers(LayerMask.GetMask(groundLayerName)); // Jump if (Input.GetKey(KeyCode.Space) && playerOnGround) @@ -59,6 +61,10 @@ public class Player : MonoBehaviour { rigidbody.velocity = new Vector2(actualRunSpeed * -1, rigidbody.velocity.y); } + } + private bool HasEncounteredEnemy() + { + return rigidbody.IsTouchingLayers(LayerMask.GetMask(enemiesLayerName)); } } diff --git a/Assets/Sprites/Bug - Level 1.png b/Assets/Sprites/Bug.png similarity index 100% rename from Assets/Sprites/Bug - Level 1.png rename to Assets/Sprites/Bug.png diff --git a/Assets/Sprites/Bug - Level 1.png.meta b/Assets/Sprites/Bug.png.meta similarity index 100% rename from Assets/Sprites/Bug - Level 1.png.meta rename to Assets/Sprites/Bug.png.meta diff --git a/Assets/Sprites/Collectibles.meta b/Assets/Sprites/Collectibles.meta new file mode 100644 index 0000000..eed7239 --- /dev/null +++ b/Assets/Sprites/Collectibles.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 14a48cea37764e24b9e2179e98e14bf9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Collectibles/pizza.png b/Assets/Sprites/Collectibles/pizza.png new file mode 100644 index 0000000000000000000000000000000000000000..ad833f4d986e3a49e099a58eac5616a015daa7cb GIT binary patch literal 436 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9>?NMQuIx{k7@6c{^_CWbv;HNnt4}V&3~!?w^3lW+WZfn<8S?A z*ka83hm)zmZn<;GzbY25+fpqpK{^Xp8Xdm0FhKFd29Xm1ZVpZ-!!Jx(;nLl-Bj^#c z%YRBuA5#&ZdKYZsK=Ep zqvB$?Qggy{84J;_c>Dg_i;t$xom+PB-ij`bU5i$%d%3nS+pOc#{z}H{`%~06g*{FL P1_XnrtDnm{r-UW|??0k( literal 0 HcmV?d00001 diff --git a/Assets/Sprites/Collectibles/pizza.png.meta b/Assets/Sprites/Collectibles/pizza.png.meta new file mode 100644 index 0000000..61d6151 --- /dev/null +++ b/Assets/Sprites/Collectibles/pizza.png.meta @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: e6c9043b5a052f544b71e5612261b1be +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Player.meta b/Assets/Sprites/Player.meta new file mode 100644 index 0000000..feee74b --- /dev/null +++ b/Assets/Sprites/Player.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1855e99be8bcc3c4787290701e9e894b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sprites/Player/hero.png b/Assets/Sprites/Player/hero.png new file mode 100644 index 0000000000000000000000000000000000000000..a8844685138fa11e12f8073ed0201ba757192e69 GIT binary patch literal 731 zcmV<10wn#3P)00007bV*G`2jl_) z0v|OS5ZU4Y000+sMObuGZ)S9NVRB^vM@&RePDdbiWpW@hE;Mn4q~QPn00?w&PDe*f zL^A*Y002sWDIWj;00d`2O+f$vv5yP=Ro*Vjj?v_(w|@n^d?vWy$O~;Z-Vy__%$D{%qQTu?a%jCIt!G({zTuRj=qZk zWy_Ar+DuM4B8$4;B!~zz1lE{<^s-d4K}Eb-h$cp`+-P1ajPr zeo%o6bSynm;AUXyAp-H~^H_3fvm62?xQ!;u(QT`jmq)d(S*AP#uAT zx`5xsP0gPWP);Ggg+hU2dNF=bz5J1kn&z(-Aig|t=F*!|kB2{%LJa-v3ZKcL1Oma~ zi$e#O3Ifc8BL@4nfTKb{c^2}Uiod&5faecAS#u1;1SpFnmUIX{%e(Q+(o*`m6yk8Q zPwof=_tbFL3s}pCZ>n7{djLaUDex+U8zq}SfE=O&L#_;wrE9-q0D;t6mM`8`qKkmx zdy2w>p>G$cbAZu91WfSzpDT1EJxX9p{V(&G*TAF01ddr~b0Ce#j0s1F3q+?;