From 9bf2d00a47db526b46faaa6de61c3b68bfa6cb46 Mon Sep 17 00:00:00 2001 From: Samir LABANE <samir.labane@ensiie.fr> Date: Sat, 3 Aug 2019 17:39:15 +0200 Subject: [PATCH] merge --- Assets/GameObjects/CardPool.asset | 17 + Assets/GameObjects/CardPool.asset.meta | 8 + Assets/Scenes/Integration.unity | 1001 +++++++++++++++++ Assets/Scenes/Integration.unity.meta | 7 + Assets/Scripts/CardEvents.cs | 5 +- Assets/Scripts/Deck/CardPool.asset | 12 +- Assets/Scripts/Deck/CardPool.asset.meta | 2 +- Assets/Scripts/Deck/CardPool.cs | 6 +- Assets/Scripts/Deck/Deck.cs | 238 ++-- Assets/Scripts/Deck/Dump.cs | 18 +- Assets/Scripts/Deck/Hand.cs | 140 ++- Assets/Scripts/Deck/Init.cs | 107 -- Assets/Scripts/ScoreBar.cs | 2 +- Assets/Scripts/Ui.meta | 8 + Assets/Scripts/Ui/HandUi.cs | 39 + .../{Deck/Init.cs.meta => Ui/HandUi.cs.meta} | 2 +- ProjectSettings/ProjectVersion.txt | 4 +- 17 files changed, 1288 insertions(+), 328 deletions(-) create mode 100644 Assets/GameObjects/CardPool.asset create mode 100644 Assets/GameObjects/CardPool.asset.meta create mode 100644 Assets/Scenes/Integration.unity create mode 100644 Assets/Scenes/Integration.unity.meta delete mode 100644 Assets/Scripts/Deck/Init.cs create mode 100644 Assets/Scripts/Ui.meta create mode 100644 Assets/Scripts/Ui/HandUi.cs rename Assets/Scripts/{Deck/Init.cs.meta => Ui/HandUi.cs.meta} (83%) diff --git a/Assets/GameObjects/CardPool.asset b/Assets/GameObjects/CardPool.asset new file mode 100644 index 0000000..0bf780e --- /dev/null +++ b/Assets/GameObjects/CardPool.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: de6a9b8e3e2a5d9448896f3c4511ac29, type: 3} + m_Name: CardPool + m_EditorClassIdentifier: + Pool: + - {fileID: 697331425601601878, guid: 04c974020468ba94f9cb502255a15dd1, type: 3} + - {fileID: 4934257969187937544, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, type: 3} diff --git a/Assets/GameObjects/CardPool.asset.meta b/Assets/GameObjects/CardPool.asset.meta new file mode 100644 index 0000000..a3b65f2 --- /dev/null +++ b/Assets/GameObjects/CardPool.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4dc02c97ea10d0d4dac39a8351f10ce8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Integration.unity b/Assets/Scenes/Integration.unity new file mode 100644 index 0000000..21b393c --- /dev/null +++ b/Assets/Scenes/Integration.unity @@ -0,0 +1,1001 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!224 &66537583 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + m_PrefabInstance: {fileID: 1986122864} + m_PrefabAsset: {fileID: 0} +--- !u!114 &66537584 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 3072710562047330837, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + m_PrefabInstance: {fileID: 1986122864} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d999a67de7a16cb4593a3e7207e7a5ef, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &481556382 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 481556386} + - component: {fileID: 481556385} + - component: {fileID: 481556384} + - component: {fileID: 481556383} + - component: {fileID: 481556387} + m_Layer: 5 + m_Name: Board + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &481556383 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 481556382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &481556384 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 481556382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &481556385 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 481556382} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &481556386 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 481556382} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 577289746} + - {fileID: 66537583} + - {fileID: 872592475} + - {fileID: 1288275031} + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &481556387 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 481556382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d444f0a7cdb67004b91fb34506cf177f, type: 3} + m_Name: + m_EditorClassIdentifier: + mScoreBar: {fileID: 66537584} +--- !u!1 &577289745 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 577289746} + - component: {fileID: 577289747} + - component: {fileID: 577289748} + m_Layer: 5 + m_Name: Hand + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &577289746 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577289745} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 481556386} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 0, y: 100} + m_SizeDelta: {x: 800, y: 200} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &577289747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577289745} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bbd8004478a0bef4b8a90ff30bd8d431, type: 3} + m_Name: + m_EditorClassIdentifier: + deck: {fileID: 872592476} + MaxHandSize: 7 + StartHandSize: 2 + hand: [] +--- !u!114 &577289748 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 577289745} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a6fe9b3bd73304f44ac5053e5b2a9531, type: 3} + m_Name: + m_EditorClassIdentifier: + mRenderedHand: {fileID: 577289747} +--- !u!224 &621995769 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + m_PrefabInstance: {fileID: 837563319} + m_PrefabAsset: {fileID: 0} +--- !u!114 &621995772 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 697331425601601875, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + m_PrefabInstance: {fileID: 837563319} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40631ac390a9a3849a6d0c71d538ece8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &837563319 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 872592475} + m_Modifications: + - target: {fileID: 697331425601601878, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_Name + value: CardDebug + objectReference: {fileID: 0} + - target: {fileID: 697331425601601878, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -40 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_SizeDelta.x + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_SizeDelta.y + value: 80 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_Pivot.x + value: 0.49999997 + objectReference: {fileID: 0} + - target: {fileID: 697331425601601877, guid: 04c974020468ba94f9cb502255a15dd1, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 04c974020468ba94f9cb502255a15dd1, type: 3} +--- !u!1 &872592474 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 872592475} + - component: {fileID: 872592476} + m_Layer: 5 + m_Name: Deck + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &872592475 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 872592474} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 2057005749} + - {fileID: 621995769} + m_Father: {fileID: 481556386} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.49999994} +--- !u!114 &872592476 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 872592474} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c882b04e9b08e5444bb3474409d3551f, type: 3} + m_Name: + m_EditorClassIdentifier: + totalCards: + - {fileID: 2057005752} + - {fileID: 621995772} + initializer: {fileID: 481556387} +--- !u!1 &908658328 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 908658331} + - component: {fileID: 908658330} + - component: {fileID: 908658329} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &908658329 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 908658328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &908658330 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 908658328} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &908658331 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 908658328} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1288275030 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1288275031} + - component: {fileID: 1288275032} + m_Layer: 5 + m_Name: Dump + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1288275031 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1288275030} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 481556386} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1288275032 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1288275030} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db8123992f78b004a888a3ac87945fe3, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &1427303021 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1427303024} + - component: {fileID: 1427303023} + - component: {fileID: 1427303022} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1427303022 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427303021} + m_Enabled: 1 +--- !u!20 &1427303023 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427303021} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1427303024 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427303021} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1986122864 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 481556386} + m_Modifications: + - target: {fileID: 3072710562047330839, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_Name + value: ScoreBar + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 209 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_SizeDelta.x + value: 739.6 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_SizeDelta.y + value: 55 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710562047330836, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 3072710560370516180, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710560370516180, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710560679235849, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710560679235849, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3072710560679235849, guid: 4f4f0547ba7cb524d99380ce8b591908, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 4f4f0547ba7cb524d99380ce8b591908, type: 3} +--- !u!224 &2057005749 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + m_PrefabInstance: {fileID: 2098379732} + m_PrefabAsset: {fileID: 0} +--- !u!114 &2057005752 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 4934257969187937549, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + m_PrefabInstance: {fileID: 2098379732} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 40631ac390a9a3849a6d0c71d538ece8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &2098379732 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 872592475} + m_Modifications: + - target: {fileID: 4934257969187937544, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_Name + value: CardScoreEffect + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937544, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -40 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_SizeDelta.x + value: 60 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_SizeDelta.y + value: 80 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchorMax.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_Pivot.x + value: 0.49999997 + objectReference: {fileID: 0} + - target: {fileID: 4934257969187937547, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, type: 3} diff --git a/Assets/Scenes/Integration.unity.meta b/Assets/Scenes/Integration.unity.meta new file mode 100644 index 0000000..6fb7b2c --- /dev/null +++ b/Assets/Scenes/Integration.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0f47147edd74a92468ef5a13a6166609 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/CardEvents.cs b/Assets/Scripts/CardEvents.cs index ee545ed..690a0c2 100644 --- a/Assets/Scripts/CardEvents.cs +++ b/Assets/Scripts/CardEvents.cs @@ -4,7 +4,8 @@ using UnityEngine; public enum Event { - CARD_PLAYED + CARD_PLAYED, + CARD_DRAW } public class CardEvent<T> @@ -46,7 +47,7 @@ public class CardEvent<T> } public static void Trigger(Event eventToTrigger, T info) { - if (mHandler == null || mHandler.mEventHandlers[eventToTrigger] == null) + if (mHandler == null || !mHandler.mEventHandlers.ContainsKey(eventToTrigger)) { return; } diff --git a/Assets/Scripts/Deck/CardPool.asset b/Assets/Scripts/Deck/CardPool.asset index f372347..0bf780e 100644 --- a/Assets/Scripts/Deck/CardPool.asset +++ b/Assets/Scripts/Deck/CardPool.asset @@ -13,13 +13,5 @@ MonoBehaviour: m_Name: CardPool m_EditorClassIdentifier: Pool: - - 0 - - 1 - - 2 - - 3 - - 4 - - 5 - - 6 - - 7 - - 8 - - 9 + - {fileID: 697331425601601878, guid: 04c974020468ba94f9cb502255a15dd1, type: 3} + - {fileID: 4934257969187937544, guid: ca7d6d67dabc35c4cbfde5d6408b8c3b, type: 3} diff --git a/Assets/Scripts/Deck/CardPool.asset.meta b/Assets/Scripts/Deck/CardPool.asset.meta index a3b65f2..e5261e7 100644 --- a/Assets/Scripts/Deck/CardPool.asset.meta +++ b/Assets/Scripts/Deck/CardPool.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4dc02c97ea10d0d4dac39a8351f10ce8 +guid: 6f5eb12285d83a5458dfe2ebb1aebbbc NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Scripts/Deck/CardPool.cs b/Assets/Scripts/Deck/CardPool.cs index 4400c29..d74e910 100644 --- a/Assets/Scripts/Deck/CardPool.cs +++ b/Assets/Scripts/Deck/CardPool.cs @@ -7,16 +7,16 @@ public class CardPool : ScriptableObject { //TODO replace string with card class - public string[] Pool; + public GameObject[] Pool; - public string[] Draft(int i) + public GameObject[] Draft(int i) { if(i > Pool.Length) { Debug.LogError("draft size bigger than card pool"); return null; } - string[] result = new string[i]; + GameObject[] result = new GameObject[i]; List<int> indexChosen = new List<int>(); int nbChosen = 0; diff --git a/Assets/Scripts/Deck/Deck.cs b/Assets/Scripts/Deck/Deck.cs index e1082f0..ce16c24 100644 --- a/Assets/Scripts/Deck/Deck.cs +++ b/Assets/Scripts/Deck/Deck.cs @@ -1,116 +1,122 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Deck<T> : MonoBehaviour -{ - [SerializeField] - public List<T> totalCards; - - [SerializeField] - public Stack<T> currentDeck; - - public void Init() - { - totalCards = new List<T>(); - } - - public void InitPlayingDeck() - { - currentDeck = new Stack<T>(); - foreach(T card in totalCards) - { - currentDeck.Push(card); - } - } - - public T Draw() - { - if(currentDeck.Count == 0) - { - this.Reshuffle(); - } - return currentDeck.Pop(); - - } - - - public void ShuffleTotal() - { - Shuffle<T>(totalCards); - } - - public void ShuffleDeck() - { - T[] tmpArray = currentDeck.ToArray(); - currentDeck.Clear(); - Shuffle(tmpArray); - foreach(T card in tmpArray) - { - currentDeck.Push(card); - } - - } - - - public void AddCard(T card) - { - - int j = Random.Range(0, totalCards.Count); - if(j == totalCards.Count) - { - totalCards.Add(card); - } - else - { - totalCards.Insert(j, card); - } - - } - - public void RemoveCard(T card) - { - if(totalCards.Contains(card)) - { - totalCards.Remove(card); - } - } - - - public void Reshuffle() - { - currentDeck.Clear(); - currentDeck = Dump<T>.Instance.Recycle(); - - if(currentDeck.Count == 0) - { - Debug.LogError("deck & dump empty"); - } - } - #region Utilities - public static void Shuffle<E>(List<E> list) - { - for (int i = list.Count - 1; i >= 0; i--) - { - int j = Random.Range(0, i + 1); - - E tmp = list[i]; - list[i] = list[j]; - list[j] = tmp; - } - } - - public static void Shuffle<E>( E[] array) - { - for (int i = array.Length - 1; i >= 0; i--) - { - int j = Random.Range(0, i + 1); - - E tmp = array[i]; - array[i] = array[j]; - array[j] = tmp; - } - } - #endregion - -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Deck : MonoBehaviour +{ + [SerializeField] + public List<Card> totalCards; + + [SerializeField] + public Stack<Card> currentDeck; + + [SerializeField] + private CardInitializer initializer; + + private void Start() + { + } + + public void InitPlayingDeck() + { + + currentDeck = new Stack<Card>(); + foreach(Card card in totalCards) + { + initializer.InitCard(card); + currentDeck.Push(card); + } + } + + + public Card Draw() + { + if(currentDeck.Count == 0) + { + Reshuffle(); + } + return currentDeck.Pop(); + } + + + public void ShuffleTotal() + { + Shuffle(totalCards); + } + + public void ShuffleDeck() + { + Card[] tmpArray = currentDeck.ToArray(); + currentDeck.Clear(); + Shuffle(tmpArray); + foreach(Card card in tmpArray) + { + currentDeck.Push(card); + } + + } + + + public void AddCard(Card card) + { + + int j = Random.Range(0, totalCards.Count); + if(j == totalCards.Count) + { + totalCards.Add(card); + } + else + { + totalCards.Insert(j, card); + } + //desactivate card and set parent + card.transform.SetParent(transform); + card.gameObject.SetActive(false); + } + + public void RemoveCard(Card card) + { + if(totalCards.Contains(card)) + { + totalCards.Remove(card); + } + } + + + public void Reshuffle() + { + currentDeck.Clear(); + currentDeck = Dump.Instance.Recycle(); + + if(currentDeck.Count == 0) + { + Debug.LogError("deck & dump empty"); + } + } + #region Utilities + public static void Shuffle<E>(List<E> list) + { + for (int i = list.Count - 1; i >= 0; i--) + { + int j = Random.Range(0, i + 1); + + E tmp = list[i]; + list[i] = list[j]; + list[j] = tmp; + } + } + + public static void Shuffle<E>( E[] array) + { + for (int i = array.Length - 1; i >= 0; i--) + { + int j = Random.Range(0, i + 1); + + E tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + } + #endregion + +} diff --git a/Assets/Scripts/Deck/Dump.cs b/Assets/Scripts/Deck/Dump.cs index ff94b6e..3429e2d 100644 --- a/Assets/Scripts/Deck/Dump.cs +++ b/Assets/Scripts/Deck/Dump.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using UnityEngine; -public class Dump<T> : MonoBehaviour +public class Dump : MonoBehaviour { - public Stack<T> dumpStack; + public Stack<Card> dumpStack; - public static Dump<T> Instance + public static Dump Instance { private set; get; @@ -23,7 +23,7 @@ public class Dump<T> : MonoBehaviour DestroyImmediate(this); } - dumpStack = new Stack<T>(); + dumpStack = new Stack<Card>(); Debug.Log("init dump"); } @@ -40,23 +40,23 @@ public class Dump<T> : MonoBehaviour DestroyImmediate(this); } - dumpStack = new Stack<T>(); + dumpStack = new Stack<Card>(); Debug.Log("init dump"); } - public void Discard(T card) + public void Discard(Card card) { Debug.Log("dump size: "+dumpStack.Count); dumpStack.Push(card); } - public Stack<T> Recycle () + public Stack<Card> Recycle () { - Stack<T> result = new Stack<T>(); + Stack<Card> result = new Stack<Card>(); while(dumpStack.Count >0) { @@ -66,7 +66,7 @@ public class Dump<T> : MonoBehaviour return result; } - public T Draw() + public Card Draw() { return dumpStack.Pop(); } diff --git a/Assets/Scripts/Deck/Hand.cs b/Assets/Scripts/Deck/Hand.cs index 82d99fc..15c6faf 100644 --- a/Assets/Scripts/Deck/Hand.cs +++ b/Assets/Scripts/Deck/Hand.cs @@ -1,76 +1,64 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class Hand<T> : MonoBehaviour -{ - [SerializeField] - public Deck<T> deck; - - private Dump<T> dump; - - [SerializeField] - private int MaxHandSize = 7; - - [SerializeField] - private int StartHandSize = 5; - - [SerializeField] - public List<T> hand; - // Start is called before the first frame update - - - // Update is called once per frame - void Update() - { - - } - - public void Init() - { - hand = new List<T>(); - deck.InitPlayingDeck(); - for (int i = 0; i < StartHandSize; i++) - { - Draw(); - } - dump = Dump<T>.Instance; - } - - public void Draw() - { - T newCard = deck.Draw(); - - if(hand.Count < MaxHandSize) - { - - hand.Add(newCard); - } - else - { - - Discard(newCard); - } - } - - public void DrawFromDump() - { - T newCard = dump.Draw(); - if (hand.Count < MaxHandSize) - { - Debug.Log("draw succed"); - hand.Add(newCard); - } - else - { - - Discard(newCard); - } - } - - - public void Discard(T card) - { - Dump<T>.Instance.Discard(card); - } -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Hand : MonoBehaviour +{ + [SerializeField] + public Deck deck; + + [SerializeField] + private int MaxHandSize = 7; + + [SerializeField] + private int StartHandSize = 5; + + [SerializeField] + public List<Card> hand; + // Start is called before the first frame update + void Start() + { + hand = new List<Card>(); + deck.InitPlayingDeck(); + for (int i = 0; i < StartHandSize; i++) + { + Draw(); + } + } + + // Update is called once per frame + void Update() + { + + } + + public List<Card> GetCards() + { + return hand; + } + + public void Draw() + { + Card newCard = deck.Draw(); + + if(hand.Count < MaxHandSize) + { + Debug.Log("draw succed"); + hand.Add(newCard); + CardEvent<Card>.Trigger(Event.CARD_DRAW, newCard); + newCard.gameObject.SetActive(true); + } + else + { + Debug.Log("discard"); + Discard(newCard); + } + } + + + + public void Discard(Card card) + { + Dump.Instance.Discard(card); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Deck/Init.cs b/Assets/Scripts/Deck/Init.cs deleted file mode 100644 index 4aafdfd..0000000 --- a/Assets/Scripts/Deck/Init.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.UI; - -public class Init : MonoBehaviour -{ - [SerializeField] - private CardPool cardPool; - - private Deck<string> decktest; - - private Dump<string> dumptest; - - private Hand<string> handtest; - - [SerializeField] - private Text[] draftPreviews; - - [SerializeField] - private Button[] draftSelection; - - - [SerializeField] - private List<string> deckpreview; - - [SerializeField] - private List<string> handpreview; - - [SerializeField] - private string[] dumppreview; - - [SerializeField] - private string[] draftResult; - - // Start is called before the first frame update - void Start() - { - draftResult = new string[draftSelection.Length]; - decktest = new Deck<string>(); - handtest = new Hand<string>(); - dumptest = new Dump<string>(); - - handtest.deck = decktest; - decktest.Init(); - dumptest.Init(); - /*for (int i = 0; i < draftSelection.Length; i++) - { - draftSelection[i].onClick.AddListener(() => { SelectCard(i); }); - }*/ - } - - // Update is called once per frame - void Update() - { - - } - - public void Draft() - { - draftResult = cardPool.Draft(draftSelection.Length); - for(int i = 0; i< draftSelection.Length; i++ ) - { - draftPreviews[i].text = draftResult[i]; - } - } - - public void SelectCard(int i) - { - Debug.Log("card selected: " + i); - for (int j = 0; j < draftPreviews.Length; j++) - { - draftPreviews[j].text = ""; - } - decktest.AddCard(draftResult[i]); - deckpreview = decktest.totalCards; - } - - public void Shuffle() - { - decktest.ShuffleTotal(); - deckpreview = decktest.totalCards; - } - - - public void Play() - { - dumptest.Init(); - decktest.InitPlayingDeck(); - handtest.Init(); - handpreview = handtest.hand; - deckpreview = decktest.currentDeck.ToList(); - - } - - public void Draw() - { - handtest.Draw(); - handpreview = handtest.hand; - dumppreview = dumptest.dumpStack.ToArray(); - deckpreview = decktest.currentDeck.ToList(); - } - - - -} diff --git a/Assets/Scripts/ScoreBar.cs b/Assets/Scripts/ScoreBar.cs index a1f8c6b..d1b23de 100644 --- a/Assets/Scripts/ScoreBar.cs +++ b/Assets/Scripts/ScoreBar.cs @@ -29,7 +29,7 @@ public class ScoreBar : MonoBehaviour /* Change the score, value > 0 is an increase for the player and a decrease for then opponent */ public void ModifyScore(int value) { - mSlider.value -= (float)value; + mSlider.value += (float)value; mValue += value; } diff --git a/Assets/Scripts/Ui.meta b/Assets/Scripts/Ui.meta new file mode 100644 index 0000000..63b97a6 --- /dev/null +++ b/Assets/Scripts/Ui.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e5c055a32b0d3c4994bfdaf0833dc4f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Ui/HandUi.cs b/Assets/Scripts/Ui/HandUi.cs new file mode 100644 index 0000000..b493f64 --- /dev/null +++ b/Assets/Scripts/Ui/HandUi.cs @@ -0,0 +1,39 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class HandUi : MonoBehaviour +{ + + [SerializeField] + private Hand mRenderedHand; + + // Start is called before the first frame update + void Start() + { + CardEvent<Card>.Register(Event.CARD_DRAW, OnCardDraw); + } + + public void OnCardDraw(Card card) + { + PlaceHand(); + } + + void PlaceHand() + { + List<Card> cards = mRenderedHand.GetCards(); + if (cards.Count == 0) + return; //nothing to do + float cardSize = cards[0].GetComponent<RectTransform>().rect.width; + float decal = cardSize * 0.80f; + int mod = 0; + float starting = -(decal * cards.Count) / 2f; + foreach (Card card in cards) + { + Vector3 newpos = new Vector3(starting + decal * mod, card.transform.localPosition.y, -mod); + card.transform.localPosition = newpos; + mod++; + } + } +} diff --git a/Assets/Scripts/Deck/Init.cs.meta b/Assets/Scripts/Ui/HandUi.cs.meta similarity index 83% rename from Assets/Scripts/Deck/Init.cs.meta rename to Assets/Scripts/Ui/HandUi.cs.meta index b239d88..846e26d 100644 --- a/Assets/Scripts/Deck/Init.cs.meta +++ b/Assets/Scripts/Ui/HandUi.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6777a307aa5a9f242ac2e83949957330 +guid: a6fe9b3bd73304f44ac5053e5b2a9531 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index d033e8f..42b4b32 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.1.13f1 -m_EditorVersionWithRevision: 2019.1.13f1 (b5956c0a61e7) +m_EditorVersion: 2019.1.12f1 +m_EditorVersionWithRevision: 2019.1.12f1 (f04f5427219e) -- GitLab