From 28fdf318d33d102e8e9a1ba304957712049ece9c Mon Sep 17 00:00:00 2001 From: Ader Alisma 01 Date: Fri, 26 May 2023 18:58:36 -0400 Subject: [PATCH] Changer le comportement de ResourceMaker et ajout de commentaires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ResourceMaker sera utilisé pour géré la création de mini ressources cliquables dans une autre tâche. ResourceRemover change le texte en vert si les ressources nécessaires sont disponibles ou en rouge dans le cas contraire. --- Assets/Scenes/TestResource.unity | 569 +++++++++++++++--------------- Assets/Scripts/ResourceMaker.cs | 41 +-- Assets/Scripts/ResourceManager.cs | 75 +--- Assets/Scripts/ResourceRemover.cs | 12 +- Assets/Scripts/ResourceText.cs | 4 +- 5 files changed, 320 insertions(+), 381 deletions(-) diff --git a/Assets/Scenes/TestResource.unity b/Assets/Scenes/TestResource.unity index b1bb934..da9565a 100644 --- a/Assets/Scenes/TestResource.unity +++ b/Assets/Scenes/TestResource.unity @@ -536,10 +536,11 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 370108781} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 68, y: -63.38066, z: -0.25568116} + m_LocalPosition: {x: 320, y: -63.38066, z: -0.25568116} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 1058911776} - {fileID: 1401568135} m_Father: {fileID: 1565302173} m_RootOrder: 3 @@ -667,7 +668,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Place Unit + m_text: Use resource m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -744,155 +745,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 716208795} m_CullTransparentMesh: 1 ---- !u!1 &737126673 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 737126674} - - component: {fileID: 737126678} - - component: {fileID: 737126677} - - component: {fileID: 737126676} - - component: {fileID: 737126675} - m_Layer: 5 - m_Name: AddWoodButton - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &737126674 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 737126673} - 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: 1140115652} - m_Father: {fileID: 1907038142} - m_RootOrder: 1 - 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: 19, y: -56} - m_SizeDelta: {x: 194.7697, y: 40.4309} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &737126675 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 737126673} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 9dd6bad38b516d64e8e23a5822ca37bb, type: 3} - m_Name: - m_EditorClassIdentifier: - _resourceMakingAmount: 5 - _resourceChoice: 1 ---- !u!114 &737126676 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 737126673} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 737126677} - m_OnClick: - m_PersistentCalls: - m_Calls: - - m_Target: {fileID: 737126675} - m_TargetAssemblyTypeName: ResourceMaker, Assembly-CSharp - m_MethodName: GenerateResource - m_Mode: 1 - m_Arguments: - m_ObjectArgument: {fileID: 0} - m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 0 - m_FloatArgument: 0 - m_StringArgument: - m_BoolArgument: 0 - m_CallState: 2 ---- !u!114 &737126677 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 737126673} - 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: 10905, guid: 0000000000000000f000000000000000, type: 0} - 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 &737126678 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 737126673} - m_CullTransparentMesh: 1 --- !u!1 &875029258 GameObject: m_ObjectHideFlags: 0 @@ -1029,6 +881,141 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 875029258} m_CullTransparentMesh: 1 +--- !u!1 &1058911775 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1058911776} + - component: {fileID: 1058911778} + - component: {fileID: 1058911777} + m_Layer: 5 + m_Name: Explication + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1058911776 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1058911775} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0.25568116} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 370108782} + 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: -346, y: 7} + m_SizeDelta: {x: 339.2007, y: 67.8177} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1058911777 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1058911775} + 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: "Retire la quantit\xE9 sp\xE9cifi\xE9e de ressource" + 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: 23.07 + m_fontSizeBase: 23.07 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + 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 &1058911778 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1058911775} + m_CullTransparentMesh: 1 --- !u!1 &1058966274 GameObject: m_ObjectHideFlags: 0 @@ -1164,141 +1151,6 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1058966274} m_CullTransparentMesh: 1 ---- !u!1 &1140115651 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1140115652} - - component: {fileID: 1140115654} - - component: {fileID: 1140115653} - m_Layer: 5 - m_Name: Text (TMP) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1140115652 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1140115651} - 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: 737126674} - 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: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &1140115653 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1140115651} - 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: Generate Wood - 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: 4281479730 - m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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: 24 - m_fontSizeBase: 24 - m_fontWeight: 400 - m_enableAutoSizing: 0 - m_fontSizeMin: 18 - m_fontSizeMax: 72 - m_fontStyle: 0 - m_HorizontalAlignment: 2 - 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 &1140115654 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1140115651} - m_CullTransparentMesh: 1 --- !u!1 &1370974364 GameObject: m_ObjectHideFlags: 0 @@ -1536,7 +1388,7 @@ RectTransform: m_Children: - {fileID: 716208796} m_Father: {fileID: 370108782} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -1555,8 +1407,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: adc0c9da23034d342aec05775f0bd941, type: 3} m_Name: m_EditorClassIdentifier: - _rock: 15 - _wood: 15 + _rock: 10 + _wood: 10 _food: 0 _text: {fileID: 716208797} --- !u!114 &1401568137 @@ -1687,7 +1539,7 @@ RectTransform: m_Children: - {fileID: 2060845925} m_Father: {fileID: 1907038142} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -2178,6 +2030,141 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1749347598} m_CullTransparentMesh: 1 +--- !u!1 &1873648824 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873648825} + - component: {fileID: 1873648827} + - component: {fileID: 1873648826} + m_Layer: 5 + m_Name: Explication + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1873648825 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873648824} + 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: 1907038142} + 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: 30, y: -135} + m_SizeDelta: {x: 339.2007, y: 67.8177} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1873648826 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873648824} + 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: "G\xE9n\xE8re la quantit\xE9 sp\xE9cifi\xE9e de la ressource choisie" + 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: 23.07 + m_fontSizeBase: 23.07 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + 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 &1873648827 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873648824} + m_CullTransparentMesh: 1 --- !u!1 &1907038141 GameObject: m_ObjectHideFlags: 0 @@ -2206,8 +2193,8 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 1873648825} - {fileID: 1471040130} - - {fileID: 737126674} m_Father: {fileID: 1565302173} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/ResourceMaker.cs b/Assets/Scripts/ResourceMaker.cs index f1b6e57..5f2898c 100644 --- a/Assets/Scripts/ResourceMaker.cs +++ b/Assets/Scripts/ResourceMaker.cs @@ -1,15 +1,15 @@ using System.Collections; -using System.Collections.Generic; using UnityEngine; - +/// +/// Gère la production de ressource et sert de minuteur pour laisser la ressource sur le sol. +/// public class ResourceMaker : MonoBehaviour { [SerializeField] private int _resourceMakingAmount; [SerializeField] private ResourceChoice _resourceChoice; - - private ResourceManager _resourceManager; + private bool _generatingResources = true; private enum ResourceChoice { Rock, @@ -19,38 +19,39 @@ public class ResourceMaker : MonoBehaviour private void Start() { - _resourceManager = ResourceManager.Instance; + //StartCoroutine(Generate()); } + /// + /// D'après le choix de resource à générer, choisi le prefab à instancier + /// public void GenerateResource() { switch (_resourceChoice) { case ResourceChoice.Rock: - _resourceManager.RockGenerationAmount(_resourceMakingAmount,ResourceManager.AddOrRemove.Add); break; case ResourceChoice.Wood: - _resourceManager.WoodGenerationAmount(_resourceMakingAmount, ResourceManager.AddOrRemove.Add); break; case ResourceChoice.Food: - _resourceManager.FoodGenerationAmount(_resourceMakingAmount, ResourceManager.AddOrRemove.Add); break; } } + private IEnumerator Generate() + { + while (_generatingResources) + { + + Debug.Log("Generating..."); + + yield return new WaitForSeconds(3f); + } + } + private void OnDestroy() { - switch (_resourceChoice) - { - case ResourceChoice.Rock: - _resourceManager.RockGenerationAmount(_resourceMakingAmount, ResourceManager.AddOrRemove.Remove); - break; - case ResourceChoice.Wood: - _resourceManager.WoodGenerationAmount(_resourceMakingAmount, ResourceManager.AddOrRemove.Remove); - break; - case ResourceChoice.Food: - _resourceManager.FoodGenerationAmount(_resourceMakingAmount, ResourceManager.AddOrRemove.Remove); - break; - } + _generatingResources = false; + StopCoroutine(Generate()); } } diff --git a/Assets/Scripts/ResourceManager.cs b/Assets/Scripts/ResourceManager.cs index a2b8eaf..978905e 100644 --- a/Assets/Scripts/ResourceManager.cs +++ b/Assets/Scripts/ResourceManager.cs @@ -7,13 +7,9 @@ using System.Collections; public class ResourceManager : MonoBehaviour { private static ResourceManager _instance = null; - private int _rockAmount = 0; - private int _woodAmount = 0; - private int _foodAmount = 0; - private int _rockGenerationAmount = 0; - private int _woodGenerationAmount = 0; - private int _foodGenerationAmount = 0; - private bool _generatingResources = true; + private int _rockAmount = 20; + private int _woodAmount = 20; + private int _foodAmount = 20; public enum AddOrRemove { @@ -42,7 +38,6 @@ public class ResourceManager : MonoBehaviour else { _instance = this; - StartCoroutine(Generate()); } } @@ -79,73 +74,23 @@ public class ResourceManager : MonoBehaviour } get { return _foodAmount; } } - public void RockGenerationAmount(int amount, AddOrRemove choice) - { - if (choice == AddOrRemove.Add) - { - _rockAmount += amount; - } - else - { - _rockAmount -= amount; - } - } - public void WoodGenerationAmount(int amount, AddOrRemove choice) - { - if (choice == AddOrRemove.Add) - { - _woodAmount += amount; - } - else - { - _woodAmount -= amount; - } - } - public void FoodGenerationAmount(int amount, AddOrRemove choice) - { - if( choice == AddOrRemove.Add) - { - _foodAmount += amount; - } - else - { - _foodAmount -= amount; - } - } public void Remove(int rock, int wood, int food) { - _rockAmount = _rockAmount - rock < MIN ? MIN : _rockAmount - rock; - _rockAmount = _rockAmount - wood < MIN ? MIN : _rockAmount - wood; - _foodAmount = _foodAmount - food < MIN ? MIN : _foodAmount - food; + _rockAmount = (_rockAmount - rock) < MIN ? MIN : _rockAmount - rock; + _woodAmount = (_woodAmount - wood) < MIN ? MIN : _woodAmount - wood; + _foodAmount = (_foodAmount - food) < MIN ? MIN : _foodAmount - food; } public bool EnoughFor(int rock, int wood, int food = 0) { - if (rock > _rockAmount || wood > _woodAmount || food > _foodAmount) + if (_rockAmount >= rock && _woodAmount >= wood && _foodAmount >= food) { - return false; + return true; } - return true; + return false; } - private IEnumerator Generate() - { - while (_generatingResources) - { - _rockAmount = _rockGenerationAmount; - _woodAmount = _woodGenerationAmount; - _foodAmount = _foodGenerationAmount; - Debug.Log("Generating..."); - - yield return new WaitForSeconds(3f); - } - } - - private void OnDestroy() - { - _generatingResources = false; - StopCoroutine(Generate()); - } + } diff --git a/Assets/Scripts/ResourceRemover.cs b/Assets/Scripts/ResourceRemover.cs index 71bc7be..0d8098b 100644 --- a/Assets/Scripts/ResourceRemover.cs +++ b/Assets/Scripts/ResourceRemover.cs @@ -4,6 +4,11 @@ using UnityEngine; using UnityEngine.UIElements; using TMPro; +/// +/// Gère le retrait de ressources et l'état du bouton +/// Si les ressources nécessaires sont atteints, ce script change la disponibilité du bouton +/// et vice-versa +/// public class ResourceRemover : MonoBehaviour { @@ -35,17 +40,16 @@ public class ResourceRemover : MonoBehaviour private void ChangeAvailability() { - //checks if player has enough resources then chooses state of button's availability - + //checks if player has enough resources then changes the state of button's availability if (_resourceManager.EnoughFor(_rock, _wood, _food)) { - if (_text.color == Color.red) + if (_text.color != Color.green) { _text.color = Color.green; Debug.Log("Changed to green..."); } } - else if (_text.color == Color.green) + else if (_text.color != Color.red) { _text.color = Color.red; Debug.Log("Changed to red..."); diff --git a/Assets/Scripts/ResourceText.cs b/Assets/Scripts/ResourceText.cs index e19c23c..a3131eb 100644 --- a/Assets/Scripts/ResourceText.cs +++ b/Assets/Scripts/ResourceText.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using UnityEngine; using TMPro; - +/// +/// Gère l'affichage des resources +/// public class ResourceText : MonoBehaviour { [SerializeField]