diff --git a/.idea/.idea.The Auction/.idea/inspectionProfiles/Project_Default.xml b/.idea/.idea.The Auction/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..363328e --- /dev/null +++ b/.idea/.idea.The Auction/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/Assets/Audio.meta b/Assets/Audio.meta new file mode 100644 index 0000000..7242465 --- /dev/null +++ b/Assets/Audio.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 12df34c1f7c101f41b9f97fccb27121f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Villager_Angry.mp3 b/Assets/Audio/Villager_Angry.mp3 new file mode 100644 index 0000000..abe7476 Binary files /dev/null and b/Assets/Audio/Villager_Angry.mp3 differ diff --git a/Assets/Audio/Villager_Angry.mp3.meta b/Assets/Audio/Villager_Angry.mp3.meta new file mode 100644 index 0000000..9c5ea45 --- /dev/null +++ b/Assets/Audio/Villager_Angry.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 3f7efa6095e46064e8849d07700b7c40 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Villager_Happy.mp3 b/Assets/Audio/Villager_Happy.mp3 new file mode 100644 index 0000000..f024596 Binary files /dev/null and b/Assets/Audio/Villager_Happy.mp3 differ diff --git a/Assets/Audio/Villager_Happy.mp3.meta b/Assets/Audio/Villager_Happy.mp3.meta new file mode 100644 index 0000000..094cb14 --- /dev/null +++ b/Assets/Audio/Villager_Happy.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: bfb08039f7cc2844785d8bf4c8891af1 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/ka-ching sound effect.mp3 b/Assets/Audio/ka-ching sound effect.mp3 new file mode 100644 index 0000000..d6bd748 Binary files /dev/null and b/Assets/Audio/ka-ching sound effect.mp3 differ diff --git a/Assets/Audio/ka-ching sound effect.mp3.meta b/Assets/Audio/ka-ching sound effect.mp3.meta new file mode 100644 index 0000000..94c3411 --- /dev/null +++ b/Assets/Audio/ka-ching sound effect.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 096c003e405725142bfb76b9fb54537c +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/toaster oven ding - sound effect.mp3 b/Assets/Audio/toaster oven ding - sound effect.mp3 new file mode 100644 index 0000000..a9de1aa Binary files /dev/null and b/Assets/Audio/toaster oven ding - sound effect.mp3 differ diff --git a/Assets/Audio/toaster oven ding - sound effect.mp3.meta b/Assets/Audio/toaster oven ding - sound effect.mp3.meta new file mode 100644 index 0000000..b61c24c --- /dev/null +++ b/Assets/Audio/toaster oven ding - sound effect.mp3.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 12a36da580bcbcb449990a80c9471853 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Customer/Customer.prefab b/Assets/Customer/Customer.prefab index 2ac2054..c80de55 100644 --- a/Assets/Customer/Customer.prefab +++ b/Assets/Customer/Customer.prefab @@ -1,5 +1,139 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &3096247509938969863 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2579693046821952761} + - component: {fileID: 8028199953353550877} + - component: {fileID: 4734145443259180329} + 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 &2579693046821952761 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3096247509938969863} + 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: 3973078567107739988} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 200, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8028199953353550877 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3096247509938969863} + m_CullTransparentMesh: 1 +--- !u!114 &4734145443259180329 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3096247509938969863} + 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: New Text + 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: 36 + m_fontSizeBase: 36 + 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!1 &3582750950399662834 GameObject: m_ObjectHideFlags: 0 @@ -9,6 +143,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 6564429125302780662} + - component: {fileID: 2626769806097928812} + - component: {fileID: 323721399381893304} + - component: {fileID: 7484184910861808735} m_Layer: 0 m_Name: Customer m_TagString: Untagged @@ -29,16 +166,379 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 4680687846769661018} + - {fileID: 4013785496967212353} + - {fileID: 8019979993914469277} + - {fileID: 2353741547831399736} + - {fileID: 3973078567107739988} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &2626769806097928812 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3582750950399662834} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b50833c62b5f59644a29221ccb3ffb18, type: 3} + m_Name: + m_EditorClassIdentifier: + _minWaitTime: 5 + _maxWaitTime: 10 + _buyChance: 0.3 + _buyChanceIncrease: 0.2 + _buyChanceDecrease: 0.3 + _objectHolder: {fileID: 2353741547831399736} +--- !u!195 &323721399381893304 +NavMeshAgent: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3582750950399662834} + m_Enabled: 1 + m_AgentTypeID: 0 + m_Radius: 0.4 + m_Speed: 3.5 + m_Acceleration: 8 + avoidancePriority: 50 + m_AngularSpeed: 120 + m_StoppingDistance: 0 + m_AutoTraverseOffMeshLink: 1 + m_AutoBraking: 1 + m_AutoRepath: 1 + m_Height: 2 + m_BaseOffset: 0 + m_WalkableMask: 4294967295 + m_ObstacleAvoidanceType: 4 +--- !u!114 &7484184910861808735 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3582750950399662834} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 165e0ca2b8b0b3a40b36b5b46e91dca9, type: 3} + m_Name: + m_EditorClassIdentifier: + _customerNomal: {fileID: 6838593136780136478} + _customerAngry: {fileID: 6763356380254657486} +--- !u!1 &3951142034581684682 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2353741547831399736} + m_Layer: 0 + m_Name: ItemHandle + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2353741547831399736 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3951142034581684682} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1.831, z: 0.5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6564429125302780662} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &6763356380254657486 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8019979993914469277} + m_Layer: 0 + m_Name: Angry + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8019979993914469277 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6763356380254657486} + serializedVersion: 2 + 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: 2334956513988168255} + m_Father: {fileID: 6564429125302780662} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &6796302241985326907 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3973078567107739988} + - component: {fileID: 5021036160212185713} + - component: {fileID: 6049552928424139037} + - component: {fileID: 1392404261179993453} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3973078567107739988 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6796302241985326907} + 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: 2579693046821952761} + m_Father: {fileID: 6564429125302780662} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 960, y: 540} + m_SizeDelta: {x: 10, y: 10} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!223 &5021036160212185713 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6796302241985326907} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 25 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &6049552928424139037 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6796302241985326907} + 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: 1 +--- !u!114 &1392404261179993453 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6796302241985326907} + 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!1 &6838593136780136478 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4013785496967212353} + m_Layer: 0 + m_Name: Normal + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4013785496967212353 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6838593136780136478} + serializedVersion: 2 + 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: 4680687846769661018} + m_Father: {fileID: 6564429125302780662} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &2877193134574579156 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 8019979993914469277} + m_Modifications: + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalScale.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalScale.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalRotation.w + value: 0.49999988 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalRotation.x + value: 0.49999988 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalRotation.y + value: -0.50000024 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalRotation.z + value: 0.5000001 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 90 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 90 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_ConstrainProportionsScale + value: 1 + objectReference: {fileID: 0} + - target: {fileID: -1684107799473140416, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 1aa713fc36ad6ad409f0167b1bd7e2ca, type: 2} + - target: {fileID: 919132149155446097, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_Name + value: Customer (1) + objectReference: {fileID: 0} + - target: {fileID: 6317578925029434746, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 1aa713fc36ad6ad409f0167b1bd7e2ca, type: 2} + - target: {fileID: 8100320773420232829, guid: b89594669d2f8c447924e07361919e00, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 1aa713fc36ad6ad409f0167b1bd7e2ca, type: 2} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: b89594669d2f8c447924e07361919e00, type: 3} +--- !u!4 &2334956513988168255 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, + type: 3} + m_PrefabInstance: {fileID: 2877193134574579156} + m_PrefabAsset: {fileID: 0} --- !u!1001 &5152009883973645233 PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: serializedVersion: 3 - m_TransformParent: {fileID: 6564429125302780662} + m_TransformParent: {fileID: 4013785496967212353} m_Modifications: - target: {fileID: -8679921383154817045, guid: b89594669d2f8c447924e07361919e00, type: 3} diff --git a/Assets/Customer/CustomerAngry.mat b/Assets/Customer/CustomerAngry.mat new file mode 100644 index 0000000..53faea9 --- /dev/null +++ b/Assets/Customer/CustomerAngry.mat @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-3385930777553547782 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 7 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CustomerAngry + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _AlphaToMask: 0 + - _Blend: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _DstBlendAlpha: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 0.78867924, g: 0.08184399, b: 0.08184399, a: 1} + - _Color: {r: 0.78867924, g: 0.08184395, b: 0.08184395, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Customer/CustomerAngry.mat.meta b/Assets/Customer/CustomerAngry.mat.meta new file mode 100644 index 0000000..4770391 --- /dev/null +++ b/Assets/Customer/CustomerAngry.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1aa713fc36ad6ad409f0167b1bd7e2ca +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Customer/CustomerController.cs b/Assets/Customer/CustomerController.cs index 7a7f818..c42bc6e 100644 --- a/Assets/Customer/CustomerController.cs +++ b/Assets/Customer/CustomerController.cs @@ -1,18 +1,206 @@ -using System.Collections; -using System.Collections.Generic; +using System; +using Customer; using UnityEngine; using UnityEngine.AI; +using static Customer.MoodState; +using Random = UnityEngine.Random; + +public class CustomerController : MonoBehaviour, IObjectParentHolder { + private NavMeshAgent _navMeshAgent; + private Vector3 _target; + + public SellCounter TargetCounter { get; private set; } + + [Header("WaitTime")] [SerializeField] private float _minWaitTime = 5.0f; + [SerializeField] private float _maxWaitTime = 10.0f; + + [Header("BuyChace")] [SerializeField] private float _buyChance = 0.5f; + [SerializeField] private float _buyChanceIncrease = 0.1f; + [SerializeField] private float _buyChanceDecrease = 0.1f; + + + [SerializeField] private Transform _objectHolder; + + private Object _currentObject; + + private float _waitTime; + + private CustomerVisibleController _visibleController; + + public MoodState State => _visibleController.GetState(); + + private Vector3 _exitPosition; + public event Action OnCustomerLeft; + + + private CustomerState _state = CustomerState.GoingToCounter; + + //enum + public enum CustomerState { + GoingToCounter, + WaitingToBuy, + Buying, + WalkingToExit + } -public class CustomerController : MonoBehaviour { - NavMeshAgent _navMeshAgent; - private Transform _target; - private void Awake() { _navMeshAgent = GetComponent(); + _visibleController = GetComponent(); + + _visibleController.SetState(Normal); } - + private void Update() { - _target = PlayerController.Instance.transform; - _navMeshAgent.SetDestination(_target.position); + switch (_state) { + case CustomerState.GoingToCounter: + if (_navMeshAgent.remainingDistance <= _navMeshAgent.stoppingDistance) { + OnDestinationReached(); + } + + break; + case CustomerState.WaitingToBuy: + WaitToBuy(); + break; + case CustomerState.Buying: + BuyItem(); + break; + case CustomerState.WalkingToExit: + CheckIfReachedExit(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + private void CheckIfReachedExit() { + if (_navMeshAgent.remainingDistance <= _navMeshAgent.stoppingDistance) { + Debug.Log("Bye :p"); + CustomerManager.Instance.CustomerDies(this); + Destroy(this.gameObject); + } + } + + private bool ShouldBuyItem() { + //This should be a function that checks if a customer should buy an item + //For example, if the item is worth 10 bucks, and the player sets the price to 20, the customer should not buy it since its too expensive + + //if an item is prices higher then X% of the base price, the customer should not buy it + Object obj = TargetCounter.GetObject(); + if (obj == null) { + Debug.LogError("Counter has no object"); + return false; + } + + float price = obj.ObjectSo.basePrice; + float sellPrice = TargetCounter.GetSellingPrice(); + bool isBroken = obj.IsBroken; + + float difference = Mathf.Abs(price - sellPrice); + float percentage = difference / price; + + //Log this for now + Debug.Log("Difference: " + difference + " Percentage: " + percentage); + //Random differnece between 0.1 and 0.2; + float diff = Random.Range(_buyChanceDecrease, _buyChanceIncrease); + + var calculatedBuyChance = _buyChance; + + if (isBroken) { + //Customer should be less likely to buy broken items + calculatedBuyChance -= 0.1f; + } + + if (percentage > calculatedBuyChance + diff) { + return false; + } + + return true; + } + + public void SetDestination(Vector3 position) { + _target = position; + _navMeshAgent.SetDestination(_target); + } + + public void SetTargetCounter(SellCounter counter) { + TargetCounter = counter; + + float angle = Random.Range(0, 360); + Vector3 offset = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)); + this.SetDestination(counter.transform.position + offset); + } + + private void BuyItem() { + if (TargetCounter == null) { + Debug.LogError("Customer has no target counter"); + return; + } + + if (!ShouldBuyItem()) { + Debug.Log("Customer should not buy item"); + this.SetDestination(_exitPosition); + _state = CustomerState.WalkingToExit; + _visibleController.SetState(Angry); + SoundFXController.Instance.PlayVillagerAngryFX(); + return; + } + + Debug.Log("Customer bought item: " + TargetCounter.GetObject().ObjectSo.objectName + " for: " + + TargetCounter.GetSellingPrice()); + _visibleController.SetState(Normal); + TargetCounter.SellItem(this); + SoundFXController.Instance.PlayItemBoughtFX(); + SoundFXController.Instance.PlayVillagerHappyFX(); + this.SetDestination(_exitPosition); + _state = CustomerState.WalkingToExit; + OnCustomerLeft?.Invoke(TargetCounter, this); //Notify the customer manager that the customer left + } + + private void OnDestinationReached() { + //should tell the counter there is a customer waiting; + Debug.Log("Customer reached destination for Counter: " + TargetCounter.name); + _state = CustomerState.WaitingToBuy; + _waitTime = Random.Range(_minWaitTime, _maxWaitTime); + } + + void OnDrawGizmosSelected() { + Gizmos.color = Color.red; + Gizmos.DrawWireSphere(_target, 0.5f); + } + + void WaitToBuy() { + _waitTime -= Time.deltaTime; + if (_waitTime <= 0) { + _state = CustomerState.Buying; + } + } + + public Transform GetHolderTransform() { + return _objectHolder; + } + + public void SetObject(Object obj) { + _currentObject = obj; + } + + public Object GetObject() { + return _currentObject; + } + + public void ClearObject() { + _currentObject = null; + } + + public bool HasObject() { + return _currentObject != null; + } + + public void SetExitPosition(Vector3 position) { + _exitPosition = position; + } + + + public void SetState(CustomerState state) { + _state = state; } } \ No newline at end of file diff --git a/Assets/Customer/CustomerHappy.mat b/Assets/Customer/CustomerHappy.mat new file mode 100644 index 0000000..9b92c80 --- /dev/null +++ b/Assets/Customer/CustomerHappy.mat @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-3385930777553547782 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 7 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CustomerHappy + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _AlphaToMask: 0 + - _Blend: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _DstBlendAlpha: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Customer/CustomerHappy.mat.meta b/Assets/Customer/CustomerHappy.mat.meta new file mode 100644 index 0000000..88e08d6 --- /dev/null +++ b/Assets/Customer/CustomerHappy.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 80f72f7a775ddda49827bbbee4cde94a +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Customer/CustomerManager.cs b/Assets/Customer/CustomerManager.cs new file mode 100644 index 0000000..1ff2cd7 --- /dev/null +++ b/Assets/Customer/CustomerManager.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UnityEngine; +using static CustomerController; +using Random = UnityEngine.Random; + + +public class CustomerManager : MonoBehaviour { + public static CustomerManager Instance { get; private set; } + + + [SerializeField] private GameObject _customerPrefab; + [SerializeField] private Transform _customerSpawnPoint; + + [SerializeField] private float _timeToNextCustomerMin = 5; + [SerializeField] private float _timeToNextCustomerMax = 10; + + private List _sellCounters = new List(); + private List AvailableCounters { get; } = new List(); + + private readonly List _customers = new List(); + + private int _newCustomerNeeded; // 0 = no new ones needed, > 0 = new one needed + private float _timeToNextCustomer; + + + //Args for the event + public class OnCustomerLeftArgs : EventArgs { + public bool Angry; + } + + public event EventHandler OnCustomerLeft; + + // Start is called before the first frame update + private void Start() { + // Find all sellingCounters in the scene + + if (Instance != null) { + Debug.LogError("What? 2 CustomerManagers crazy!!!"); + } + + Instance = this; + + var sellCounters = FindObjectsOfType(); + foreach (var sellCounter in sellCounters) { + sellCounter.OnCounterStartSelling += CounterStartedSelling; + _sellCounters?.Add(sellCounter); + } + + + } + + private void CounterStartedSelling(object sender, [NotNull] SellCounter.OnCounterStartSellingArgs e) { + if (e == null) throw new ArgumentNullException(nameof(e)); + // Spawn a customer at the spawn point + _newCustomerNeeded += 1; + AvailableCounters.Add(e.SellCounter); + } + + private void SpawnCustomer(SellCounter target) { + var customer = Instantiate(_customerPrefab, _customerSpawnPoint.position, Quaternion.identity); + var customerController = customer.GetComponent(); + + customerController.SetTargetCounter(target); + customerController.SetExitPosition(_customerSpawnPoint.position); + + customerController.OnCustomerLeft += CustomerLeft; + _customers.Add(customerController); + } + + private void CustomerLeft(SellCounter sellCounter, CustomerController customerController) { + if (customerController.State == Customer.MoodState.Angry) { + //Customer left angry, should dispach a new customer to the counter + _newCustomerNeeded += 1; + if (!AvailableCounters.Contains(sellCounter)) { + AvailableCounters.Add(sellCounter); + } + else { + Debug.LogError("This should not happen, the counter is already in the available list"); + } + } + OnCustomerLeft?.Invoke(this, new OnCustomerLeftArgs { Angry = customerController.State == Customer.MoodState.Angry }); + } + + + // Update is called once per frame + private void Update() { + if(AvailableCounters.Count == 0) return; + if (_newCustomerNeeded > 0) { + _timeToNextCustomer -= Time.deltaTime; + if (_timeToNextCustomer <= 0) { + _newCustomerNeeded--; + _timeToNextCustomer = Random.Range(_timeToNextCustomerMin, _timeToNextCustomerMax); + + SellCounter target = AvailableCounters[Random.Range(0, AvailableCounters.Count)]; + SpawnCustomer(target); + + AvailableCounters.Remove(target); + } + } + } + + public void StoppedSelling(SellCounter sellCounter) { + if (AvailableCounters.Contains(sellCounter)) { + AvailableCounters.Remove(sellCounter); + } + + //Check if any customer has this counter as an target + foreach (var customerController in _customers) { + if (customerController.TargetCounter != sellCounter) continue; + + customerController.SetDestination(_customerSpawnPoint.position); + customerController.SetState(CustomerState.WalkingToExit); + } + } + + public void CustomerDies([NotNull] CustomerController customerController) { + if (customerController == null) return; + if (_customers.Contains(customerController)) { + _customers.Remove(customerController); + } + } +} \ No newline at end of file diff --git a/Assets/Customer/CustomerManager.cs.meta b/Assets/Customer/CustomerManager.cs.meta new file mode 100644 index 0000000..a6f775b --- /dev/null +++ b/Assets/Customer/CustomerManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 12673c52136a26945ac08bbacf744c08 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Customer/CustomerVisibleController.cs b/Assets/Customer/CustomerVisibleController.cs new file mode 100644 index 0000000..827626a --- /dev/null +++ b/Assets/Customer/CustomerVisibleController.cs @@ -0,0 +1,42 @@ +using UnityEngine; + +namespace Customer { + public enum MoodState { + Normal, + Angry + } + + public class CustomerVisibleController : MonoBehaviour + { + [SerializeField] private GameObject _customerNomal; + [SerializeField] private GameObject _customerAngry; + + private MoodState _state = MoodState.Normal; + + private void SetNormal() { + _customerNomal.SetActive(true); + _customerAngry.SetActive(false); + } + + private void SetAngry() { + _customerNomal.SetActive(false); + _customerAngry.SetActive(true); + } + + public void SetState(MoodState state) { + _state = state; + switch (_state) { + case MoodState.Normal: + SetNormal(); + break; + case MoodState.Angry: + SetAngry(); + break; + } + } + + public MoodState GetState() { + return _state; + } + } +} \ No newline at end of file diff --git a/Assets/Customer/CustomerVisibleController.cs.meta b/Assets/Customer/CustomerVisibleController.cs.meta new file mode 100644 index 0000000..6444673 --- /dev/null +++ b/Assets/Customer/CustomerVisibleController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 165e0ca2b8b0b3a40b36b5b46e91dca9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScrips.meta b/Assets/GameScrips.meta new file mode 100644 index 0000000..3b348e4 --- /dev/null +++ b/Assets/GameScrips.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2023cb372da1ff5489034e880f8c2777 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScrips/GameController.cs b/Assets/GameScrips/GameController.cs new file mode 100644 index 0000000..7131e4c --- /dev/null +++ b/Assets/GameScrips/GameController.cs @@ -0,0 +1,141 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +public class GameController : MonoBehaviour { + public static GameController Instance { get; private set; } + + [SerializeField] private MainHUDController _mainHudController; + [SerializeField] private DayEndHUDController _dayEndHudController; + [SerializeField] private GameObject _playerGameObject; + + private float _money = 0; //The money the player has + private int _charisma = 0; //The charisma of the player, 0 - 100; + + //Time stuff + [SerializeField] private int _hoursPerDay = 8; //9 - 17 + [SerializeField] private int _realLifeMinutes = 5; + + private float _time; //The actual time in gameHours + private float _timeScale; + private float _elapsedTime; + + //End of day variables + private float _gains; + private float _rent; + private float _profit; + + private float _startingMoney; + private bool _dayEnded = false; + + public enum LooseCondition { + Bankrupt, + Charisma + } + + + public float Money { + get => _money; + //Set the money and update the HUD + set { + _money = value; + _mainHudController.SetMoneyText(_money); + } + } + + public int Charisma { + get => _charisma; + set { + _charisma = value; + _mainHudController.SetCharisma(_charisma); + } + } + + public void Reset() { + //Start a new day + _time = 0; + _dayEnded = false; + _gains = 0; + _rent = 0; + _profit = 0; + + _startingMoney = Money; + HUDManager.Instance.HideCurrentHUD(); + _playerGameObject.SetActive(true); + } + + private void Awake() { + if (Instance != null) { + Debug.LogError("What? 2 GameControllers crazy!!!"); + } + + Instance = this; + + + } + + private void CustomerLeft(object sender, CustomerManager.OnCustomerLeftArgs e) { + if (e.Angry) { + //Customer left angry + Charisma -= 10; + if(Charisma <= 0) { + GameOver(LooseCondition.Charisma); + } + } + else { + if (_charisma + 10 <= 100) { + _charisma += 10; + } + } + } + + private void Start() { + Money = 100; + Charisma = 50; + _timeScale = (float)_hoursPerDay / (_realLifeMinutes * 60); + Reset(); + + CustomerManager.Instance.OnCustomerLeft += CustomerLeft; + + } + + private void DayEnd() { + _playerGameObject.SetActive(false); + HUDManager.Instance.ShowDayEndHUD(); + _gains = _money - _startingMoney; + _rent = 10; + _profit = _gains - _rent; + + _money += _profit; //Add the profit to the money, also includes rent + _mainHudController.SetMoneyText(_money); + + + HUDManager.Instance.GetDayEndController().DayEnd(_gains, _rent, _profit); + } + + private void Update() { + if (!_dayEnded) { + Debug.Log("Time: " + _time + " Elapsed Time: " + _elapsedTime + " TimeScale: " + _timeScale); + _elapsedTime += UnityEngine.Time.deltaTime * _timeScale; + if (_elapsedTime >= 1) { + _time += 1; + _elapsedTime = 0; + } + + int hours = (int)_time; + + _mainHudController.SetTime(hours + 9); //Offset by 9 so it starts at 9 am + + if (_time >= _hoursPerDay) { + //End the day + Debug.Log("Day Ended"); + _dayEnded = true; + DayEnd(); + } + } + } + + + public static void GameOver(LooseCondition condition) { + SceneManager.LoadScene(condition == LooseCondition.Bankrupt ? "Bankrupt" : "Charisma"); + } +} \ No newline at end of file diff --git a/Assets/GameScrips/GameController.cs.meta b/Assets/GameScrips/GameController.cs.meta new file mode 100644 index 0000000..18cd0de --- /dev/null +++ b/Assets/GameScrips/GameController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 39c4878df96a95643a23e2d0ba8dd7d6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScrips/TutorialController.cs b/Assets/GameScrips/TutorialController.cs new file mode 100644 index 0000000..054b1d4 --- /dev/null +++ b/Assets/GameScrips/TutorialController.cs @@ -0,0 +1,77 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TutorialController : MonoBehaviour +{ + public List _uiElements = new List(); + + [SerializeField] private ComputerBehaviour _computerBehaviour; + [SerializeField] private ObjectSO _item; + + private SellCounter[] _counters; + + private int _currentElement = 0; + + + // Start is called before the first frame update + private void Awake() { //Use Awake instead of Start to ensure that all the data is set before adding events + _counters = FindObjectsOfType(); + + + _computerBehaviour.OnBuyItem += ItemBought; + foreach (var counter in _counters) { + counter.OnCounterStartSelling += ItemOnSellingPedestal; + } + + + } + + private void Start() { + _computerBehaviour.SetItem(_item, true); + } + + private void ItemBought(object sender, System.EventArgs e) { + _computerBehaviour.OnBuyItem -= ItemBought; + Next(); + } + + private void ItemOnSellingPedestal(object sender, System.EventArgs e) { + foreach (var counter in _counters) { + counter.OnCounterStartSelling -= ItemOnSellingPedestal; + } + CustomerManager.Instance.OnCustomerLeft += CustomerLeft; + Next(); + } + + private void CustomerLeft(object sender, System.EventArgs e) { + CustomerManager.Instance.OnCustomerLeft -= CustomerLeft; + StartCoroutine(Countdown()); + Next(); + } + + //20 Seconds after the customer leaves + private IEnumerator Countdown() { + yield return new WaitForSeconds(20); + Next(); + } + + + + private void OnEnable() { + _uiElements[_currentElement].SetActive(true); + } + + private void Next() { + _uiElements[_currentElement].SetActive(false); + _currentElement++; + if (_currentElement >= _uiElements.Count) { + //End of tutorial + Debug.Log("End of tutorial"); + this.gameObject.SetActive(false); + return; + } + _uiElements[_currentElement].SetActive(true); + } + +} diff --git a/Assets/GameScrips/TutorialController.cs.meta b/Assets/GameScrips/TutorialController.cs.meta new file mode 100644 index 0000000..f1ea6d7 --- /dev/null +++ b/Assets/GameScrips/TutorialController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7fdcaca5501821d47a0ac7f1e528281a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HUD/BankruptScreenController.cs b/Assets/HUD/BankruptScreenController.cs new file mode 100644 index 0000000..0ccd29f --- /dev/null +++ b/Assets/HUD/BankruptScreenController.cs @@ -0,0 +1,8 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +public class BankruptScreenController : MonoBehaviour { + public void Restart() { + SceneManager.LoadScene("MainMenu"); + } +} \ No newline at end of file diff --git a/Assets/HUD/BankruptScreenController.cs.meta b/Assets/HUD/BankruptScreenController.cs.meta new file mode 100644 index 0000000..f8df437 --- /dev/null +++ b/Assets/HUD/BankruptScreenController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a6c6cc9cdd84fd440aecd149413b6c97 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HUD/ComputerScreen/ComputerScreen.uxml b/Assets/HUD/ComputerScreen/ComputerScreen.uxml index f9f1086..91ca8a5 100644 --- a/Assets/HUD/ComputerScreen/ComputerScreen.uxml +++ b/Assets/HUD/ComputerScreen/ComputerScreen.uxml @@ -1,6 +1,6 @@ - + diff --git a/Assets/HUD/ComputerScreen/ComputerScreenController.cs b/Assets/HUD/ComputerScreen/ComputerScreenController.cs new file mode 100644 index 0000000..d7e48ff --- /dev/null +++ b/Assets/HUD/ComputerScreen/ComputerScreenController.cs @@ -0,0 +1,14 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.UIElements; + +public class ComputerScreenController : MonoBehaviour { + private UIDocument _uiDocument; + + private void OnEnable() { + _uiDocument = GetComponent(); + var root = _uiDocument.rootVisualElement; + } +} \ No newline at end of file diff --git a/Assets/HUD/ComputerScreen/ComputerScreenController.cs.meta b/Assets/HUD/ComputerScreen/ComputerScreenController.cs.meta new file mode 100644 index 0000000..252580a --- /dev/null +++ b/Assets/HUD/ComputerScreen/ComputerScreenController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 20f14f6fae9591d42ba3d72a6cdf91b1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HUD/ComputerScreen/SellEntry.uxml b/Assets/HUD/ComputerScreen/SellEntry.uxml index 0435285..301db88 100644 --- a/Assets/HUD/ComputerScreen/SellEntry.uxml +++ b/Assets/HUD/ComputerScreen/SellEntry.uxml @@ -2,6 +2,7 @@ + diff --git a/Assets/HUD/DayEndHUDController.cs b/Assets/HUD/DayEndHUDController.cs new file mode 100644 index 0000000..23abd29 --- /dev/null +++ b/Assets/HUD/DayEndHUDController.cs @@ -0,0 +1,32 @@ +using TMPro; +using UnityEngine; + +public class DayEndHUDController : MonoBehaviour { + [SerializeField] private TextMeshProUGUI _gainsText; + + [SerializeField] private TextMeshProUGUI _rentText; + [SerializeField] private TextMeshProUGUI _profitText; + + [SerializeField] private TextMeshProUGUI _buttonText; + + public void DayEnd(float gains, float rent, float profit) { + _gainsText.text = "Gains: " + gains + "$"; + _rentText.text = "Rent: " + rent + "$"; + _profitText.text = "Profit: " + profit + "$"; + + //Check if the user is bankrupt + if (GameController.Instance.Money < 0) { + _buttonText.text = "Game Over"; + } + else { + _buttonText.text = "Next Day"; + } + } + + public void ConfirmEnd() { + GameController.Instance.Reset(); + if (GameController.Instance.Money < 0) { + GameController.GameOver(GameController.LooseCondition.Bankrupt); + } + } +} \ No newline at end of file diff --git a/Assets/HUD/DayEndHUDController.cs.meta b/Assets/HUD/DayEndHUDController.cs.meta new file mode 100644 index 0000000..3d938d4 --- /dev/null +++ b/Assets/HUD/DayEndHUDController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2f75c50d62e583241b94570f8ec67be8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/HUD/HUDManager.cs b/Assets/HUD/HUDManager.cs new file mode 100644 index 0000000..7fe1df5 --- /dev/null +++ b/Assets/HUD/HUDManager.cs @@ -0,0 +1,95 @@ +using UnityEngine; + +public class HUDManager : MonoBehaviour { + public static HUDManager Instance { get; private set; } + + [SerializeField] private GameObject _computerHUD; + [SerializeField] private GameObject _sellScreenHUD; + [SerializeField] private GameObject _miniGameHud; + [SerializeField] private GameObject _dayEndHUD; + [SerializeField] private GameObject _repairHUD; + + private GameObject _currentHUD; + + public bool IsUiOpen => _currentHUD != null; + + private void Awake() { + if (Instance != null) { + Debug.LogError("What? 2 HudManagers crazy!!!"); + } + + Instance = this; + } + + private void Update() { + CheckClose(); + } + + public void ShowComputerHUD() { + ShowHUD(_computerHUD); + } + + public void ShowSellScreenHUD(SellCounter counter) { + ShowHUD(_sellScreenHUD); + } + + public void ShowDayEndHUD() { + ShowHUD(_dayEndHUD); + } + + private void ShowHUD(GameObject hud) { + if (_currentHUD != null) { + _currentHUD.SetActive(false); + } + + _currentHUD = hud; + _currentHUD.SetActive(true); + } + + public void HideCurrentHUD() { + if (_currentHUD != null) { + _currentHUD.SetActive(false); + _currentHUD = null; + } + } + + private void CheckClose() { + if (!Input.GetKeyDown(KeyCode.Escape)) return; + if (_currentHUD == null) return; + + HideCurrentHUD(); + } + + + public void SellItem(SellCounter counter, Object sellingObject) { + Debug.Log(_sellScreenHUD.GetComponent()); + this.ShowSellScreenHUD(counter); + _sellScreenHUD.GetComponent().SetItem(counter, sellingObject); + } + + public void BuyItem(ComputerBehaviour computerBehaviour, ObjectSO objectSo, bool isBroken) { + this.ShowMinigameHUD(); + this._miniGameHud.GetComponent().BuyItem(computerBehaviour, objectSo, isBroken); + } + + private void ShowMinigameHUD() { + ShowHUD(_miniGameHud); + } + + public DayEndHUDController GetDayEndController() { + return _dayEndHUD.GetComponent(); + } + + public void UpdateItem(ObjectSO objectToSell, bool isBroken) { + this._miniGameHud.GetComponent().UpdateItem(objectToSell, isBroken); + } + + public void ShowRepairHUD() { + ShowHUD(_repairHUD); + } + + public void SetRepairHudItem(RepairStationBehaviour repairStationBehaviour, Object @object, float timeToFix, + float costToFix) { + _repairHUD.GetComponent().SetObject(repairStationBehaviour, @object, timeToFix, costToFix); + } +} \ No newline at end of file diff --git a/Assets/HUDManager.cs.meta b/Assets/HUD/HUDManager.cs.meta similarity index 100% rename from Assets/HUDManager.cs.meta rename to Assets/HUD/HUDManager.cs.meta diff --git a/Assets/HUD/ItemSellScreen/SellItem.uxml b/Assets/HUD/ItemSellScreen/SellItem.uxml index ab55bf5..e816f4c 100644 --- a/Assets/HUD/ItemSellScreen/SellItem.uxml +++ b/Assets/HUD/ItemSellScreen/SellItem.uxml @@ -3,9 +3,13 @@ - + + + + + diff --git a/Assets/HUD/ItemSellScreen/SellScreenController.cs b/Assets/HUD/ItemSellScreen/SellScreenController.cs index e7f9d6f..f8cfedf 100644 --- a/Assets/HUD/ItemSellScreen/SellScreenController.cs +++ b/Assets/HUD/ItemSellScreen/SellScreenController.cs @@ -1,7 +1,4 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; -using UnityEngine.UI; using UnityEngine.UIElements; using Button = UnityEngine.UIElements.Button; @@ -10,41 +7,57 @@ public class SellScreenController : MonoBehaviour { private UIDocument _document; private Label _itemNameLabel; + private Label _avgPriceLabel; private Label _paidPriceLabel; - private TextField _YourPriceInputfield; + private TextField _yourPriceInputfield; private SellCounter _counter; private Object _sellingObject; - //Becase we set the gameobject to active false, we need to use Awake - private void Awake() { + //Because we set the gameobject to active false, we need to use OnEnable + private void OnEnable() { _document = GetComponent(); _itemNameLabel = _document.rootVisualElement.Q