From 9e082537d808c4135e057d7fb2dc35659fdcd36a Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Thu, 2 Jun 2022 14:48:24 +0200 Subject: [PATCH 1/5] money and daycount ui added --- Assets/Scenes/MainScene.unity | 803 ++++++++++++++++++++++++++++- Assets/Scripts/HouseController.cs | 6 +- Assets/Scripts/PlayerController.cs | 13 +- Assets/Scripts/ShopSlot.cs | 6 +- 4 files changed, 819 insertions(+), 9 deletions(-) diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index ee638aa..fe5e082 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -1639,7 +1639,7 @@ MonoBehaviour: m_HandleRect: {fileID: 2006577138} m_Direction: 2 m_Value: 1 - m_Size: 0.5932421 + m_Size: 0.59324205 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -2677,6 +2677,141 @@ RectTransform: m_CorrespondingSourceObject: {fileID: 3510585822996971025, guid: 44dae5fbdb6f7df4f93a10807f66956f, type: 3} m_PrefabInstance: {fileID: 729139770} m_PrefabAsset: {fileID: 0} +--- !u!1 &865947142 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 865947143} + - component: {fileID: 865947145} + - component: {fileID: 865947144} + m_Layer: 5 + m_Name: DayText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &865947143 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865947142} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1070476668} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 68.54913, y: -22.5} + m_SizeDelta: {x: 115, y: 45} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &865947144 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865947142} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_text: "Day: \n" + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &865947145 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 865947142} + m_CullTransparentMesh: 1 --- !u!1001 &876025937 PrefabInstance: m_ObjectHideFlags: 0 @@ -3524,6 +3659,321 @@ RectTransform: m_CorrespondingSourceObject: {fileID: 3510585822996971025, guid: 44dae5fbdb6f7df4f93a10807f66956f, type: 3} m_PrefabInstance: {fileID: 160321877} m_PrefabAsset: {fileID: 0} +--- !u!1 &1061398530 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1061398534} + - component: {fileID: 1061398533} + - component: {fileID: 1061398532} + - component: {fileID: 1061398531} + m_Layer: 5 + m_Name: InfoCanvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1061398531 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1061398530} + 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 &1061398532 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1061398530} + 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 &1061398533 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1061398530} + 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: 25 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1061398534 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1061398530} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1070476668} + - {fileID: 1649897726} + m_Father: {fileID: 0} + m_RootOrder: 8 + 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!1 &1070476667 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1070476668} + - component: {fileID: 1070476670} + - component: {fileID: 1070476669} + m_Layer: 5 + m_Name: DayParent + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1070476668 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1070476667} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 865947143} + - {fileID: 1089918734} + m_Father: {fileID: 1061398534} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -242.5, y: 202.5} + m_SizeDelta: {x: -515, y: -435} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1070476669 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1070476667} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_Sprite: {fileID: 21300000, guid: 2a61ecc3d143def478dfed9f6d6ca3fd, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1070476670 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1070476667} + m_CullTransparentMesh: 1 +--- !u!1 &1089918733 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1089918734} + - component: {fileID: 1089918736} + - component: {fileID: 1089918735} + m_Layer: 5 + m_Name: DayCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1089918734 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1089918733} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1070476668} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 85.08983, y: -22.25} + m_SizeDelta: {x: 53.6157, y: 44.5} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1089918735 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1089918733} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_text: 1 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 4 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1089918736 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1089918733} + m_CullTransparentMesh: 1 --- !u!1001 &1113359677 PrefabInstance: m_ObjectHideFlags: 0 @@ -4456,6 +4906,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: menu: {fileID: 1395531174} + dayCountTextMeshProUGUI: {fileID: 1089918735} --- !u!212 &1278234715 SpriteRenderer: m_ObjectHideFlags: 0 @@ -4785,6 +5236,141 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 44dae5fbdb6f7df4f93a10807f66956f, type: 3} +--- !u!1 &1347709340 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1347709341} + - component: {fileID: 1347709343} + - component: {fileID: 1347709342} + m_Layer: 5 + m_Name: MoneyCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1347709341 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347709340} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1649897726} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 90.6, y: -22.5} + m_SizeDelta: {x: 53.6157, y: 44.5} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1347709342 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347709340} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_text: "0\xB5" + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 4 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1347709343 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1347709340} + m_CullTransparentMesh: 1 --- !u!1001 &1373673699 PrefabInstance: m_ObjectHideFlags: 0 @@ -5887,6 +6473,84 @@ RectTransform: m_AnchoredPosition: {x: -640, y: 215} m_SizeDelta: {x: 720, y: 430} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &1649897725 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1649897726} + - component: {fileID: 1649897728} + - component: {fileID: 1649897727} + m_Layer: 5 + m_Name: MoneyParent + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1649897726 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1649897725} + 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_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 2022611509} + - {fileID: 1347709341} + m_Father: {fileID: 1061398534} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -242.5, y: 147.5} + m_SizeDelta: {x: -515, y: -435} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1649897727 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1649897725} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_Sprite: {fileID: 21300000, guid: 2a61ecc3d143def478dfed9f6d6ca3fd, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1649897728 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1649897725} + m_CullTransparentMesh: 1 --- !u!1 &1671356616 GameObject: m_ObjectHideFlags: 0 @@ -6192,8 +6856,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b18feac5270242d4a85c78ce72972d56, type: 3} m_Name: m_EditorClassIdentifier: - money: 0 startMoney: 10000 + moneyTextMeshProUGUI: {fileID: 1347709342} --- !u!4 &1800469990 Transform: m_ObjectHideFlags: 0 @@ -7026,6 +7690,141 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2006577137} m_CullTransparentMesh: 1 +--- !u!1 &2022611508 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2022611509} + - component: {fileID: 2022611511} + - component: {fileID: 2022611510} + m_Layer: 5 + m_Name: MoneyText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2022611509 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2022611508} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1649897726} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 66.029, y: -22.5} + m_SizeDelta: {x: 115, y: 45} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &2022611510 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2022611508} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, 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_text: 'Money:' + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &2022611511 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2022611508} + m_CullTransparentMesh: 1 --- !u!224 &2026367185 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 3510585822996971025, guid: 44dae5fbdb6f7df4f93a10807f66956f, type: 3} diff --git a/Assets/Scripts/HouseController.cs b/Assets/Scripts/HouseController.cs index 5d2de3d..10723d2 100644 --- a/Assets/Scripts/HouseController.cs +++ b/Assets/Scripts/HouseController.cs @@ -1,15 +1,17 @@ using System; using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.Events; public class HouseController : MonoBehaviour { - private int dayCount = 0; + private int dayCount = 1; private static UnityEvent newDayEvent; public static UnityEvent NewDayEvent => newDayEvent; public Canvas menu; + public TextMeshProUGUI dayCountTextMeshProUGUI; private void OnMouseDown() { toggleMenu(); @@ -21,7 +23,7 @@ public class HouseController : MonoBehaviour { public void newDay() { dayCount++; - Debug.Log("New day: " + dayCount); + dayCountTextMeshProUGUI.text = dayCount.ToString(); newDayEvent?.Invoke(); } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 9cf4716..2af46cb 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using TMPro; using UnityEngine; using UnityEngine.UIElements; using Cursor = UnityEngine.Cursor; @@ -21,14 +22,17 @@ public class PlayerController : MonoBehaviour { #endregion private Inventory _inventory; - public int money; + private int _money; private UsableItem _selectedItem; public int startMoney = 100; + public TextMeshProUGUI moneyTextMeshProUGUI; + + public int Money => _money; // Start is called before the first frame update private void Start() { - money = startMoney; + _money = startMoney; _inventory = Inventory.instance; } @@ -44,4 +48,9 @@ public class PlayerController : MonoBehaviour { public UsableItem GetSelectedItem() { return _selectedItem; } + + public void ChangeMoney(int amount) { + _money += amount; + moneyTextMeshProUGUI.text = amount + "µ"; + } } \ No newline at end of file diff --git a/Assets/Scripts/ShopSlot.cs b/Assets/Scripts/ShopSlot.cs index 7679618..4a2f3c1 100644 --- a/Assets/Scripts/ShopSlot.cs +++ b/Assets/Scripts/ShopSlot.cs @@ -76,13 +76,13 @@ public class ShopSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler * Gets called when the Shop Slot is clicked */ public void UseItem() { - if(_playerController.money >= item.cost) { + if(_playerController.Money >= item.cost) { _inventory.AddItem(item, 1); _shop.RemoveItem(item, 1); - _playerController.money -= item.cost; + _playerController.ChangeMoney(-item.cost); Debug.Log("Buying Item: " + item.displayName); - Debug.Log("money left: " + _playerController.money); + Debug.Log("money left: " + _playerController.Money); } else { Debug.Log("Not enough money to buy item."); } From 52fa93fc36374508a627fcb1b07d6c9b2afd4965 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Thu, 2 Jun 2022 14:58:47 +0200 Subject: [PATCH 2/5] Money and Day UI finished --- Assets/Scenes/MainScene.unity | 30 +++++++++++++++--------------- Assets/Scripts/PlayerController.cs | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index fe5e082..2e56e84 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -2712,7 +2712,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 68.54913, y: -22.5} + m_AnchoredPosition: {x: 66, y: -30} m_SizeDelta: {x: 115, y: 45} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &865947144 @@ -3796,10 +3796,10 @@ RectTransform: m_Father: {fileID: 1061398534} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -242.5, y: 202.5} - m_SizeDelta: {x: -515, y: -435} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 165, y: -45} + m_SizeDelta: {x: 300, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1070476669 MonoBehaviour: @@ -3874,8 +3874,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 85.08983, y: -22.25} - m_SizeDelta: {x: 53.6157, y: 44.5} + m_AnchoredPosition: {x: 180, y: -30} + m_SizeDelta: {x: 200, y: 45} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1089918735 MonoBehaviour: @@ -5271,8 +5271,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 90.6, y: -22.5} - m_SizeDelta: {x: 53.6157, y: 44.5} + m_AnchoredPosition: {x: 180, y: -30} + m_SizeDelta: {x: 200, y: 45} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1347709342 MonoBehaviour: @@ -6508,10 +6508,10 @@ RectTransform: m_Father: {fileID: 1061398534} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -242.5, y: 147.5} - m_SizeDelta: {x: -515, y: -435} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 165, y: -115} + m_SizeDelta: {x: 300, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1649897727 MonoBehaviour: @@ -7725,8 +7725,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 66.029, y: -22.5} - m_SizeDelta: {x: 115, y: 45} + m_AnchoredPosition: {x: 66, y: -30} + m_SizeDelta: {x: 115, y: 60} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2022611510 MonoBehaviour: diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2af46cb..3b3ab36 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -34,6 +34,7 @@ public class PlayerController : MonoBehaviour { private void Start() { _money = startMoney; _inventory = Inventory.instance; + moneyTextMeshProUGUI.text = _money + "µ"; } public void SetSelectedItem(UsableItem item) { @@ -51,6 +52,6 @@ public class PlayerController : MonoBehaviour { public void ChangeMoney(int amount) { _money += amount; - moneyTextMeshProUGUI.text = amount + "µ"; + moneyTextMeshProUGUI.text = _money + "µ"; } } \ No newline at end of file From ee6704abc1493acbf6ad9cfdd75ae264da52d8a9 Mon Sep 17 00:00:00 2001 From: dhain Date: Thu, 2 Jun 2022 15:08:21 +0200 Subject: [PATCH 3/5] added ItemStorage.cs, ItemStorageSlot.cs, ItemStorageUI.cs * Inventory, InventorySlot, InventoryUI, Shop, ShopSlot, ShopUI are extending them --- Assets/Scenes/MainScene.unity | 8 ++- Assets/Scripts/Inventory.cs | 43 ++-------------- Assets/Scripts/InventorySlot.cs | 69 +++----------------------- Assets/Scripts/InventoryUI.cs | 1 - Assets/Scripts/ItemStorage.cs | 46 +++++++++++++++++ Assets/Scripts/ItemStorage.cs.meta | 11 ++++ Assets/Scripts/ItemStorageSlot.cs | 68 +++++++++++++++++++++++++ Assets/Scripts/ItemStorageSlot.cs.meta | 11 ++++ Assets/Scripts/ItemStorageUI.cs | 55 ++++++++++++++++++++ Assets/Scripts/ItemStorageUI.cs.meta | 11 ++++ Assets/Scripts/Shop.cs | 44 +--------------- Assets/Scripts/ShopSlot.cs | 63 ++++------------------- Assets/Scripts/ShopUI.cs | 6 +-- 13 files changed, 231 insertions(+), 205 deletions(-) create mode 100644 Assets/Scripts/ItemStorage.cs create mode 100644 Assets/Scripts/ItemStorage.cs.meta create mode 100644 Assets/Scripts/ItemStorageSlot.cs create mode 100644 Assets/Scripts/ItemStorageSlot.cs.meta create mode 100644 Assets/Scripts/ItemStorageUI.cs create mode 100644 Assets/Scripts/ItemStorageUI.cs.meta diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index ee638aa..33531a0 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -4545,7 +4545,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &1291863650 MonoBehaviour: m_ObjectHideFlags: 0 @@ -5946,7 +5946,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bc5eb8967b8912c42b93a2086383ddd9, type: 3} m_Name: m_EditorClassIdentifier: - tempItems: + startItems: - {fileID: 11400000, guid: 008a8fdd2c3a95745acafee4087a855d, type: 2} - {fileID: 11400000, guid: 430db451ae959f34b8fba8d8b17276fd, type: 2} - {fileID: 11400000, guid: d651d57ba97a4246a0094409e29fe56a, type: 2} @@ -7738,6 +7738,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 1985691912} m_Modifications: + - target: {fileID: 5121261193055935939, guid: 2279fa2b47ef2ce40af9052d3a3f438b, type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: UseItem + objectReference: {fileID: 0} - target: {fileID: 5121261193055935940, guid: 2279fa2b47ef2ce40af9052d3a3f438b, type: 3} propertyPath: m_Pivot.x value: 0.5 diff --git a/Assets/Scripts/Inventory.cs b/Assets/Scripts/Inventory.cs index 4e9250e..f297705 100644 --- a/Assets/Scripts/Inventory.cs +++ b/Assets/Scripts/Inventory.cs @@ -1,7 +1,6 @@ -using System.Collections.Generic; using UnityEngine; -public class Inventory : MonoBehaviour { +public class Inventory : ItemStorage { #region Singleton public static Inventory instance; @@ -16,51 +15,17 @@ public class Inventory : MonoBehaviour { #endregion - public Dictionary items; - public Item[] startItems; public const int InventorySpace = 28; - /** - * Methods can be added to this and they will get called every time onItemChangedCallback gets Invoked - */ - public delegate void OnItemChanged(); - public OnItemChanged onItemChangedCallback; - - private void Start() { - items ??= new Dictionary(); - foreach(Item item in startItems) { - AddItem(item, 1); - } - } - /** * Adds the specified amount of items to the Inventory */ - public void AddItem(Item item, int amount) { + public override void AddItem(Item item, int amount) { if(items.Count >= InventorySpace) { Debug.Log("Not enough inventory space!"); return; } - - if(!items.ContainsKey(item)) { - items.Add(item, amount); - } else { - items[item] += amount; - } - - onItemChangedCallback?.Invoke(); - } - - /** - * Removes the specified amount of items in the Inventory - */ - public void RemoveItem(Item item, int amount) { - if(items[item] <= 0) { - items.Remove(item); - } else { - items[item] -= amount; - } - - onItemChangedCallback?.Invoke(); + + base.AddItem(item, amount); } } diff --git a/Assets/Scripts/InventorySlot.cs b/Assets/Scripts/InventorySlot.cs index d9a14ae..6aa5e43 100644 --- a/Assets/Scripts/InventorySlot.cs +++ b/Assets/Scripts/InventorySlot.cs @@ -1,72 +1,15 @@ -using System; -using System.Collections; -using TMPro; using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.UI; - -public class InventorySlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { - public Image icon; - public TextMeshProUGUI amountText; - - public Item _item; - - #region DescriptionHover - - public float timeToWait; - - public void OnPointerEnter(PointerEventData eventData) { - StopAllCoroutines(); - StartCoroutine(StartTimer()); - } - - public void OnPointerExit(PointerEventData eventData) { - StopAllCoroutines(); - HoverManager.onMouseExit(); - } - - private void ShowMessage() { - if(_item){ - HoverManager.onMouseHover(_item.description, Input.mousePosition); - } - } - - private IEnumerator StartTimer() { - yield return new WaitForSeconds(timeToWait); - - ShowMessage(); - } - - #endregion - - /** - * Sets the Item of the Inventory Slot - */ - public void AddItem(Item newItem) { - _item = newItem; - - icon.sprite = _item.defaultSprite; - icon.enabled = true; - } - - /** - * Clears the Inventory Slot - */ - public void ClearSlot() { - _item = null; - icon.sprite = null; - icon.enabled = false; - } +public class InventorySlot : ItemStorageSlot { /** * Gets called when the Inventory Slot is clicked */ - public void UseItem() { - if(_item.GetType() == typeof(UsableItem)) { - ((UsableItem) _item).Select(); - Debug.Log("using " + _item.displayName); + public override void UseItem() { + if(Item.GetType() == typeof(UsableItem)) { + ((UsableItem) Item).Select(); + Debug.Log("using " + Item.displayName); } else { - Debug.Log("Item not usable " + _item.displayName); + Debug.Log("Item not usable " + Item.displayName); } } } \ No newline at end of file diff --git a/Assets/Scripts/InventoryUI.cs b/Assets/Scripts/InventoryUI.cs index 94d4a02..ffe6660 100644 --- a/Assets/Scripts/InventoryUI.cs +++ b/Assets/Scripts/InventoryUI.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using UnityEngine; diff --git a/Assets/Scripts/ItemStorage.cs b/Assets/Scripts/ItemStorage.cs new file mode 100644 index 0000000..3b023ba --- /dev/null +++ b/Assets/Scripts/ItemStorage.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using UnityEngine; + +public class ItemStorage : MonoBehaviour { + public Dictionary items; + public Item[] startItems; + + /** + * Methods can be added to this and they will get called every time onItemChangedCallback gets Invoked + */ + public delegate void OnItemChanged(); + public OnItemChanged onItemChangedCallback; + + private void Start() { + items ??= new Dictionary(); + foreach(Item item in startItems) { + AddItem(item, 1); + } + } + + /** + * Adds the specified amount of items to the Item Storage + */ + public virtual void AddItem(Item item, int amount) { + if(!items.ContainsKey(item)) { + items.Add(item, amount); + } else { + items[item] += amount; + } + + onItemChangedCallback?.Invoke(); + } + + /** + * Removes the specified amount of items in the Item Storage + */ + public void RemoveItem(Item item, int amount) { + if(items[item] <= 0) { + items.Remove(item); + } else { + items[item] -= amount; + } + + onItemChangedCallback?.Invoke(); + } +} diff --git a/Assets/Scripts/ItemStorage.cs.meta b/Assets/Scripts/ItemStorage.cs.meta new file mode 100644 index 0000000..c2c179d --- /dev/null +++ b/Assets/Scripts/ItemStorage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 21c02dc661faff342aca965c68c2c13a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ItemStorageSlot.cs b/Assets/Scripts/ItemStorageSlot.cs new file mode 100644 index 0000000..f8c8f04 --- /dev/null +++ b/Assets/Scripts/ItemStorageSlot.cs @@ -0,0 +1,68 @@ +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +public class ItemStorageSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { + public Image icon; + public TextMeshProUGUI amountText; + + public Item Item => _item; + + private Item _item; + + #region DescriptionHover + + public float timeToWait; + + public void OnPointerEnter(PointerEventData eventData) { + StopAllCoroutines(); + StartCoroutine(StartTimer()); + } + + public void OnPointerExit(PointerEventData eventData) { + StopAllCoroutines(); + HoverManager.onMouseExit(); + } + + private void ShowMessage() { + if(_item){ + HoverManager.onMouseHover(_item.description, Input.mousePosition); + } + } + + private IEnumerator StartTimer() { + yield return new WaitForSeconds(timeToWait); + + ShowMessage(); + } + + #endregion + + /** + * Sets the Item of the Item Storage Slot + */ + public void AddItem(Item newItem) { + _item = newItem; + + icon.sprite = _item.defaultSprite; + icon.enabled = true; + } + + /** + * Clears the Item Storage Slot + */ + public virtual void ClearSlot() { + _item = null; + icon.sprite = null; + icon.enabled = false; + } + + /** + * Gets called when the Item Storage Slot is clicked + */ + public virtual void UseItem() { + } +} diff --git a/Assets/Scripts/ItemStorageSlot.cs.meta b/Assets/Scripts/ItemStorageSlot.cs.meta new file mode 100644 index 0000000..c571d3f --- /dev/null +++ b/Assets/Scripts/ItemStorageSlot.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b6f14e8c24660e04e9ceb50a7d8e659d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ItemStorageUI.cs b/Assets/Scripts/ItemStorageUI.cs new file mode 100644 index 0000000..25677d3 --- /dev/null +++ b/Assets/Scripts/ItemStorageUI.cs @@ -0,0 +1,55 @@ +using System.Linq; +using UnityEngine; + +public class ItemStorageUI : MonoBehaviour { + public Transform itemsParent; + public GameObject inventoryUI; + private Inventory _inventory; + private InventorySlot[] _slots; + + private void Start() { + // Get Inventory instance and add UpdateUI method to OnItemChanged delegate + _inventory = Inventory.instance; + _inventory.onItemChangedCallback += UpdateUI; + + // Add all InventorySlot GameObjects to _slots and turn off the Inventory UI + _slots = itemsParent.GetComponentsInChildren(); + ToggleInventory(); + + // Set the icon to not be a raycast target for the Description Hovering to work + foreach(InventorySlot slot in _slots) { + slot.icon.raycastTarget = false; + } + } + + private void Update() { + // When "Inventory" button is pressed turn on/off Inventory UI + if(Input.GetButtonDown("Inventory")) { + ToggleInventory(); + } + } + + /** + * Turn on/off the Inventory UI + */ + private void ToggleInventory() { + inventoryUI.SetActive(!inventoryUI.activeSelf); + } + + /** + * Is called when something in the Inventory UI should update + */ + private void UpdateUI() { + // Add all items to the correct slots and clear the ones where no item should be + for(int i = 0; i < _slots.Length; i++) { + if(i < _inventory.items.Count) { + _slots[i].AddItem(_inventory.items.ElementAt(i).Key); + if(_inventory.items[_inventory.items.ElementAt(i).Key] > 1) { + _slots[i].amountText.text = "" + _inventory.items[_inventory.items.ElementAt(i).Key]; + } + } else { + _slots[i].ClearSlot(); + } + } + } +} diff --git a/Assets/Scripts/ItemStorageUI.cs.meta b/Assets/Scripts/ItemStorageUI.cs.meta new file mode 100644 index 0000000..0cf565d --- /dev/null +++ b/Assets/Scripts/ItemStorageUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 21b91c5ff9ffa4d45a5e71b08b141657 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop.cs b/Assets/Scripts/Shop.cs index 32c2ef1..71c261a 100644 --- a/Assets/Scripts/Shop.cs +++ b/Assets/Scripts/Shop.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -public class Shop : MonoBehaviour { +public class Shop : ItemStorage { #region Singleton public static Shop instance; @@ -15,46 +15,4 @@ public class Shop : MonoBehaviour { } #endregion - - public Dictionary items; - public Item[] tempItems; - - /** - * Methods can be added to this and they will get called every time onItemChangedCallback gets Invoked - */ - public delegate void OnItemChanged(); - public OnItemChanged onItemChangedCallback; - - private void Start() { - items ??= new Dictionary(); - foreach(Item item in tempItems) { - AddItem(item, 1); - } - } - - /** - * Adds the specified amount of items to the Shop - */ - public void AddItem(Item item, int amount) { - if(!items.ContainsKey(item)) { - items.Add(item, amount); - } else { - items[item] += amount; - } - - onItemChangedCallback?.Invoke(); - } - // TODO: add to buy more than one item - /** - * Removes the specified amount of items in the Shop - */ - public void RemoveItem(Item item, int amount) { - if(items[item] <= 0) { - items.Remove(item); - } else { - items[item] -= amount; - } - - onItemChangedCallback?.Invoke(); - } } \ No newline at end of file diff --git a/Assets/Scripts/ShopSlot.cs b/Assets/Scripts/ShopSlot.cs index 7679618..e62d7a3 100644 --- a/Assets/Scripts/ShopSlot.cs +++ b/Assets/Scripts/ShopSlot.cs @@ -5,68 +5,25 @@ using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; -public class ShopSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler { - public Image icon; - public Item item; +public class ShopSlot : ItemStorageSlot { public TextMeshProUGUI nameText; public TextMeshProUGUI costText; - public TextMeshProUGUI amountText; - + private Shop _shop; private Inventory _inventory; private PlayerController _playerController; - - #region DescriptionHover - - public float timeToWait; - - public void OnPointerEnter(PointerEventData eventData) { - StopAllCoroutines(); - StartCoroutine(StartTimer()); - } - - public void OnPointerExit(PointerEventData eventData) { - StopAllCoroutines(); - HoverManager.onMouseExit(); - } - - private void ShowMessage() { - if(item) { - HoverManager.onMouseHover(item.description, Input.mousePosition); - } - } - - private IEnumerator StartTimer() { - yield return new WaitForSeconds(timeToWait); - - ShowMessage(); - } - - #endregion private void Start() { _shop = Shop.instance; _inventory = Inventory.instance; _playerController = PlayerController.instance; } - - /** - * Sets the Item of the Shop Slot - */ - public void AddItem(Item newItem) { - item = newItem; - - icon.sprite = item.defaultSprite; - icon.enabled = true; - } /** * Clears the Shop Slot */ - public void ClearSlot() { - item = null; - icon.sprite = null; - icon.enabled = false; + public override void ClearSlot() { + base.ClearSlot(); nameText.text = ""; costText.text = ""; amountText.text = ""; @@ -75,13 +32,13 @@ public class ShopSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler /** * Gets called when the Shop Slot is clicked */ - public void UseItem() { - if(_playerController.money >= item.cost) { - _inventory.AddItem(item, 1); - _shop.RemoveItem(item, 1); - _playerController.money -= item.cost; + public override void UseItem() { + if(_playerController.money >= Item.cost) { + _inventory.AddItem(Item, 1); + _shop.RemoveItem(Item, 1); + _playerController.money -= Item.cost; - Debug.Log("Buying Item: " + item.displayName); + Debug.Log("Buying Item: " + Item.displayName); Debug.Log("money left: " + _playerController.money); } else { Debug.Log("Not enough money to buy item."); diff --git a/Assets/Scripts/ShopUI.cs b/Assets/Scripts/ShopUI.cs index 00d7c2f..9e7a37f 100644 --- a/Assets/Scripts/ShopUI.cs +++ b/Assets/Scripts/ShopUI.cs @@ -20,8 +20,6 @@ public class ShopUI : MonoBehaviour { foreach(ShopSlot slot in _slots) { slot.icon.raycastTarget = false; } - - UpdateUI(); } private void Update() { @@ -46,8 +44,8 @@ public class ShopUI : MonoBehaviour { for(int i = 0; i < _slots.Length; i++) { if(i < _shop.items.Count) { _slots[i].AddItem(_shop.items.ElementAt(i).Key); - _slots[i].nameText.text = _slots[i].item.displayName; - _slots[i].costText.text = _slots[i].item.cost + " €"; + _slots[i].nameText.text = _slots[i].Item.displayName; + _slots[i].costText.text = _slots[i].Item.cost + " €"; _slots[i].amountText.text = _shop.items[_shop.items.ElementAt(i).Key] + " #"; } else { _slots[i].ClearSlot(); From 98b571c2aacfcb1c423aba32b48f2405385018cf Mon Sep 17 00:00:00 2001 From: dhain Date: Thu, 2 Jun 2022 15:10:31 +0200 Subject: [PATCH 4/5] merged with develop --- Assets/Scripts/ShopSlot.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/ShopSlot.cs b/Assets/Scripts/ShopSlot.cs index 3ce0d25..6c7855a 100644 --- a/Assets/Scripts/ShopSlot.cs +++ b/Assets/Scripts/ShopSlot.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections; using TMPro; using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.UI; public class ShopSlot : ItemStorageSlot { public TextMeshProUGUI nameText; @@ -32,13 +28,13 @@ public class ShopSlot : ItemStorageSlot { /** * Gets called when the Shop Slot is clicked */ - public void UseItem() { - if(_playerController.Money >= item.cost) { - _inventory.AddItem(item, 1); - _shop.RemoveItem(item, 1); - _playerController.ChangeMoney(-item.cost); + public override void UseItem() { + if(_playerController.Money >= Item.cost) { + _inventory.AddItem(Item, 1); + _shop.RemoveItem(Item, 1); + _playerController.ChangeMoney(-Item.cost); - Debug.Log("Buying Item: " + item.displayName); + Debug.Log("Buying Item: " + Item.displayName); Debug.Log("money left: " + _playerController.Money); } else { Debug.Log("Not enough money to buy item."); From f7b593045fc0faed63c8ce525329779162420bb1 Mon Sep 17 00:00:00 2001 From: d-hain Date: Fri, 3 Jun 2022 00:07:30 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=C2=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/BaseTile.prefab | 2 +- Assets/Scenes/MainScene.unity | 4 +- Assets/Scripts/ItemStorageUI.cs | 55 ---------------------------- Assets/Scripts/ItemStorageUI.cs.meta | 11 ------ Assets/Scripts/ShopUI.cs | 6 +-- Assets/Scripts/TileBehaviour.cs | 51 ++++++++++---------------- Assets/Scripts/TileController.cs | 35 ++++++------------ Packages/packages-lock.json | 13 ++++++- ProjectSettings/ProjectVersion.txt | 4 +- 9 files changed, 49 insertions(+), 132 deletions(-) delete mode 100644 Assets/Scripts/ItemStorageUI.cs delete mode 100644 Assets/Scripts/ItemStorageUI.cs.meta diff --git a/Assets/BaseTile.prefab b/Assets/BaseTile.prefab index d9d5305..06c92b4 100644 --- a/Assets/BaseTile.prefab +++ b/Assets/BaseTile.prefab @@ -75,7 +75,7 @@ SpriteRenderer: m_SortingLayerID: -2016319409 m_SortingLayer: 1 m_SortingOrder: 0 - m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} + m_Sprite: {fileID: 21300000, guid: 2700e06d970d112489ff23cfb58c3f78, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index a40f752..c2fb890 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -4906,7 +4906,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: menu: {fileID: 1395531174} - dayCountTextMeshProUGUI: {fileID: 1089918735} + dayCountTextMeshProUGUI: {fileID: 0} --- !u!212 &1278234715 SpriteRenderer: m_ObjectHideFlags: 0 @@ -5010,7 +5010,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tile: {fileID: 4752245148499717901, guid: ea81011a3ce83fb4386934728a92ee2d, type: 3} - CameraGameObject: {fileID: 598358736} + cameraGameObject: {fileID: 0} --- !u!4 &1291863651 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/ItemStorageUI.cs b/Assets/Scripts/ItemStorageUI.cs deleted file mode 100644 index 25677d3..0000000 --- a/Assets/Scripts/ItemStorageUI.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Linq; -using UnityEngine; - -public class ItemStorageUI : MonoBehaviour { - public Transform itemsParent; - public GameObject inventoryUI; - private Inventory _inventory; - private InventorySlot[] _slots; - - private void Start() { - // Get Inventory instance and add UpdateUI method to OnItemChanged delegate - _inventory = Inventory.instance; - _inventory.onItemChangedCallback += UpdateUI; - - // Add all InventorySlot GameObjects to _slots and turn off the Inventory UI - _slots = itemsParent.GetComponentsInChildren(); - ToggleInventory(); - - // Set the icon to not be a raycast target for the Description Hovering to work - foreach(InventorySlot slot in _slots) { - slot.icon.raycastTarget = false; - } - } - - private void Update() { - // When "Inventory" button is pressed turn on/off Inventory UI - if(Input.GetButtonDown("Inventory")) { - ToggleInventory(); - } - } - - /** - * Turn on/off the Inventory UI - */ - private void ToggleInventory() { - inventoryUI.SetActive(!inventoryUI.activeSelf); - } - - /** - * Is called when something in the Inventory UI should update - */ - private void UpdateUI() { - // Add all items to the correct slots and clear the ones where no item should be - for(int i = 0; i < _slots.Length; i++) { - if(i < _inventory.items.Count) { - _slots[i].AddItem(_inventory.items.ElementAt(i).Key); - if(_inventory.items[_inventory.items.ElementAt(i).Key] > 1) { - _slots[i].amountText.text = "" + _inventory.items[_inventory.items.ElementAt(i).Key]; - } - } else { - _slots[i].ClearSlot(); - } - } - } -} diff --git a/Assets/Scripts/ItemStorageUI.cs.meta b/Assets/Scripts/ItemStorageUI.cs.meta deleted file mode 100644 index 0cf565d..0000000 --- a/Assets/Scripts/ItemStorageUI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 21b91c5ff9ffa4d45a5e71b08b141657 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ShopUI.cs b/Assets/Scripts/ShopUI.cs index 9e7a37f..61a9050 100644 --- a/Assets/Scripts/ShopUI.cs +++ b/Assets/Scripts/ShopUI.cs @@ -6,12 +6,12 @@ public class ShopUI : MonoBehaviour { public GameObject shopUI; private Shop _shop; private ShopSlot[] _slots; - + private void Start() { // Get Shop instance and add UpdateUI method to OnItemChanged delegate _shop = Shop.instance; _shop.onItemChangedCallback += UpdateUI; - + // Add all ShopSlot GameObjects to _slots and turn off the Shop UI _slots = itemsParent.GetComponentsInChildren(); ToggleShop(); @@ -45,7 +45,7 @@ public class ShopUI : MonoBehaviour { if(i < _shop.items.Count) { _slots[i].AddItem(_shop.items.ElementAt(i).Key); _slots[i].nameText.text = _slots[i].Item.displayName; - _slots[i].costText.text = _slots[i].Item.cost + " €"; + _slots[i].costText.text = _slots[i].Item.cost + " µ"; _slots[i].amountText.text = _shop.items[_shop.items.ElementAt(i).Key] + " #"; } else { _slots[i].ClearSlot(); diff --git a/Assets/Scripts/TileBehaviour.cs b/Assets/Scripts/TileBehaviour.cs index 833bb10..96959d3 100644 --- a/Assets/Scripts/TileBehaviour.cs +++ b/Assets/Scripts/TileBehaviour.cs @@ -5,52 +5,39 @@ using Items.TerraformingTools; using Tiles; using UnityEngine; -public class TileBehaviour : MonoBehaviour -{ - private BaseTile tile; - +public class TileBehaviour : MonoBehaviour { + private BaseTile _tile; + // Start is called before the first frame update - void Start() - { + private void Start() { Debug.Log("Created"); SetTile(new GrassTile()); - - HouseController.NewDayEvent.AddListener(tile.DayLightStep); + + HouseController.NewDayEvent.AddListener(_tile.DayLightStep); } - // Update is called once per frame - void Update() - { - - } - - void OnMouseDown() - { + private void OnMouseDown() { Debug.Log("Clicked"); - + UsableItem usable = PlayerController.instance.GetSelectedItem(); BaseTile tileToSetTo = null; - if (usable.GetType() == typeof(TerraformingTool)) - { - TerraformingTool terraformingTool = (TerraformingTool) usable; + if(usable.GetType() == typeof(TerraformingTool)) { + TerraformingTool terraformingTool = (TerraformingTool)usable; Type tileTypeToSetTo = terraformingTool.TileType; - tileToSetTo = (BaseTile) Activator.CreateInstance(tileTypeToSetTo); - } - else - { - tileToSetTo = tile.Clicked(usable); + tileToSetTo = (BaseTile)Activator.CreateInstance(tileTypeToSetTo); + } else { + tileToSetTo = _tile.Clicked(usable); Debug.Log("AMOGUS " + tileToSetTo.ToString()); } - if (tileToSetTo != null) - { + + if(tileToSetTo != null) { SetTile(tileToSetTo); } } - void SetTile(BaseTile tileToSet) - { + private void SetTile(BaseTile tileToSet) { Debug.Log("Set tile to " + tileToSet.ToString()); - tile = tileToSet; - GetComponent().color = tile.getColor; // TODO: Change to Sprite + _tile = tileToSet; + GetComponent().color = _tile.getColor; // TODO: Change to Sprite } -} +} \ No newline at end of file diff --git a/Assets/Scripts/TileController.cs b/Assets/Scripts/TileController.cs index 5049d4b..6ab7008 100644 --- a/Assets/Scripts/TileController.cs +++ b/Assets/Scripts/TileController.cs @@ -3,38 +3,25 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class TileController : MonoBehaviour -{ +public class TileController : MonoBehaviour { public GameObject tile; - public GameObject CameraGameObject; - + public GameObject cameraGameObject; + // Start is called before the first frame update - void Start() - { - Camera camera = CameraGameObject.GetComponent(); - Vector3 screen = camera.ViewportToWorldPoint(new Vector3(1,1,camera.nearClipPlane)); + void Start() { + Camera camera = cameraGameObject.GetComponent(); + Vector3 screen = camera.ViewportToWorldPoint(new Vector3(1, 1, camera.nearClipPlane)); int x = Convert.ToInt32(Math.Ceiling(screen.x)); int y = Convert.ToInt32(Math.Ceiling(screen.y)); - + Debug.Log(screen); - for (int xx = -x; xx <= x; xx++) - { - for (int yy = -y; yy <= y; yy++) - { - if (tile != null) - { + for(int xx = -x; xx <= x; xx++) { + for(int yy = -y; yy <= y; yy++) { + if(tile != null) { Instantiate(tile, new Vector3(xx, yy, 0), Quaternion.identity); } } } } - - // Update is called once per frame - void Update() - { - - } - - -} +} \ No newline at end of file diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 4f0557e..40769bb 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -137,12 +137,21 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.nuget.newtonsoft-json": { + "version": "3.0.2", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.services.core": { - "version": "1.0.1", + "version": "1.3.1", "depth": 1, "source": "registry", "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0" + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.nuget.newtonsoft-json": "3.0.2", + "com.unity.modules.androidjni": "1.0.0" }, "url": "https://packages.unity.com" }, diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 90d6509..3dcb827 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2021.3.1f1 -m_EditorVersionWithRevision: 2021.3.1f1 (3b70a0754835) +m_EditorVersion: 2021.3.2f1 +m_EditorVersionWithRevision: 2021.3.2f1 (d6360bedb9a0)