From b1308b5f4793956eeb8dceda80cd88b455d75844 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 13 Jan 2023 15:50:48 -0500 Subject: [PATCH] full flow --- namedropper/Assets/GameOverScreen.cs | 25 + namedropper/Assets/GameOverScreen.cs.meta | 11 + namedropper/Assets/Replay.cs | 21 + namedropper/Assets/Replay.cs.meta | 11 + namedropper/Assets/Scenes/Game.unity | 25 +- namedropper/Assets/Scenes/GameOver.unity | 546 ++++++++++++++++++ namedropper/Assets/Scenes/GameOver.unity.meta | 7 + ...CategorySelect.unity => TopicSelect.unity} | 41 +- ...lect.unity.meta => TopicSelect.unity.meta} | 0 namedropper/Assets/Scripts/Game.cs | 57 +- namedropper/Assets/Scripts/GameDataManager.cs | 7 +- namedropper/Assets/Scripts/GameManager.cs | 50 ++ .../Assets/Scripts/GameManager.cs.meta | 11 + namedropper/Assets/Scripts/Player.cs | 17 +- namedropper/Assets/Scripts/TopicSelect.cs | 8 +- namedropper/Packages/manifest.json | 2 +- namedropper/Packages/packages-lock.json | 2 +- .../ProjectSettings/EditorBuildSettings.asset | 5 +- 18 files changed, 790 insertions(+), 56 deletions(-) create mode 100644 namedropper/Assets/GameOverScreen.cs create mode 100644 namedropper/Assets/GameOverScreen.cs.meta create mode 100644 namedropper/Assets/Replay.cs create mode 100644 namedropper/Assets/Replay.cs.meta create mode 100644 namedropper/Assets/Scenes/GameOver.unity create mode 100644 namedropper/Assets/Scenes/GameOver.unity.meta rename namedropper/Assets/Scenes/{CategorySelect.unity => TopicSelect.unity} (98%) rename namedropper/Assets/Scenes/{CategorySelect.unity.meta => TopicSelect.unity.meta} (100%) create mode 100644 namedropper/Assets/Scripts/GameManager.cs create mode 100644 namedropper/Assets/Scripts/GameManager.cs.meta diff --git a/namedropper/Assets/GameOverScreen.cs b/namedropper/Assets/GameOverScreen.cs new file mode 100644 index 0000000..65ad4bf --- /dev/null +++ b/namedropper/Assets/GameOverScreen.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class GameOverScreen : MonoBehaviour +{ + [SerializeField] Text _gameOverMessage; + + void Start() + { + if (GameManager.Instance.Score > GameManager.Instance.HighScore) + { + GameManager.Instance.HighScore = GameManager.Instance.Score; + } + _gameOverMessage.text = "GAME OVER\n\nYour score: " + GameManager.Instance.Score + "\nToday's hi-score: " + GameManager.Instance.HighScore.ToString() + "\n\nPress 'R' to Replay"; + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/namedropper/Assets/GameOverScreen.cs.meta b/namedropper/Assets/GameOverScreen.cs.meta new file mode 100644 index 0000000..9b4a8ea --- /dev/null +++ b/namedropper/Assets/GameOverScreen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2aa0539fcac3224495562ab7c386f3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Replay.cs b/namedropper/Assets/Replay.cs new file mode 100644 index 0000000..e8ecbae --- /dev/null +++ b/namedropper/Assets/Replay.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Replay : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (Input.GetKeyDown(KeyCode.R)) + { + GameManager.Instance.RestartGame(); + } + } +} diff --git a/namedropper/Assets/Replay.cs.meta b/namedropper/Assets/Replay.cs.meta new file mode 100644 index 0000000..3cbe658 --- /dev/null +++ b/namedropper/Assets/Replay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d9f0573f6651ecd4b900ae5fee7f7cb6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scenes/Game.unity b/namedropper/Assets/Scenes/Game.unity index b17ec9c..a2ea31d 100644 --- a/namedropper/Assets/Scenes/Game.unity +++ b/namedropper/Assets/Scenes/Game.unity @@ -259,7 +259,7 @@ GameObject: m_Component: - component: {fileID: 107001399} m_Layer: 5 - m_Name: Scores + m_Name: UI m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -548,7 +548,7 @@ GameObject: - component: {fileID: 1225785574} - component: {fileID: 1225785573} m_Layer: 5 - m_Name: BlueScore + m_Name: Timer m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -884,6 +884,7 @@ GameObject: m_Component: - component: {fileID: 1641253473} - component: {fileID: 1641253472} + - component: {fileID: 1641253474} m_Layer: 0 m_Name: Game m_TagString: Untagged @@ -903,8 +904,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c2999330b51cf4c409e52d0a60d0be86, type: 3} m_Name: m_EditorClassIdentifier: - BlueScoreCounter: {fileID: 1225785573} - RedScoreCounter: {fileID: 1957998283} + Score: {fileID: 1957998283} + Timer: {fileID: 1225785573} --- !u!4 &1641253473 Transform: m_ObjectHideFlags: 0 @@ -919,6 +920,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1641253474 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1641253471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d9f0573f6651ecd4b900ae5fee7f7cb6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1666960087 GameObject: m_ObjectHideFlags: 0 @@ -1333,7 +1346,7 @@ GameObject: - component: {fileID: 1957998284} - component: {fileID: 1957998283} m_Layer: 5 - m_Name: RedScore + m_Name: Score m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1371,7 +1384,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Material: {fileID: 0} - m_Color: {r: 1, g: 0, b: 0.3764553, a: 1} + m_Color: {r: 0, g: 0.44705883, b: 1, a: 1} m_RaycastTarget: 1 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 diff --git a/namedropper/Assets/Scenes/GameOver.unity b/namedropper/Assets/Scenes/GameOver.unity new file mode 100644 index 0000000..acbc608 --- /dev/null +++ b/namedropper/Assets/Scenes/GameOver.unity @@ -0,0 +1,546 @@ +%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: 12 + 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_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !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 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &107001398 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 107001399} + m_Layer: 5 + m_Name: UI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &107001399 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 107001398} + 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: 1225785572} + m_Father: {fileID: 1666960088} + m_RootOrder: 0 + 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!1 &1225785571 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1225785572} + - component: {fileID: 1225785574} + - component: {fileID: 1225785573} + m_Layer: 5 + m_Name: Game Over Message + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1225785572 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1225785571} + 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: 107001399} + m_RootOrder: 0 + 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: 297.69} + m_SizeDelta: {x: 167.5, y: 231.1} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1225785573 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1225785571} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0, g: 0.4462726, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 12800000, guid: b46f1d3bdf627d645a08de1c3a257a10, type: 3} + m_FontSize: 115 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 3 + m_MaxSize: 300 + m_Alignment: 1 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: GAME OVER +--- !u!222 &1225785574 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1225785571} + m_CullTransparentMesh: 1 +--- !u!1 &1252190028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1252190031} + - component: {fileID: 1252190030} + - component: {fileID: 1252190029} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1252190029 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252190028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, 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 &1252190030 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252190028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1252190031 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1252190028} + 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 &1439945299 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1439945302} + - component: {fileID: 1439945301} + - component: {fileID: 1439945300} + 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 &1439945300 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1439945299} + m_Enabled: 1 +--- !u!20 &1439945301 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1439945299} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 537.24 + 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 &1439945302 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1439945299} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 960, y: 540, 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!1 &1641253471 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1641253473} + - component: {fileID: 1641253474} + - component: {fileID: 1641253472} + m_Layer: 0 + m_Name: GameOverScreen + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1641253472 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1641253471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d9f0573f6651ecd4b900ae5fee7f7cb6, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1641253473 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1641253471} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 328.70825, y: 532.0139, z: -188.99962} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1641253474 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1641253471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f2aa0539fcac3224495562ab7c386f3a, type: 3} + m_Name: + m_EditorClassIdentifier: + _gameOverMessage: {fileID: 1225785573} +--- !u!1 &1666960087 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1666960088} + - component: {fileID: 1666960091} + - component: {fileID: 1666960090} + - component: {fileID: 1666960089} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1666960088 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1666960087} + 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: 107001399} + 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 &1666960089 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1666960087} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1666960090 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1666960087} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, 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 + m_PresetInfoIsWorld: 0 +--- !u!223 &1666960091 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1666960087} + 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 diff --git a/namedropper/Assets/Scenes/GameOver.unity.meta b/namedropper/Assets/Scenes/GameOver.unity.meta new file mode 100644 index 0000000..f1e99a2 --- /dev/null +++ b/namedropper/Assets/Scenes/GameOver.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9a83269cc360c71439d7152c93d105c9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scenes/CategorySelect.unity b/namedropper/Assets/Scenes/TopicSelect.unity similarity index 98% rename from namedropper/Assets/Scenes/CategorySelect.unity rename to namedropper/Assets/Scenes/TopicSelect.unity index 35f5305..2df24b5 100644 --- a/namedropper/Assets/Scenes/CategorySelect.unity +++ b/namedropper/Assets/Scenes/TopicSelect.unity @@ -296,22 +296,6 @@ GameObject: m_PrefabInstance: {fileID: 785169904} m_PrefabAsset: {fileID: 0} --- !u!114 &330129966 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330129965} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ae3cf3ee1d381b544985a421e4ecbc64, type: 3} - m_Name: - m_EditorClassIdentifier: - Name: - TopicData: - Topic: - Categories: [] ---- !u!114 &330129967 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -703,6 +687,7 @@ GameObject: m_Component: - component: {fileID: 1641253473} - component: {fileID: 1641253472} + - component: {fileID: 1641253474} m_Layer: 0 m_Name: TopicSelect m_TagString: Untagged @@ -723,7 +708,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: _topic1Box: {fileID: 1797572950} - _topic2Box: {fileID: 330129967} + _topic2Box: {fileID: 330129966} _title: {fileID: 1225785573} --- !u!4 &1641253473 Transform: @@ -739,6 +724,18 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1641253474 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1641253471} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d9f0573f6651ecd4b900ae5fee7f7cb6, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1666960087 GameObject: m_ObjectHideFlags: 0 @@ -829,8 +826,8 @@ Canvas: m_GameObject: {fileID: 1666960087} m_Enabled: 1 serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} + m_RenderMode: 1 + m_Camera: {fileID: 1439945301} m_PlaneDistance: 100 m_PixelPerfect: 0 m_ReceivesEvents: 1 @@ -839,7 +836,7 @@ Canvas: m_SortingBucketNormalizedSize: 0 m_AdditionalShaderChannelsFlag: 0 m_SortingLayerID: 0 - m_SortingOrder: 0 + m_SortingOrder: 1 m_TargetDisplay: 0 --- !u!1 &1682087379 GameObject: @@ -950,6 +947,10 @@ PrefabInstance: propertyPath: _team value: 1 objectReference: {fileID: 0} + - target: {fileID: 9049015333349338377, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3} + propertyPath: _forTopicSelect + value: 1 + objectReference: {fileID: 0} - target: {fileID: 9049015333349338378, guid: 56b5ab1b6ee02794ab9664e282d1930a, type: 3} propertyPath: m_Mass value: 0.5 diff --git a/namedropper/Assets/Scenes/CategorySelect.unity.meta b/namedropper/Assets/Scenes/TopicSelect.unity.meta similarity index 100% rename from namedropper/Assets/Scenes/CategorySelect.unity.meta rename to namedropper/Assets/Scenes/TopicSelect.unity.meta diff --git a/namedropper/Assets/Scripts/Game.cs b/namedropper/Assets/Scripts/Game.cs index 185515d..d2297d7 100644 --- a/namedropper/Assets/Scripts/Game.cs +++ b/namedropper/Assets/Scripts/Game.cs @@ -1,15 +1,14 @@ using UnityEngine; +using System.Collections; using UnityEngine.UI; - using UnityEngine.SceneManagement; public class Game : MonoBehaviour { - int _blueScore = 0; - int _redScore = 0; + int _seconds = 60; - [SerializeField] Text BlueScoreCounter; - [SerializeField] Text RedScoreCounter; + [SerializeField] Text Score; + [SerializeField] Text Timer; Category[] _categories; // Start is called before the first frame update @@ -18,6 +17,12 @@ public class Game : MonoBehaviour _categories = FindObjectsOfType(); + //set the topic for testing purposes in case I start directly from this scene + if (GameDataManager.Instance.CurrentTopic == null) + { + GameDataManager.Instance.CurrentTopic = GameDataManager.Instance.GetRandomTopicData(); + } + foreach (Category category in _categories) { CategoryData categoryData = GameDataManager.Instance.GetRandomCategoryData(GameDataManager.Instance.CurrentTopic); @@ -25,24 +30,43 @@ public class Game : MonoBehaviour category.Name = categoryData.Category; category.Elements = categoryData.Elements; category.ResetElements(); - } + StartCoroutine(Countdown()); } - private void Start() + + IEnumerator Countdown() { - UpdateScores(); + while (_seconds > 0) + { + _seconds--; + Timer.text = _seconds.ToString(); + yield return new WaitForSeconds(1f); + } + NextRound(); } - public void AddScore(Player.Team team, int amount = 1) + void NextRound() { - if (team == Player.Team.RED) + GameManager.Instance.Round++; + + if (GameManager.Instance.Round > 3) { - _redScore += amount; + SceneManager.LoadScene("GameOver"); } - else if (team == Player.Team.BLUE) + else { - _blueScore += amount; + SceneManager.LoadScene("TopicSelect"); } + } + + private void Start() + { + UpdateScores(); + } + + public void AddScore(int amount = 1) + { + GameManager.Instance.Score += amount; UpdateScores(); } @@ -55,16 +79,15 @@ public class Game : MonoBehaviour public void UpdateScores() { - BlueScoreCounter.text = _blueScore.ToString(); - RedScoreCounter.text = _redScore.ToString(); + Score.text = GameManager.Instance.Score.ToString(); } // Update is called once per frame void Update() { - if (Input.GetKeyDown(KeyCode.R)) + if (Input.GetKeyDown(KeyCode.RightBracket)) { - SceneManager.LoadScene(SceneManager.GetActiveScene().name); + NextRound(); } } } diff --git a/namedropper/Assets/Scripts/GameDataManager.cs b/namedropper/Assets/Scripts/GameDataManager.cs index a305cad..d1e58f2 100644 --- a/namedropper/Assets/Scripts/GameDataManager.cs +++ b/namedropper/Assets/Scripts/GameDataManager.cs @@ -8,10 +8,15 @@ using System.IO; public class GameDataManager { private static GameDataManager _instance = null; - GameData _gameData = new GameData(); + GameData _gameData = null; TopicData _currentTopic = null; public GameDataManager() { + Reset(); + } + + public void Reset() + { Deserializer deserializer = new Deserializer(); string yamlText = File.ReadAllText(Application.dataPath + "/Resources/categories.yaml"); _gameData = deserializer.Deserialize(yamlText); diff --git a/namedropper/Assets/Scripts/GameManager.cs b/namedropper/Assets/Scripts/GameManager.cs new file mode 100644 index 0000000..651fdfe --- /dev/null +++ b/namedropper/Assets/Scripts/GameManager.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; +using System.IO; + +public class GameManager +{ + private static GameManager _instance = null; + + int _score = 0; + int _highScore = 0; + int _round = 1; + + public GameManager() + { + Reset(); + } + + void Reset() + { + Score = 0; + Round = 1; + } + + public void RestartGame() + { + Reset(); + GameDataManager.Instance.Reset(); + SceneManager.LoadScene("TopicSelect"); + } + + public static GameManager Instance + { + get + { + if (_instance == null) + { + _instance = new GameManager(); + } + return _instance; + } + } + + public int Score { get => _score; set => _score = value; } + public int Round { get => _round; set => _round = value; } + public int HighScore { get => _highScore; set => _highScore = value; } +} \ No newline at end of file diff --git a/namedropper/Assets/Scripts/GameManager.cs.meta b/namedropper/Assets/Scripts/GameManager.cs.meta new file mode 100644 index 0000000..4240005 --- /dev/null +++ b/namedropper/Assets/Scripts/GameManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b800293dfcdfcca4e8aec93973cca5ec +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scripts/Player.cs b/namedropper/Assets/Scripts/Player.cs index 3e0e018..9d832f2 100644 --- a/namedropper/Assets/Scripts/Player.cs +++ b/namedropper/Assets/Scripts/Player.cs @@ -11,6 +11,7 @@ public class Player : MonoBehaviour [SerializeField] KeyCode _keyDown; [SerializeField] Team _team; [SerializeField] Text _text; + [SerializeField] bool _forTopicSelect = false; Game _game; Vector3 _originalPosition; public enum Team @@ -32,7 +33,8 @@ public class Player : MonoBehaviour void Start() { - PickNewWord(); + if (_forTopicSelect == false) + PickNewWord(); } void PickNewWord() @@ -40,6 +42,17 @@ public class Player : MonoBehaviour _text.text = _game.PickRandomWord(); } + private void OnCollisionEnter2D(Collision2D collision) + { + GameObject other = collision.gameObject; + if (other.GetComponent()) + { + const float BOUNCE_AMOUNT = 60f; + other.GetComponent().AddForce((other.transform.position - transform.position) * BOUNCE_AMOUNT); + GetComponent().AddForce((transform.position - other.transform.position) * BOUNCE_AMOUNT); + + } + } private void OnTriggerEnter2D(Collider2D collision) { Category category = collision.gameObject.GetComponent(); @@ -49,7 +62,7 @@ public class Player : MonoBehaviour if (category.Elements.Contains(_text.text)) { - _game.AddScore(_team); + _game.AddScore(); category.ShowFeedbackGood(); } else diff --git a/namedropper/Assets/Scripts/TopicSelect.cs b/namedropper/Assets/Scripts/TopicSelect.cs index 1366011..711ba61 100644 --- a/namedropper/Assets/Scripts/TopicSelect.cs +++ b/namedropper/Assets/Scripts/TopicSelect.cs @@ -9,7 +9,6 @@ public class TopicSelect : MonoBehaviour [SerializeField] TopicBox _topic2Box; [SerializeField] Text _title; - int round = 1; // Start is called before the first frame update void Awake() { @@ -18,7 +17,7 @@ public class TopicSelect : MonoBehaviour void InitRound() { - _title.text = "Round " + round + "\nPick a Topic!"; + _title.text = "Round " + GameManager.Instance.Round + "\nPick a Topic!"; _topic1Box.TopicData = GameDataManager.Instance.GetRandomTopicData(); _topic2Box.TopicData = GameDataManager.Instance.GetRandomTopicData(); _topic1Box.Name = _topic1Box.TopicData.Topic; @@ -28,10 +27,5 @@ public class TopicSelect : MonoBehaviour // Update is called once per frame void Update() { - if (Input.GetKeyDown(KeyCode.R)) - { - SceneManager.LoadScene(SceneManager.GetActiveScene().name); - } - } } diff --git a/namedropper/Packages/manifest.json b/namedropper/Packages/manifest.json index 89ebb8f..b7e1b8c 100644 --- a/namedropper/Packages/manifest.json +++ b/namedropper/Packages/manifest.json @@ -8,7 +8,7 @@ "com.unity.2d.tilemap": "1.0.0", "com.unity.collab-proxy": "1.15.7", "com.unity.ide.rider": "2.0.7", - "com.unity.ide.visualstudio": "2.0.12", + "com.unity.ide.visualstudio": "2.0.17", "com.unity.ide.vscode": "1.2.4", "com.unity.test-framework": "1.1.29", "com.unity.textmeshpro": "3.0.6", diff --git a/namedropper/Packages/packages-lock.json b/namedropper/Packages/packages-lock.json index 9c31022..ae8d313 100644 --- a/namedropper/Packages/packages-lock.json +++ b/namedropper/Packages/packages-lock.json @@ -99,7 +99,7 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.12", + "version": "2.0.17", "depth": 0, "source": "registry", "dependencies": { diff --git a/namedropper/ProjectSettings/EditorBuildSettings.asset b/namedropper/ProjectSettings/EditorBuildSettings.asset index ec08eb4..10176f1 100644 --- a/namedropper/ProjectSettings/EditorBuildSettings.asset +++ b/namedropper/ProjectSettings/EditorBuildSettings.asset @@ -9,9 +9,12 @@ EditorBuildSettings: path: guid: 00000000000000000000000000000000 - enabled: 1 - path: Assets/Scenes/CategorySelect.unity + path: Assets/Scenes/TopicSelect.unity guid: 91a4af9a6af9fc840b522128085513da - enabled: 1 path: Assets/Scenes/Game.unity guid: fc389e04780671f498562f1d56f81afb + - enabled: 1 + path: Assets/Scenes/GameOver.unity + guid: 9a83269cc360c71439d7152c93d105c9 m_configObjects: {}