From e5b82b853584f1082ac731195104425aa66dfa20 Mon Sep 17 00:00:00 2001 From: Yami An Date: Tue, 24 Oct 2023 23:32:16 +0700 Subject: [PATCH] mouse input --- Assets/Prefab/CardPrefab.prefab | 76 ++- Assets/Scenes/SampleScene.unity | 952 ++++++++++++++++++++++++++++++- Assets/Script/ManagerCard.cs | 94 ++- Assets/Script/MouseInput.cs | 43 ++ Assets/Script/MouseInput.cs.meta | 11 + ProjectSettings/TagManager.asset | 6 +- 6 files changed, 1146 insertions(+), 36 deletions(-) create mode 100644 Assets/Script/MouseInput.cs create mode 100644 Assets/Script/MouseInput.cs.meta diff --git a/Assets/Prefab/CardPrefab.prefab b/Assets/Prefab/CardPrefab.prefab index f003ce1..7d06189 100644 --- a/Assets/Prefab/CardPrefab.prefab +++ b/Assets/Prefab/CardPrefab.prefab @@ -12,9 +12,11 @@ GameObject: - component: {fileID: 8883740995629890595} - component: {fileID: -3470920445453802428} - component: {fileID: 3916618843119500897} + - component: {fileID: 763119680318175421} + - component: {fileID: -5547126929902757163} m_Layer: 0 m_Name: CardPrefab - m_TagString: Untagged + m_TagString: Card m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -113,3 +115,75 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: FaceUp: 1 +--- !u!50 &763119680318175421 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8949091621847208831} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &-5547126929902757163 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8949091621847208831} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 5, y: 7.26} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 5, y: 7.26} + m_EdgeRadius: 0 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index b2ad053..2785c49 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -133,9 +133,11 @@ GameObject: m_Component: - component: {fileID: 34188332} - component: {fileID: 34188333} + - component: {fileID: 34188335} + - component: {fileID: 34188334} m_Layer: 0 m_Name: PosBot7 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -149,7 +151,7 @@ Transform: m_GameObject: {fileID: 34188331} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 7.5, y: 0, z: 0} + m_LocalPosition: {x: 15, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -207,6 +209,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &34188334 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34188331} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &34188335 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 34188331} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &230371216 GameObject: m_ObjectHideFlags: 0 @@ -217,9 +291,11 @@ GameObject: m_Component: - component: {fileID: 230371218} - component: {fileID: 230371217} + - component: {fileID: 230371220} + - component: {fileID: 230371219} m_Layer: 0 m_Name: PosTop1 - m_TagString: Untagged + m_TagString: PosTop m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -291,6 +367,78 @@ Transform: m_Children: [] m_Father: {fileID: 1034617219} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!61 &230371219 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 230371216} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &230371220 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 230371216} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &454662471 GameObject: m_ObjectHideFlags: 0 @@ -301,9 +449,11 @@ GameObject: m_Component: - component: {fileID: 454662472} - component: {fileID: 454662473} + - component: {fileID: 454662475} + - component: {fileID: 454662474} m_Layer: 0 m_Name: PosTop4 - m_TagString: Untagged + m_TagString: PosTop m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -375,6 +525,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &454662474 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 454662471} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &454662475 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 454662471} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &600562791 GameObject: m_ObjectHideFlags: 0 @@ -385,9 +607,11 @@ GameObject: m_Component: - component: {fileID: 600562792} - component: {fileID: 600562793} + - component: {fileID: 600562795} + - component: {fileID: 600562794} m_Layer: 0 m_Name: PosBot6 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -401,7 +625,7 @@ Transform: m_GameObject: {fileID: 600562791} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 5, y: 0, z: 0} + m_LocalPosition: {x: 12.5, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -459,6 +683,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &600562794 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 600562791} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &600562795 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 600562791} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &620967027 GameObject: m_ObjectHideFlags: 0 @@ -484,7 +780,7 @@ Transform: m_GameObject: {fileID: 620967027} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -1.5, z: 0} + m_LocalPosition: {x: -7.5, y: -1.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -693,9 +989,11 @@ GameObject: m_Component: - component: {fileID: 975406506} - component: {fileID: 975406507} + - component: {fileID: 975406509} + - component: {fileID: 975406508} m_Layer: 0 m_Name: PosBot3 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -709,7 +1007,7 @@ Transform: m_GameObject: {fileID: 975406505} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -2.5, y: 0, z: 0} + m_LocalPosition: {x: 5, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -767,6 +1065,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &975406508 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 975406505} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &975406509 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 975406505} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1034617218 GameObject: m_ObjectHideFlags: 0 @@ -812,9 +1182,11 @@ GameObject: m_Component: - component: {fileID: 1035028801} - component: {fileID: 1035028802} + - component: {fileID: 1035028804} + - component: {fileID: 1035028803} m_Layer: 0 m_Name: PosTop3 - m_TagString: Untagged + m_TagString: PosTop m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -886,6 +1258,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1035028803 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1035028800} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1035028804 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1035028800} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1198939758 GameObject: m_ObjectHideFlags: 0 @@ -896,9 +1340,11 @@ GameObject: m_Component: - component: {fileID: 1198939759} - component: {fileID: 1198939760} + - component: {fileID: 1198939762} + - component: {fileID: 1198939761} m_Layer: 0 m_Name: PosBot2 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -912,7 +1358,7 @@ Transform: m_GameObject: {fileID: 1198939758} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -5, y: 0, z: 0} + m_LocalPosition: {x: 2.5, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -970,6 +1416,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1198939761 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1198939758} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1198939762 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1198939758} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1212278198 GameObject: m_ObjectHideFlags: 0 @@ -980,9 +1498,11 @@ GameObject: m_Component: - component: {fileID: 1212278199} - component: {fileID: 1212278200} + - component: {fileID: 1212278202} + - component: {fileID: 1212278201} m_Layer: 0 m_Name: PosTop2 - m_TagString: Untagged + m_TagString: PosTop m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1054,6 +1574,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1212278201 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1212278198} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1212278202 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1212278198} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1226310186 GameObject: m_ObjectHideFlags: 0 @@ -1064,9 +1656,11 @@ GameObject: m_Component: - component: {fileID: 1226310187} - component: {fileID: 1226310188} + - component: {fileID: 1226310190} + - component: {fileID: 1226310189} m_Layer: 0 m_Name: PosBot5 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1080,7 +1674,7 @@ Transform: m_GameObject: {fileID: 1226310186} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 2.5, y: 0, z: 0} + m_LocalPosition: {x: 10, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1138,6 +1732,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1226310189 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1226310186} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1226310190 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1226310186} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1324752376 GameObject: m_ObjectHideFlags: 0 @@ -1148,9 +1814,11 @@ GameObject: m_Component: - component: {fileID: 1324752377} - component: {fileID: 1324752378} + - component: {fileID: 1324752380} + - component: {fileID: 1324752379} m_Layer: 0 m_Name: PosBot1 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1164,7 +1832,7 @@ Transform: m_GameObject: {fileID: 1324752376} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -7.5, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1222,6 +1890,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1324752379 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1324752376} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1324752380 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1324752376} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &1618202103 GameObject: m_ObjectHideFlags: 0 @@ -1232,6 +1972,7 @@ GameObject: m_Component: - component: {fileID: 1618202105} - component: {fileID: 1618202104} + - component: {fileID: 1618202108} m_Layer: 0 m_Name: __ManagerScript__ m_TagString: Untagged @@ -1251,7 +1992,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5ad4bb91b1709e9498cd0eb2d5bf75a6, type: 3} m_Name: m_EditorClassIdentifier: - CardPrefab: {fileID: 8949091621847208831, guid: e47e610d005bb014f978fe27600fb47f, type: 3} PosTops: - {fileID: 230371216} - {fileID: 1212278198} @@ -1318,7 +2058,11 @@ MonoBehaviour: - {fileID: 21300000, guid: a196b3727a318cd40a33fdffdcab4684, type: 3} - {fileID: 21300000, guid: c3c730b1616a25f4db823c33bc7481ff, type: 3} - {fileID: 21300000, guid: dec6ce0b4d3e4534c966419cf09c8bd8, type: 3} + CardPrefab: {fileID: 8949091621847208831, guid: e47e610d005bb014f978fe27600fb47f, type: 3} + DeckButton: {fileID: 2065622092} + TripsOnDisplay: [] DeckCard: [] + DisCardPile: [] --- !u!4 &1618202105 Transform: m_ObjectHideFlags: 0 @@ -1334,6 +2078,18 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1618202108 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1618202103} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1ec7c6587489d4441b9a5f9b57ca0bc6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1943609418 GameObject: m_ObjectHideFlags: 0 @@ -1359,7 +2115,7 @@ Transform: m_GameObject: {fileID: 1943609418} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 3.5, z: 0} + m_LocalPosition: {x: -7.5, y: 3.5, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -1376,9 +2132,11 @@ GameObject: m_Component: - component: {fileID: 1963198423} - component: {fileID: 1963198424} + - component: {fileID: 1963198426} + - component: {fileID: 1963198425} m_Layer: 0 m_Name: PosBot4 - m_TagString: Untagged + m_TagString: PosBot m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1392,7 +2150,7 @@ Transform: m_GameObject: {fileID: 1963198422} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 7.5, y: 0, z: 0} m_LocalScale: {x: 0.4, y: 0.4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1450,6 +2208,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!61 &1963198425 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1963198422} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 +--- !u!50 &1963198426 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1963198422} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 --- !u!1 &2065622092 GameObject: m_ObjectHideFlags: 0 @@ -1460,9 +2290,11 @@ GameObject: m_Component: - component: {fileID: 2065622093} - component: {fileID: 2065622094} + - component: {fileID: 2065622096} + - component: {fileID: 2065622095} m_Layer: 0 - m_Name: PosCard - m_TagString: Untagged + m_Name: DeckCard + m_TagString: Deck m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -1476,7 +2308,7 @@ Transform: m_GameObject: {fileID: 2065622092} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -7.5, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.39999998, y: 0.39999998, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1534,6 +2366,78 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!50 &2065622095 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2065622092} + 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_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 0 +--- !u!61 &2065622096 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2065622092} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_ForceSendLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ForceReceiveLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_ContactCaptureLayers: + serializedVersion: 2 + m_Bits: 4294967295 + m_CallbackLayers: + serializedVersion: 2 + m_Bits: 4294967295 + 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: 4.07, y: 6.8} + newSize: {x: 4.07, y: 6.8} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 4.07, y: 6.8} + m_EdgeRadius: 0 --- !u!1001 &7300258972767921120 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Script/ManagerCard.cs b/Assets/Script/ManagerCard.cs index 0faf54e..f069119 100644 --- a/Assets/Script/ManagerCard.cs +++ b/Assets/Script/ManagerCard.cs @@ -3,13 +3,15 @@ using System.Linq; using UnityEngine; using static UnityEngine.Quaternion; +using static System.Linq.Enumerable; public sealed class ManagerCard : MonoBehaviour { - public GameObject CardPrefab; public GameObject[] PosTops; public GameObject[] PosBots; public Sprite[] FaceCard; + public GameObject CardPrefab; + public GameObject DeckButton; public static string[] SetCard = new string[] { @@ -36,16 +38,22 @@ public sealed class ManagerCard : MonoBehaviour "K" }; + public List> DeckTrips = new(); + public List TripsOnDisplay = new(); public List DeckCard = new(); + public List DisCardPile = new(); public List[] Tops; public List[] Bots; - private List _bot0 = new(); - private List _bot1 = new(); - private List _bot2 = new(); - private List _bot3 = new(); - private List _bot4 = new(); - private List _bot5 = new(); - private List _bot6 = new(); + private readonly List _bot0 = new(); + private readonly List _bot1 = new(); + private readonly List _bot2 = new(); + private readonly List _bot3 = new(); + private readonly List _bot4 = new(); + private readonly List _bot5 = new(); + private readonly List _bot6 = new(); + private int _trips; + private int _tripsRemainder; + private int _deckLocation; private void Start() { @@ -71,9 +79,9 @@ public void DealCard() { DeckCard = GenerateDeckCard(); ShuffleCard(DeckCard); - DeckCard.ForEach(x => print(x)); SolitaireSort(); _ = StartCoroutine(CreateDeckCard()); + SortDeckIntoTrips(); } public void ShuffleCard(List list) @@ -92,6 +100,33 @@ public void ShuffleCard(List list) } } + public static List GenerateDeckCard() => SetCard.SelectMany(x => Values.Select(y => x + y)).ToList(); + + public void DealFromDeck() + { + if (_deckLocation < _trips) + { + TripsOnDisplay.Clear(); + + var xPos = 2.5f; + var zPos = 0.2f; + + DeckTrips[_deckLocation].ForEach(x => + { + var newTopCard = Instantiate(CardPrefab, new Vector3(DeckButton.transform.position.x + xPos, DeckButton.transform.position.y, DeckButton.transform.position.z + zPos), identity, DeckButton.transform); + + xPos += 0.5f; + newTopCard.name = x; + TripsOnDisplay.Add(x); + newTopCard.GetComponent().FaceUp = true; + }); + } + else + { + RestacktopDeck(); + } + } + private IEnumerator CreateDeckCard() { for (var i = 0; i < 7; i++) @@ -130,5 +165,44 @@ private void SolitaireSort() } } - public static List GenerateDeckCard() => SetCard.SelectMany(x => Values.Select(y => x + y)).ToList(); + private void SortDeckIntoTrips() + { + _trips = DeckCard.Count / 3; + _tripsRemainder = DeckCard.Count % 3; + DeckTrips.Clear(); + + var index = 0; + + for (var i = 0; i < _trips; i++) + { + DeckTrips.Add(Range(0, 3).Select(x => DeckCard[x + index]).ToList()); + index += 3; + } + + if (_tripsRemainder is not 0) + { + var myRemainders = new List(); + + index = 0; + + for (var i = 0; i < _tripsRemainder; i++) + { + myRemainders.Add(DeckCard[DeckCard.Count - _tripsRemainder + index]); + index++; + } + + DeckTrips.Add(myRemainders); + _trips++; + } + + _deckLocation = 0; + } + + private void RestacktopDeck() + { + DeckCard.Clear(); + DisCardPile.ForEach(x => DeckCard.Add(x)); + DisCardPile.Clear(); + SortDeckIntoTrips(); + } } diff --git a/Assets/Script/MouseInput.cs b/Assets/Script/MouseInput.cs new file mode 100644 index 0000000..5fddeed --- /dev/null +++ b/Assets/Script/MouseInput.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using static UnityEngine.Camera; +using static UnityEngine.Input; +using static UnityEngine.Physics2D; +using static UnityEngine.Vector2; + +public sealed class MouseInput : MonoBehaviour +{ + private ManagerCard _managerCard; + + private void Start() => _managerCard = FindObjectOfType(); + + private void Update() => GetMouseClick(); + + private void GetMouseClick() + { + if (GetMouseButtonDown(0)) + { + var hit = Raycast(main.ScreenToWorldPoint(new Vector3(mousePosition.x, mousePosition.y, 10f)), zero); + + if (hit) + { + if (hit.collider.CompareTag("Deck")) + { + print($"Deck: {hit.collider.name}"); + _managerCard.DealFromDeck(); + } + else if (hit.collider.CompareTag("Card")) + { + print($"Card: {hit.collider.name}"); + } + else if (hit.collider.CompareTag("PosTop")) + { + print($"PosTop: {hit.collider.name}"); + } + else if (hit.collider.CompareTag("PosBot")) + { + print($"PosBot: {hit.collider.name}"); + } + } + } + } +} diff --git a/Assets/Script/MouseInput.cs.meta b/Assets/Script/MouseInput.cs.meta new file mode 100644 index 0000000..5782eb8 --- /dev/null +++ b/Assets/Script/MouseInput.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ec7c6587489d4441b9a5f9b57ca0bc6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 1c92a78..b84c2c4 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -3,7 +3,11 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: [] + tags: + - Deck + - Card + - PosTop + - PosBot layers: - Default - TransparentFX