From f6c075ce4668c34bb93978abaab62f337b84f4d1 Mon Sep 17 00:00:00 2001 From: abpo11 <syncbak123@gmail.com> Date: Thu, 14 Feb 2019 02:42:07 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B0=80=EC=8B=9C=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C.=20=EB=84=89=EB=B0=B1=20=EA=B1=B0=EB=A6=AC?= =?UTF-8?q?=EC=99=80=20=EB=8D=B0=EB=AF=B8=EC=A7=80=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5.=20ground=20layer=EC=97=90=20spike=20?= =?UTF-8?q?=EC=9E=84=EC=8B=9C=EB=A1=9C=20=EC=B6=94=EA=B0=80=ED=95=A8.=20?= =?UTF-8?q?=EB=AA=A8=EB=93=A0=20spike=EC=97=90=20=EC=BD=9C=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EB=8D=94=20=EC=B6=94=EA=B0=80=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefabs/Rooms/NormalRoom/Room 4.prefab | 56 +++++++++++++++++ Assets/Prefabs/TetrisMap/PlayerIcon.prefab | 2 +- Assets/Scenes/PlayScene.unity | 31 ++++++++++ Assets/Scripts/Characters/Enemy/Enemy.cs | 4 +- Assets/Scripts/playerOnSpike.cs | 62 +++++++++++++++++++ Assets/Scripts/playerOnSpike.cs.meta | 11 ++++ Assets/tiletest.cs | 16 +++++ Assets/tiletest.cs.meta | 11 ++++ 8 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 Assets/Scripts/playerOnSpike.cs create mode 100644 Assets/Scripts/playerOnSpike.cs.meta create mode 100644 Assets/tiletest.cs create mode 100644 Assets/tiletest.cs.meta diff --git a/Assets/Prefabs/Rooms/NormalRoom/Room 4.prefab b/Assets/Prefabs/Rooms/NormalRoom/Room 4.prefab index fc017e5..43f17d5 100644 --- a/Assets/Prefabs/Rooms/NormalRoom/Room 4.prefab +++ b/Assets/Prefabs/Rooms/NormalRoom/Room 4.prefab @@ -123,6 +123,9 @@ GameObject: - component: {fileID: 4202914257283556} - component: {fileID: 8195094281688291738} - component: {fileID: 3664157344750859314} + - component: {fileID: 2113883504719364560} + - component: {fileID: 50510369170615966} + - component: {fileID: 66891075305192572} m_Layer: 10 m_Name: spike m_TagString: Untagged @@ -341,6 +344,26 @@ Rigidbody2D: m_SleepingMode: 1 m_CollisionDetection: 0 m_Constraints: 0 +--- !u!50 &50510369170615966 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1687661689682920} + m_BodyType: 2 + 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: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!50 &50664629928502538 Rigidbody2D: serializedVersion: 4 @@ -849,6 +872,26 @@ CompositeCollider2D: - {x: 0, y: 0} - {x: 11, y: 0} m_VertexDistance: 0.0005 +--- !u!66 &66891075305192572 +CompositeCollider2D: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1687661689682920} + 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_GeometryType: 0 + m_GenerationType: 0 + m_EdgeRadius: 0 + m_ColliderPaths: [] + m_CompositePaths: + m_Paths: [] + m_VertexDistance: 0.0005 --- !u!114 &114127645492151898 MonoBehaviour: m_ObjectHideFlags: 1 @@ -953,6 +996,19 @@ TilemapCollider2D: m_UsedByEffector: 0 m_UsedByComposite: 1 m_Offset: {x: 0, y: 0} +--- !u!19719996 &2113883504719364560 +TilemapCollider2D: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1687661689682920} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 1 + m_Offset: {x: 0, y: 0} --- !u!19719996 &2113883505917435124 TilemapCollider2D: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/TetrisMap/PlayerIcon.prefab b/Assets/Prefabs/TetrisMap/PlayerIcon.prefab index e1b74b4..d559005 100644 --- a/Assets/Prefabs/TetrisMap/PlayerIcon.prefab +++ b/Assets/Prefabs/TetrisMap/PlayerIcon.prefab @@ -34,7 +34,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1704656476422024} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 192, y: 0, z: -2} + m_LocalPosition: {x: 72, y: 0, z: -2} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Scenes/PlayScene.unity b/Assets/Scenes/PlayScene.unity index 8fdde1c..6fe22a8 100644 --- a/Assets/Scenes/PlayScene.unity +++ b/Assets/Scenes/PlayScene.unity @@ -404,6 +404,27 @@ GameObject: m_CorrespondingSourceObject: {fileID: 1623439448163086, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2} m_PrefabInternal: {fileID: 1618052740} +--- !u!114 &489222434 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 489222433} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a4458b2b5e7c3f842b29e2121f8400ea, type: 3} + m_Name: + m_EditorClassIdentifier: + spikeTile: + - {fileID: 11400000, guid: 7f2c5cb43ad7207499b22fb5e0acd41a, type: 2} + - {fileID: 11400000, guid: f411e29431b787c4ab84b5ff59ca5e6e, type: 2} + - {fileID: 11400000, guid: 85440e0dd81e48840947ce485614bab6, type: 2} + - {fileID: 11400000, guid: 7dbb7c55a3417f54fbd38fafb369478e, type: 2} + rb: {fileID: 0} + SpikeLayer: 10 + spikeDamage: 5 + spikeKnockBackx: 10 + spikeKnockBacky: 10 --- !u!223 &647962947 stripped Canvas: m_CorrespondingSourceObject: {fileID: 223237664237935382, guid: 692aad2449e06054799ea4706578fb23, @@ -1541,6 +1562,11 @@ Prefab: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 114294925164316638, guid: 3d077a5f727dd1e4780e9265ed26e036, + type: 2} + propertyPath: groundLayer.m_Bits + value: 7424 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2} m_IsPrefabAsset: 0 @@ -1813,6 +1839,11 @@ Prefab: propertyPath: m_CullingMask.m_Bits value: 4294967295 objectReference: {fileID: 0} + - target: {fileID: 81874366432473632, guid: b67c2e6425443f14c85899a92710bf3f, + type: 2} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b67c2e6425443f14c85899a92710bf3f, type: 2} m_IsPrefabAsset: 0 diff --git a/Assets/Scripts/Characters/Enemy/Enemy.cs b/Assets/Scripts/Characters/Enemy/Enemy.cs index e70d0ac..e42dc32 100644 --- a/Assets/Scripts/Characters/Enemy/Enemy.cs +++ b/Assets/Scripts/Characters/Enemy/Enemy.cs @@ -67,12 +67,12 @@ public class Enemy : MonoBehaviour { bool wallTest = IsTouchingWall(); if (wallTest) { - Debug.Log("Touching wall"); + // Debug.Log("Touching wall"); } bool cliffTest = IsAdvancingToCliff(); if (cliffTest) { - Debug.Log("Advancing to cliff"); + // Debug.Log("Advancing to cliff"); } } diff --git a/Assets/Scripts/playerOnSpike.cs b/Assets/Scripts/playerOnSpike.cs new file mode 100644 index 0000000..672d630 --- /dev/null +++ b/Assets/Scripts/playerOnSpike.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Tilemaps; +public class playerOnSpike : MonoBehaviour { + public TileBase[] spikeTile; + public Rigidbody2D rb; + public int SpikeLayer = 10; //10 is for spike layer + public float spikeDamage = 5f; + public float spikeKnockBackx = 5f; + public float spikeKnockBacky = 5f; + + private void Start() + { + rb = GetComponent<Rigidbody2D>(); + } + + void OnCollisionEnter2D(Collision2D coll) + { + if (coll.gameObject.layer == SpikeLayer) + { + Tilemap t = coll.gameObject.GetComponent<Tilemap>(); + Vector3 hitPosition = Vector3.zero; + ContactPoint2D hit = coll.contacts[0]; + hitPosition.x = hit.point.x - 0.01f * hit.normal.x; + hitPosition.y = hit.point.y - 0.01f * hit.normal.y; + //ì¶©ëŒ ìœ„ì¹˜ 중심 계산 + + + TileBase colTile = t.GetTile(t.WorldToCell(hitPosition)); + + if (colTile != null) + { + EnemyAttackInfo attack = new EnemyAttackInfo(spikeDamage, 0f, 0, null, null); //ë„‰ë°±ì€ ë”°ë¡œ 구현 + GetComponent<PlayerAttack>().TakeDamage(attack); + + //ë°©í–¥ì— ë”°ë¥¸ 넉백 구현 + if (colTile == spikeTile[0]) //spike up tile + { + // print("uuch!"); + rb.velocity = new Vector2(rb.velocity.x, spikeKnockBacky); + } + else if (colTile == spikeTile[1]) //spike down tile + { + // print("duch!"); + rb.velocity = new Vector2(rb.velocity.x, -spikeKnockBacky); + } + if (colTile == spikeTile[2]) //spike l tile + { + // print("luch!"); + rb.velocity = new Vector2( -spikeKnockBackx, rb.velocity.y); + } + else if (colTile == spikeTile[3]) //spike r tile + { + // print("ruch!"); + rb.velocity = new Vector2( spikeKnockBackx, rb.velocity.y); + } + } + } + + } +} diff --git a/Assets/Scripts/playerOnSpike.cs.meta b/Assets/Scripts/playerOnSpike.cs.meta new file mode 100644 index 0000000..bb3dd4c --- /dev/null +++ b/Assets/Scripts/playerOnSpike.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4458b2b5e7c3f842b29e2121f8400ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/tiletest.cs b/Assets/tiletest.cs new file mode 100644 index 0000000..0d01142 --- /dev/null +++ b/Assets/tiletest.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class tiletest : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/Assets/tiletest.cs.meta b/Assets/tiletest.cs.meta new file mode 100644 index 0000000..8789bb2 --- /dev/null +++ b/Assets/tiletest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb17c0dc633a1ef4c8337e5ffa1ffdae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- 2.22.0