diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 6ddf916..89d7df2 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -154,7 +154,7 @@ RectTransform: 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.1908, y: -6.7747} + m_AnchoredPosition: {x: 103.35, y: -6.7745} m_SizeDelta: {x: 563.871, y: 56.09} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &318397172 @@ -391,6 +391,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 423320530} m_CullTransparentMesh: 1 +--- !u!1 &449474137 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 449474138} + - component: {fileID: 449474140} + - component: {fileID: 449474139} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &449474138 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 449474137} + 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: 1308558881} + 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: -294.49, y: 2.4098} + m_SizeDelta: {x: 197.02, y: 219.18} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &449474139 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 449474137} + 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: 8361202218039602252, guid: aae15fbae448a1042ac4dd3fe0729e0a, type: 3} + m_Type: 0 + 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 &449474140 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 449474137} + m_CullTransparentMesh: 1 --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -1019,7 +1094,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Buy + m_text: 'Buy: $100.00' m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -1046,8 +1121,8 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 36 - m_fontSizeBase: 36 + m_fontSize: 28 + m_fontSizeBase: 28 m_fontWeight: 400 m_enableAutoSizing: 0 m_fontSizeMin: 18 @@ -1134,7 +1209,7 @@ RectTransform: 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: -199, y: -71} + m_AnchoredPosition: {x: -97.86023, y: -71} m_SizeDelta: {x: 166.254, y: 72.3619} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1130218634 @@ -1267,8 +1342,8 @@ RectTransform: 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: 204, y: -71} - m_SizeDelta: {x: 166.254, y: 72.3619} + m_AnchoredPosition: {x: 253, y: -71} + m_SizeDelta: {x: 270.5336, y: 72.3619} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1143714944 MonoBehaviour: @@ -1400,12 +1475,13 @@ RectTransform: - {fileID: 1130218633} - {fileID: 2115714079} - {fileID: 318397171} + - {fileID: 449474138} m_Father: {fileID: 663531050} 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: -561, y: 236} - m_SizeDelta: {x: 595.46875, y: 244.61829} + m_AnchoredPosition: {x: -461.9568, y: 239} + m_SizeDelta: {x: 805.3823, y: 244.6183} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1308558882 MonoBehaviour: @@ -1458,7 +1534,13 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: gameManager: {fileID: 366304914} + BaseStorePrice: 1 + PriceMultiplier: 1.1 + StoreProfit: 0.5 + StoreReset: 4 + ManagerOpen: 1 StoreCountText: {fileID: 2115714080} + BuyButton: {fileID: 1143714944} StoreSlider: {fileID: 318397172} --- !u!1 &1633529897 GameObject: @@ -1569,8 +1651,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0.3089981} - m_SizeDelta: {x: 0, y: 101.3477} + m_AnchoredPosition: {x: 103.35437, y: 0.3089981} + m_SizeDelta: {x: -206.7088, y: 101.3477} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1811417437 MonoBehaviour: @@ -1592,7 +1674,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Lemonade Stand + m_text: Alchemy Stand m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -1705,8 +1787,8 @@ RectTransform: 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.0000063181, y: -71} - m_SizeDelta: {x: 199.0163, y: 72.361} + m_AnchoredPosition: {x: 51.38577, y: -71} + m_SizeDelta: {x: 99.508, y: 72.361} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2115714080 MonoBehaviour: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index be24feb..b202f9c 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -6,8 +6,8 @@ using UnityEngine; public class GameManager : MonoBehaviour { #region GameManager - private decimal _currentBalance = 1.00M; - public decimal CurrentBalance { get => _currentBalance; set => _currentBalance = value; } + private float _currentBalance = 1.00f; + public float CurrentBalance { get => _currentBalance; set => _currentBalance = value; } [SerializeField] private TextMeshProUGUI BalanceText; @@ -27,13 +27,13 @@ public class GameManager : MonoBehaviour } - public void AddToBalance(decimal amount) + public void AddToBalance(float amount) { CurrentBalance += amount; BalanceText.text = String.Format("$ {0:C2}", CurrentBalance.ToString()); } - public void SubtractFromBalance(decimal amount) + public void SubtractFromBalance(float amount) { if(CurrentBalance < amount) { @@ -44,7 +44,7 @@ public class GameManager : MonoBehaviour BalanceText.text = String.Format("$ {0:C2}", CurrentBalance.ToString()); } - public bool CanAfford(decimal amount) + public bool CanAfford(float amount) { return CurrentBalance >= amount; } diff --git a/Assets/Scripts/Store.cs b/Assets/Scripts/Store.cs index 4a41bb7..102ab60 100644 --- a/Assets/Scripts/Store.cs +++ b/Assets/Scripts/Store.cs @@ -1,3 +1,5 @@ +using System; + using TMPro; using UnityEngine; using UnityEngine.UI; @@ -6,6 +8,25 @@ public class Store : MonoBehaviour { [SerializeField] private GameManager gameManager; + + [Header("Store Settings")] + [SerializeField] + [Tooltip("Base price of store")] + private float BaseStorePrice = 1.00f; + [SerializeField] + [Tooltip("Amount that the Price multiplies for each store purchase")] + private float PriceMultiplier = 1.10f; + [SerializeField] + [Tooltip("Profit made by store per reset")] + private float StoreProfit = 0.50f; + [SerializeField] + [Tooltip("Time in seconds until store makes a profit")] + private float StoreReset = 4.0f; + [SerializeField] + [Tooltip("Turns on/off the store manager")] + private bool ManagerOpen = false; + + [Header("Store UI")] [SerializeField] private TextMeshProUGUI StoreCountText; [SerializeField] @@ -14,19 +35,20 @@ public class Store : MonoBehaviour private Slider StoreSlider; private int StoreCount = 0; - private decimal BaseStorePrice = 1.00M; - private decimal StoreProfit = 0.50M; - - private float StoreReset = 4.0f; private float StoreTime = 0.0f; + private float NextStorePrice = 0.0f; + private TextMeshProUGUI BuyButtonText; bool StoreOpen = false; - + // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { - StoreCountText.text = StoreCount.ToString(); - + + NextStorePrice = BaseStorePrice; + BuyButtonText = BuyButton.GetComponentInChildren(); + BuyButtonText.text = String.Format("Buy: {0:C2}", NextStorePrice); + StoreCountText.text = StoreCount.ToString(); } // Update is called once per frame @@ -37,14 +59,17 @@ public class Store : MonoBehaviour StoreTime += Time.deltaTime; if (StoreTime >= StoreReset) { - StoreOpen = false; + if (!ManagerOpen) + { + StoreOpen = false; + } StoreTime = 0.0f; gameManager.AddToBalance(StoreProfit * StoreCount); } } StoreSlider.value = StoreTime / StoreReset; - if(gameManager.CanAfford(BaseStorePrice)) + if(gameManager.CanAfford(NextStorePrice)) { BuyButton.interactable = true; } @@ -52,10 +77,12 @@ public class Store : MonoBehaviour public void Buy() { - gameManager.SubtractFromBalance(BaseStorePrice); StoreCount++; - StoreCountText.text = StoreCount.ToString(); - if(!gameManager.CanAfford(BaseStorePrice)) + StoreCountText.text = StoreCount.ToString(); + NextStorePrice = BaseStorePrice * Mathf.Pow(PriceMultiplier, StoreCount); + BuyButtonText.text = String.Format("Buy: {0:C2}", NextStorePrice); + gameManager.SubtractFromBalance(NextStorePrice); + if (!gameManager.CanAfford(NextStorePrice)) { BuyButton.interactable = false; } @@ -63,8 +90,7 @@ public class Store : MonoBehaviour public void OpenStore() { - StoreOpen = true; - + StoreOpen = true; } } diff --git a/Assets/alchemy_stand__00008_.png b/Assets/alchemy_stand__00008_.png new file mode 100644 index 0000000..548329b Binary files /dev/null and b/Assets/alchemy_stand__00008_.png differ diff --git a/Assets/alchemy_stand__00008_.png.meta b/Assets/alchemy_stand__00008_.png.meta new file mode 100644 index 0000000..4421ea7 --- /dev/null +++ b/Assets/alchemy_stand__00008_.png.meta @@ -0,0 +1,142 @@ +fileFormatVersion: 2 +guid: aae15fbae448a1042ac4dd3fe0729e0a +TextureImporter: + internalIDToNameTable: + - first: + 213: 8361202218039602252 + second: alchemy_stand__00008__0 + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 2 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: + - serializedVersion: 2 + name: alchemy_stand__00008__0 + rect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1024 + height: 1024 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + customData: + outline: [] + physicsShape: [] + tessellationDetail: -1 + bones: [] + spriteID: c4c65752e15f80470800000000000000 + internalID: 8361202218039602252 + vertices: [] + indices: + edges: [] + weights: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: