From 487c0fabae649fb304002151d1a3da21da95454a Mon Sep 17 00:00:00 2001 From: Vova <3emaster@gmail.com> Date: Wed, 6 Dec 2023 14:55:20 +0200 Subject: [PATCH] add areaname --- Assets/Scenes/City_new.unity | 307 ++++++++++++++++-- Assets/Scripts/Helpers/Enums.cs | 2 +- .../Scripts/InteractableObjects/AreaName.cs | 20 ++ .../InteractableObjects/AreaName.cs.meta | 2 + Assets/Scripts/InteractableObjects/Fridge.cs | 3 +- Assets/Scripts/Interfaces.meta | 8 + Assets/Scripts/Interfaces/IStat.cs | 31 ++ Assets/Scripts/Interfaces/IStat.cs.meta | 2 + Assets/Scripts/Managers/MouseInputManager.cs | 7 +- .../Player/{Stat.cs => NumericStat.cs} | 10 +- .../{Stat.cs.meta => NumericStat.cs.meta} | 0 Assets/Scripts/Player/Player.cs | 28 +- Assets/Scripts/Player/PlayerStats.cs | 16 +- Assets/Scripts/Player/StringStat.cs | 18 + Assets/Scripts/Player/StringStat.cs.meta | 2 + Assets/Scripts/UIElements/TopBarUI.cs | 12 +- 16 files changed, 408 insertions(+), 60 deletions(-) create mode 100644 Assets/Scripts/InteractableObjects/AreaName.cs create mode 100644 Assets/Scripts/InteractableObjects/AreaName.cs.meta create mode 100644 Assets/Scripts/Interfaces.meta create mode 100644 Assets/Scripts/Interfaces/IStat.cs create mode 100644 Assets/Scripts/Interfaces/IStat.cs.meta rename Assets/Scripts/Player/{Stat.cs => NumericStat.cs} (75%) rename Assets/Scripts/Player/{Stat.cs.meta => NumericStat.cs.meta} (100%) create mode 100644 Assets/Scripts/Player/StringStat.cs create mode 100644 Assets/Scripts/Player/StringStat.cs.meta diff --git a/Assets/Scenes/City_new.unity b/Assets/Scenes/City_new.unity index 6b182a8e..670995f4 100644 --- a/Assets/Scenes/City_new.unity +++ b/Assets/Scenes/City_new.unity @@ -827,12 +827,12 @@ RectTransform: m_Children: - {fileID: 1563406277} - {fileID: 908315046} - m_Father: {fileID: 1803835668} + m_Father: {fileID: 1003929999} 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: 50} + m_SizeDelta: {x: 0, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &127585889 MonoBehaviour: @@ -853,7 +853,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 127585887} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3} m_Name: @@ -1227,7 +1227,7 @@ RectTransform: 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_AnchoredPosition: {x: 250, y: 0} m_SizeDelta: {x: 480, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &249161732 @@ -1661,6 +1661,178 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 349281312} m_CullTransparentMesh: 1 +--- !u!1 &352700050 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 352700051} + m_Layer: 5 + m_Name: LocationName + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &352700051 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 352700050} + 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: 395272925} + m_Father: {fileID: 1803835668} + 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: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &395272924 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 395272925} + - component: {fileID: 395272927} + - component: {fileID: 395272926} + m_Layer: 5 + m_Name: Title + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &395272925 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 395272924} + 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: 352700051} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 300.628, y: 0} + m_SizeDelta: {x: 601.255, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &395272926 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 395272924} + 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: Location name + 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: 26.85 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + 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_TextWrappingMode: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_ActiveFontFeatures: 6e72656b + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_EmojiFallbackSupport: 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: -1.1415405, 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 &395272927 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 395272924} + m_CullTransparentMesh: 1 --- !u!1 &464115411 GameObject: m_ObjectHideFlags: 0 @@ -2745,7 +2917,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 749553635} serializedVersion: 2 - m_LocalRotation: {x: 0.26693356, y: 0.000000028720944, z: -0.00000000795524, w: 0.96371496} + m_LocalRotation: {x: 0.2669336, y: 3.4238033e-15, z: -1.836517e-15, w: 0.96371496} m_LocalPosition: {x: 29.11, y: 3, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -3060,7 +3232,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 835327588} serializedVersion: 2 - m_LocalRotation: {x: 0.26693356, y: 0.000000028720944, z: -0.00000000795524, w: 0.96371496} + m_LocalRotation: {x: 0.2669336, y: 3.4238033e-15, z: -1.836517e-15, w: 0.96371496} m_LocalPosition: {x: 29.11, y: 3, z: -5} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 @@ -3100,9 +3272,9 @@ RectTransform: m_Children: [] m_Father: {fileID: 127585888} 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_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 200, y: 0} m_SizeDelta: {x: 207.17, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &908315047 @@ -3339,28 +3511,56 @@ GameObject: type: 3} m_PrefabInstance: {fileID: 1291994925} m_PrefabAsset: {fileID: 0} ---- !u!95 &978326309 -Animator: - serializedVersion: 7 +--- !u!136 &978326313 +CapsuleCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 978326308} - m_Enabled: 0 - m_Avatar: {fileID: 9000000, guid: 32790d47acc86814982f18993097a759, type: 3} - m_Controller: {fileID: 9100000, guid: 6abd17ae3669e8d448186fd24a2aadb7, type: 2} - m_CullingMode: 0 - m_UpdateMode: 0 - m_ApplyRootMotion: 0 - m_LinearVelocityBlending: 0 - m_StabilizeFeet: 0 - m_AnimatePhysics: 0 - m_WarningMessage: - m_HasTransformHierarchy: 1 - m_AllowConstantClipSamplingOptimization: 1 - m_KeepAnimatorStateOnDisable: 0 - m_WriteDefaultValuesOnDisable: 0 + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.38 + m_Height: 1.8 + m_Direction: 1 + m_Center: {x: 0, y: 0.95, z: 0} +--- !u!54 &978326314 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 978326308} + serializedVersion: 4 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_CenterOfMass: {x: 0, y: 0, z: 0} + m_InertiaTensor: {x: 1, y: 1, z: 1} + m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ImplicitCom: 1 + m_ImplicitTensor: 1 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 --- !u!1 &1003929998 GameObject: m_ObjectHideFlags: 0 @@ -3392,6 +3592,7 @@ RectTransform: m_Children: - {fileID: 1982938600} - {fileID: 149740872} + - {fileID: 127585888} m_Father: {fileID: 1803835668} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -3588,7 +3789,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 355.0478, y: 30} + m_SizeDelta: {x: 400, y: 30} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1062897588 MonoBehaviour: @@ -4073,7 +4274,11 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 3284961431740112554, guid: c0021857f236ae341a3c917b9da4dfaf, type: 3} insertIndex: -1 - addedObject: {fileID: 978326309} + addedObject: {fileID: 978326313} + - targetCorrespondingSourceObject: {fileID: 3284961431740112554, guid: c0021857f236ae341a3c917b9da4dfaf, + type: 3} + insertIndex: -1 + addedObject: {fileID: 978326314} - targetCorrespondingSourceObject: {fileID: 2402651526520908900, guid: c0021857f236ae341a3c917b9da4dfaf, type: 3} insertIndex: -1 @@ -4397,6 +4602,8 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1455074789} + - component: {fileID: 1455074790} + - component: {fileID: 1455074791} m_Layer: 3 m_Name: CentralAve m_TagString: Untagged @@ -4431,6 +4638,40 @@ Transform: - {fileID: 535029579} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &1455074790 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1455074788} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 80, y: 4, z: 29.34} + m_Center: {x: -30, y: 1.66, z: 0} +--- !u!114 &1455074791 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1455074788} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 18f0e472918ce7a41898514f037c380d, type: 3} + m_Name: + m_EditorClassIdentifier: + _areaName: Central ave. --- !u!1 &1492792593 GameObject: m_ObjectHideFlags: 0 @@ -4710,11 +4951,11 @@ RectTransform: m_Children: [] m_Father: {fileID: 127585888} 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_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 40, y: 0} m_SizeDelta: {x: 60, y: 30} - m_Pivot: {x: 0, y: 1} + m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1563406278 MonoBehaviour: m_ObjectHideFlags: 0 @@ -10039,7 +10280,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1003929999} - - {fileID: 127585888} + - {fileID: 352700051} - {fileID: 9988970} m_Father: {fileID: 311736548} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/Helpers/Enums.cs b/Assets/Scripts/Helpers/Enums.cs index d4eac345..6be95d32 100644 --- a/Assets/Scripts/Helpers/Enums.cs +++ b/Assets/Scripts/Helpers/Enums.cs @@ -3,7 +3,7 @@ public enum JobPositions { Unemployed, Cashier, Clerk, ManagerAssistaint, Manager }; public enum EducationSkill { NotEducated, School, HightSchool, University }; public enum PlayerStates { Awake, Sleeping, Eating, Working } -public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job, } +public enum StatsId { Money, RentAccount, Food, Energy, BankAccount, Job,LocationName } public enum Tasks { Move, Interact, Rotate }; public enum TaskStatus { Waiting, InProgress, Complete }; public enum InteractionStatus { None,Complete, WaitForChoose, InProgress, FarFromPlayer }; diff --git a/Assets/Scripts/InteractableObjects/AreaName.cs b/Assets/Scripts/InteractableObjects/AreaName.cs new file mode 100644 index 00000000..6424602a --- /dev/null +++ b/Assets/Scripts/InteractableObjects/AreaName.cs @@ -0,0 +1,20 @@ +using Assets.Scripts.Interfaces; +using UnityEngine; + +public class AreaName : MonoBehaviour +{ + [SerializeField] + private string _areaName; + + private void OnTriggerEnter(Collider other) + { + if(other.gameObject.tag.ToLower()=="player") + { + (Player.Instance.Stats[StatsId.LocationName] as IStringStat).SetValue(_areaName); + } + } + + private void OnTriggerStay(Collider other) + { + } +} diff --git a/Assets/Scripts/InteractableObjects/AreaName.cs.meta b/Assets/Scripts/InteractableObjects/AreaName.cs.meta new file mode 100644 index 00000000..90ef716b --- /dev/null +++ b/Assets/Scripts/InteractableObjects/AreaName.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 18f0e472918ce7a41898514f037c380d \ No newline at end of file diff --git a/Assets/Scripts/InteractableObjects/Fridge.cs b/Assets/Scripts/InteractableObjects/Fridge.cs index 8af81ba3..787329ac 100644 --- a/Assets/Scripts/InteractableObjects/Fridge.cs +++ b/Assets/Scripts/InteractableObjects/Fridge.cs @@ -1,4 +1,5 @@ +using Assets.Scripts.Interfaces; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -49,7 +50,7 @@ public class Fridge : BaseInteractableObject Debug.Log($"Fridge is full"); break; case RadialMenuActions.Eat: - var hunger = _player.Stats[StatsId.Food].MaxValue - _player.Stats[StatsId.Food].Value; + var hunger = (_player.Stats[StatsId.Food] as INumericStat).MaxValue - (_player.Stats[StatsId.Food] as INumericStat).Value; var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10); StartCoroutine(EatRoutine(eatingItems)); _foodObjects.RemoveRange(0, (int)eatingItems); diff --git a/Assets/Scripts/Interfaces.meta b/Assets/Scripts/Interfaces.meta new file mode 100644 index 00000000..8a2afe08 --- /dev/null +++ b/Assets/Scripts/Interfaces.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a9e1a72e46f47a4b886261f13a9b9e6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Interfaces/IStat.cs b/Assets/Scripts/Interfaces/IStat.cs new file mode 100644 index 00000000..edde362e --- /dev/null +++ b/Assets/Scripts/Interfaces/IStat.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Assets.Scripts.Interfaces +{ + public interface IStat + { + string Name { get; } + } + public interface IStringStat + { + string Value { get; } + + void SetValue(string value); + } + + public interface INumericStat + { + float MaxValue { get; } + float Price { get; } + float Quantity { get; } + float Value { get; } + + bool deduct(float amount); + void forceDeduct(float amount); + void increase(float byAmount); + } +} diff --git a/Assets/Scripts/Interfaces/IStat.cs.meta b/Assets/Scripts/Interfaces/IStat.cs.meta new file mode 100644 index 00000000..666b4c0c --- /dev/null +++ b/Assets/Scripts/Interfaces/IStat.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 63f19538482d7a94598f9c79a711e13e \ No newline at end of file diff --git a/Assets/Scripts/Managers/MouseInputManager.cs b/Assets/Scripts/Managers/MouseInputManager.cs index 94236ad7..77fc5b38 100644 --- a/Assets/Scripts/Managers/MouseInputManager.cs +++ b/Assets/Scripts/Managers/MouseInputManager.cs @@ -28,7 +28,12 @@ public class MouseInputManager : MonoBehaviour void Update() { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); - if (!EventSystem.current.IsPointerOverGameObject() && Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask)) + if(EventSystem.current.IsPointerOverGameObject()) + { + return; + } + //hide rounded menu + if (Physics.Raycast(ray, out var mouseRaycastHit, 100f, _selectableLayerMask)) { mouseRaycastHit.transform.TryGetComponent(out BaseInteractableObject baseObject); if (baseObject != null) diff --git a/Assets/Scripts/Player/Stat.cs b/Assets/Scripts/Player/NumericStat.cs similarity index 75% rename from Assets/Scripts/Player/Stat.cs rename to Assets/Scripts/Player/NumericStat.cs index 053f4054..0db92367 100644 --- a/Assets/Scripts/Player/Stat.cs +++ b/Assets/Scripts/Player/NumericStat.cs @@ -1,4 +1,6 @@ -public class Stat +using Assets.Scripts.Interfaces; + +public class NumericStat : INumericStat { public string Name { get; private set; } public float Value { get; private set; } @@ -6,14 +8,14 @@ public class Stat public float Quantity { get; private set; } public float MaxValue { get; private set; } - public Stat(string name, float startValue, float maxValue) + public NumericStat(string name, float startValue, float maxValue) { Name = name; Value = startValue; - MaxValue = maxValue; + MaxValue = maxValue; } - public Stat(string name, float price, float quantity, float maxValue) + public NumericStat(string name, float price, float quantity, float maxValue) { Name = name; Price = price; diff --git a/Assets/Scripts/Player/Stat.cs.meta b/Assets/Scripts/Player/NumericStat.cs.meta similarity index 100% rename from Assets/Scripts/Player/Stat.cs.meta rename to Assets/Scripts/Player/NumericStat.cs.meta diff --git a/Assets/Scripts/Player/Player.cs b/Assets/Scripts/Player/Player.cs index 7b950637..a7dd6bf7 100644 --- a/Assets/Scripts/Player/Player.cs +++ b/Assets/Scripts/Player/Player.cs @@ -1,6 +1,6 @@ +using Assets.Scripts.Interfaces; using System; using System.Collections.Generic; -using Unity.VisualScripting; using UnityEngine; using UnityEngine.AI; @@ -21,7 +21,7 @@ public class Player : MonoBehaviour private PlayerStates _currentActing; private AnimationStates _currentAnimation; - public Dictionary Stats; + public Dictionary Stats; public JobPositions JobPosition { get; set; } public EducationSkill Education { get; set; } @@ -33,6 +33,7 @@ public class Player : MonoBehaviour private ContainerItem _containerItem; private Action _OnAnimationFinish; + private string _locationName; private void Awake() { @@ -213,27 +214,27 @@ public class Player : MonoBehaviour switch (_currentActing) { case PlayerStates.Eating: - Stats[StatsId.Food].increase(10f); + (Stats[StatsId.Food] as INumericStat).increase(10f); break; case PlayerStates.Sleeping: - Stats[StatsId.Energy].increase(0.2f); - Stats[StatsId.Food].deduct(0.03f); + (Stats[StatsId.Energy] as INumericStat).increase(0.2f); + (Stats[StatsId.Food] as INumericStat).deduct(0.03f); break; default: - Stats[StatsId.Food].deduct(0.05f); // 48 hours it's 100, 100/2880=~0.034 per minute - Stats[StatsId.Energy].deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute + (Stats[StatsId.Food] as INumericStat).deduct(0.05f); // 48 hours it's 100, 100/2880=~0.034 per minute + (Stats[StatsId.Energy] as INumericStat).deduct(0.1f); // 24 hours it's 100, 100/1440=~0.096 per minute break; } } public void Pay(float amount) { - Stats[StatsId.Money].deduct(amount); + (Stats[StatsId.Money] as INumericStat).deduct(amount); } public void AddMoney(float amount) { - Stats[StatsId.Money].increase(amount); + (Stats[StatsId.Money] as INumericStat).increase(amount); } public void SetContainerItem(ContainerItem containerItem) @@ -255,4 +256,13 @@ public class Player : MonoBehaviour { return _containerItem != null; } + + public void SetLocationName(string locationName) + { + _locationName = locationName; + } + public string GetLocationName() + { + return _locationName; + } } diff --git a/Assets/Scripts/Player/PlayerStats.cs b/Assets/Scripts/Player/PlayerStats.cs index d3a28f19..241dbedd 100644 --- a/Assets/Scripts/Player/PlayerStats.cs +++ b/Assets/Scripts/Player/PlayerStats.cs @@ -3,18 +3,20 @@ using System.Collections.Generic; public class PlayerStats { - public static Dictionary CreateInitialStats() + public static Dictionary CreateInitialStats() { - return new Dictionary() + return new Dictionary() { - {StatsId.Money, new Stat("Money", 100.0f,10000000f)}, - {StatsId.RentAccount, new Stat("Rent Account", 0,10f)}, - {StatsId.Food, new Stat("Food Energy", 50f,100f) }, - {StatsId.Energy,new Stat("Energy", 50f,100f) }, + {StatsId.Money, new NumericStat("Money", 100.0f,10000000f)}, + {StatsId.RentAccount, new NumericStat("Rent Account", 0,10f)}, + {StatsId.Food, new NumericStat("Food Energy", 50f,100f) }, + {StatsId.Energy,new NumericStat("Energy", 50f,100f) }, + {StatsId.LocationName,new StringStat("Location","Nowhere") }, }; } - + + //// Knowledge for University Jobs //public Stat literatureKnowledge = new Stat("LiteratureKnowledge", 0); //public Stat mathematicsKnowledge = new Stat("MathematicsKnowledge", 0); diff --git a/Assets/Scripts/Player/StringStat.cs b/Assets/Scripts/Player/StringStat.cs new file mode 100644 index 00000000..f1a6de87 --- /dev/null +++ b/Assets/Scripts/Player/StringStat.cs @@ -0,0 +1,18 @@ +using Assets.Scripts.Interfaces; + +public class StringStat : IStringStat +{ + public string Name { get; private set; } + public string Value { get; private set; } + + public StringStat(string name, string startValue) + { + Name = name; + Value = startValue; + } + + public void SetValue(string value) + { + Value = value; + } +} diff --git a/Assets/Scripts/Player/StringStat.cs.meta b/Assets/Scripts/Player/StringStat.cs.meta new file mode 100644 index 00000000..15de4214 --- /dev/null +++ b/Assets/Scripts/Player/StringStat.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c57f2033235f86b4585b18775c652653 \ No newline at end of file diff --git a/Assets/Scripts/UIElements/TopBarUI.cs b/Assets/Scripts/UIElements/TopBarUI.cs index ce2ba555..ba167a62 100644 --- a/Assets/Scripts/UIElements/TopBarUI.cs +++ b/Assets/Scripts/UIElements/TopBarUI.cs @@ -1,3 +1,4 @@ +using Assets.Scripts.Interfaces; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -9,6 +10,9 @@ public class TopBarUI : MonoBehaviour [SerializeField] private TextMeshProUGUI _moneyText; + + [SerializeField] + private TextMeshProUGUI _locationText; [SerializeField] public Slider _energy; @@ -31,8 +35,8 @@ public class TopBarUI : MonoBehaviour // Update is called once per frame void Update() { - _moneyText.text = $"${Player.Instance.Stats[StatsId.Money].Value}"; - + _moneyText.text = $"${(Player.Instance.Stats[StatsId.Money] as INumericStat).Value}"; + _locationText.text= $"{(Player.Instance.Stats[StatsId.LocationName] as IStringStat).Value}"; } @@ -43,7 +47,7 @@ public class TopBarUI : MonoBehaviour _timeText.text = $"{TimeManager.CurrentTime.GetDayName()} {TimeManager.CurrentTime.ToString(@"hh\:mm")} day ({TimeManager.CurrentTime.Days})"; } - _energy.value = (float)Player.Instance.Stats[StatsId.Energy].Value; - _food.value = (float)Player.Instance.Stats[StatsId.Food].Value; + _energy.value = (Player.Instance.Stats[StatsId.Energy] as INumericStat).Value; + _food.value = (Player.Instance.Stats[StatsId.Food] as INumericStat).Value; } }