diff --git a/Assets/Prefab/Shop/Shop.prefab b/Assets/Prefab/Shop/Shop.prefab index 1007e00c1fa4195b6f24411e308ec002a57cd24e..f6c545c0eda7be365e9100495da6e305ab63724d 100644 --- a/Assets/Prefab/Shop/Shop.prefab +++ b/Assets/Prefab/Shop/Shop.prefab @@ -541,6 +541,177 @@ RectTransform: m_AnchoredPosition: {x: 12, y: 65} m_SizeDelta: {x: 270, y: 126.68} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &5177812132122329187 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 557132623315488981} + - component: {fileID: 6053708191702506109} + - component: {fileID: 1838556968299405519} + m_Layer: 0 + m_Name: timer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &557132623315488981 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5177812132122329187} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: -0.8588784} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1076336731131441806} + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 3.8009713, y: 5.04} + m_SizeDelta: {x: 4.73, y: 5} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!23 &6053708191702506109 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5177812132122329187} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!114 &1838556968299405519 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5177812132122329187} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, 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: 60 + 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: 18 + m_fontSizeBase: 18 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 0 + 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 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 + m_hasFontAssetChanged: 0 + m_renderer: {fileID: 6053708191702506109} + m_maskType: 0 --- !u!1 &5972690824423832835 GameObject: m_ObjectHideFlags: 0 @@ -556,7 +727,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &809395858004822939 Transform: m_ObjectHideFlags: 0 @@ -570,7 +741,6 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 5119864925773810787} - {fileID: 3021310274326302775} m_Father: {fileID: 655551303553745855} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -906,7 +1076,7 @@ Transform: m_LocalScale: {x: 0.46399996, y: 0.46399996, z: 0.46399996} m_ConstrainProportionsScale: 1 m_Children: [] - m_Father: {fileID: 809395858004822939} + m_Father: {fileID: 1076336731131441806} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!212 &9187325541804685720 SpriteRenderer: @@ -960,6 +1130,53 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &7017381858224549934 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1076336731131441806} + - component: {fileID: 9212427172894748653} + m_Layer: 0 + m_Name: follow + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1076336731131441806 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7017381858224549934} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.9166404, y: 0.5031796, z: 0.39399838} + m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 557132623315488981} + - {fileID: 5119864925773810787} + m_Father: {fileID: 7736077607212111405} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &9212427172894748653 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7017381858224549934} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ead2c309649a8bb4580a01fe66068b95, type: 3} + m_Name: + m_EditorClassIdentifier: + player: {fileID: 0} --- !u!1 &7867012483106533646 GameObject: m_ObjectHideFlags: 0 @@ -1973,6 +2190,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 400080, guid: f1d84cc28597f5641a3d9cbc4df7e306, type: 3} insertIndex: 5 addedObject: {fileID: 2258705402641834259} + - targetCorrespondingSourceObject: {fileID: 400080, guid: f1d84cc28597f5641a3d9cbc4df7e306, type: 3} + insertIndex: -1 + addedObject: {fileID: 1076336731131441806} m_AddedComponents: - targetCorrespondingSourceObject: {fileID: 100078, guid: f1d84cc28597f5641a3d9cbc4df7e306, type: 3} insertIndex: -1 @@ -2051,7 +2271,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: uiShop: {fileID: 2894649308036582996} - shopAlert: {fileID: 5972690824423832835} + shopAlertUI: {fileID: 5972690824423832835} + shopAlertFollow: {fileID: 7017381858224549934} --- !u!1001 &7990290028326398621 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Shop/ShopAlertFollow.cs b/Assets/Scripts/Shop/ShopAlertFollow.cs new file mode 100644 index 0000000000000000000000000000000000000000..a453e0f5820cbb1eee9834b4d3be05d9fd30482f --- /dev/null +++ b/Assets/Scripts/Shop/ShopAlertFollow.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ShopAlertFollow : MonoBehaviour +{ + public GameObject player; + + void Update() + { + Vector3 directionToPlayer = transform.position - player.transform.position; + directionToPlayer.y = 0; + + Quaternion toRotation = Quaternion.LookRotation(directionToPlayer); + + for(int i = 0; i < transform.childCount; i++) + { + Transform child = transform.GetChild(i); + child.rotation = Quaternion.Euler(0, toRotation.eulerAngles.y, 0); + } + } +} diff --git a/Assets/Scripts/Shop/ShopAlertFollow.cs.meta b/Assets/Scripts/Shop/ShopAlertFollow.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..d3ce2a9cdd3f05ce6aa49b3e14a911228dfabc3e --- /dev/null +++ b/Assets/Scripts/Shop/ShopAlertFollow.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ead2c309649a8bb4580a01fe66068b95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Shop/Shopkeeper.cs b/Assets/Scripts/Shop/Shopkeeper.cs index 35d82066011bd4a3256bd34414002dcc1b650a97..1570c9b4883dce7c308a1be3449eafc55cce7aa0 100644 --- a/Assets/Scripts/Shop/Shopkeeper.cs +++ b/Assets/Scripts/Shop/Shopkeeper.cs @@ -5,7 +5,8 @@ using UnityEngine; public class Shopkeeper : MonoBehaviour { public GameObject uiShop; - public GameObject shopAlert; + public GameObject shopAlertUI; + public GameObject shopAlertFollow; private bool isActiveShop = false; private GameObject player; private void Update() @@ -35,7 +36,7 @@ public class Shopkeeper : MonoBehaviour player.GetComponent<PlayerWeaponState>().enabled = false; player.GetComponent<StatisticsManager>().enabled = false; Cursor.lockState = CursorLockMode.None; - shopAlert.gameObject.SetActive(false); + deactivateAlert(); } else if (isActiveShop == false && player != null) { @@ -45,14 +46,14 @@ public class Shopkeeper : MonoBehaviour player.GetComponent<PlayerWeaponState>().enabled = true; player.GetComponent<StatisticsManager>().enabled = true; Cursor.lockState = CursorLockMode.Locked; - shopAlert.gameObject.SetActive(true); + activateAlert(); } } private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { - shopAlert.gameObject.SetActive(true); + activateAlert(); player = other.gameObject; } } @@ -61,8 +62,21 @@ public class Shopkeeper : MonoBehaviour { if (other.gameObject.tag == "Player") { - shopAlert.gameObject.SetActive(false); + deactivateAlert(); player = null; } } + private void activateAlert() + { + shopAlertUI.SetActive(true); + shopAlertFollow.SetActive(true); + shopAlertFollow.GetComponent<ShopAlertFollow>().player = player; + } + + private void deactivateAlert() + { + shopAlertUI.SetActive(false); + shopAlertFollow.GetComponent<ShopAlertFollow>().player = null; + shopAlertFollow.SetActive(false); + } }