diff --git a/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity b/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity index a43d443..cfd0e68 100644 --- a/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity +++ b/TheStrongestSnail/Assets/Scenes/Battle_Royale.unity @@ -6099,9 +6099,9 @@ RectTransform: m_Father: {fileID: 582056263} m_RootOrder: 0 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, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 691.1493, y: -530.9911} m_SizeDelta: {x: 1306.2986, y: 609.9821} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &384095152 @@ -11636,9 +11636,9 @@ RectTransform: m_Father: {fileID: 582056263} m_RootOrder: 3 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, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 691.15, y: -2325.055} m_SizeDelta: {x: 1306.3, y: 353.7809} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &760515340 @@ -12734,9 +12734,9 @@ RectTransform: m_Father: {fileID: 582056263} m_RootOrder: 2 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, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 691.15, y: -2015.7462} m_SizeDelta: {x: 1306.3, y: 172.6165} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &875993942 @@ -28066,9 +28066,9 @@ RectTransform: m_Father: {fileID: 582056263} m_RootOrder: 1 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, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 691.1493, y: -1382.7101} m_SizeDelta: {x: 1306.2986, y: 1001.2359} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1845562840 diff --git a/TheStrongestSnail/Assets/Scenes/Scene_main.unity b/TheStrongestSnail/Assets/Scenes/Scene_main.unity index 97e99a1..386da49 100644 --- a/TheStrongestSnail/Assets/Scenes/Scene_main.unity +++ b/TheStrongestSnail/Assets/Scenes/Scene_main.unity @@ -1370,7 +1370,7 @@ MonoBehaviour: - -2100 - -3760 - -5350 - mainBtnScript: {fileID: 0} + mainBtnScript: {fileID: 332514051} --- !u!1 &278944241 GameObject: m_ObjectHideFlags: 0 diff --git a/TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs b/TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs index e265ca1..1cf3652 100644 --- a/TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs +++ b/TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs @@ -10,14 +10,14 @@ public class Conversion : BaseUIPanel public GameObject game; void Start() { - Button1.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.ShellToEgg)); - Button2.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.EggToShell)); + Button1.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.ShellToEgg, Button1)); + Button2.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.EggToShell, Button2)); } - void ButtononClick(ConversionItem.mode mymode) + void ButtononClick(ConversionItem.mode mymode, Button button) { + ButtonClickAnimationAsync(button.gameObject); Canvas canvas = GetComponentInParent(); - GameObject conver = Instantiate(game, canvas.transform); conver.GetComponentInChildren().mymode = mymode; } diff --git a/TheStrongestSnail/Assets/Scripts/Scene_main/sceneContorl.cs b/TheStrongestSnail/Assets/Scripts/Scene_main/sceneContorl.cs index 6336411..4bef241 100644 --- a/TheStrongestSnail/Assets/Scripts/Scene_main/sceneContorl.cs +++ b/TheStrongestSnail/Assets/Scripts/Scene_main/sceneContorl.cs @@ -1,8 +1,10 @@ using System.Collections; using System.Collections.Generic; +using Unity.Mathematics; using UnityEngine; +using UnityEngine.EventSystems; -public class sceneContorl : MonoBehaviour +public class sceneContorl : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler { public Camera m_cam; public GameObject mainScene; @@ -34,59 +36,14 @@ public class sceneContorl : MonoBehaviour mainSceneRectTransform = mainScene.GetComponent(); } - // Update is called once per frame - void Update() - { -#if UNITY_EDITOR || UNITY_STANDALONE - // 桌面端:鼠标按下时 - if (Input.GetMouseButtonDown(0)) - { - m_fingerDown = true; - m_oneFingerDragStartPos = Input.mousePosition; // 获取鼠标按下的起始位置 - } - // 桌面端:鼠标松开时 - if (Input.GetMouseButtonUp(0)) - { - m_fingerDown = false; - } - - // 处理鼠标拖动 - if (m_fingerDown) - { - HandleFingerDragMove(Input.mousePosition); - } - -#else - // 移动端:单指滑动 - if (Input.touchCount == 1) - { - Touch touch = Input.touches[0]; - - // 手指刚触碰屏幕时 - if (touch.phase == TouchPhase.Began) - { - m_fingerDown = true; - m_oneFingerDragStartPos = touch.position; // 获取手指按下的起始位置 - } - // 手指在屏幕上滑动时 - else if (touch.phase == TouchPhase.Moved) - { - HandleFingerDragMove(touch.position); // 处理手指拖动 - } - } - else - { - m_fingerDown = false; - } -#endif - } /// /// 单指滑动 /// private void HandleFingerDragMove(Vector2 fingerPos) { + // 计算当前帧的滑动增量(交换顺序,保证滑动方向一致) Vector3 moveDelta = fingerPos - m_oneFingerDragStartPos; // 当前触摸位置 - 起始位置 Vector3 newPos = mainSceneRectTransform.anchoredPosition; @@ -110,22 +67,37 @@ public class sceneContorl : MonoBehaviour /// /// 当前X坐标 /// 返回距离最近的目标位置值 - private float GetClosestTargetValue(float currentX) + float FindClosestNumber(float target) { - float closestValue = targetPositions[0]; // 默认目标位置为数组的第一个值 - float minDistance = Mathf.Abs(currentX - targetPositions[0]); // 初始最小距离为第一个目标的距离 + float closestNumber = targetPositions[0]; // 默认第一个数为最近的数 + float minDifference = Mathf.Abs(target - closestNumber); // 计算与第一个数的差值 - // 遍历 targetPositions 数组,计算与当前位置的距离 - for (int i = 1; i < targetPositions.Length; i++) + foreach (float number in targetPositions) { - float distance = Mathf.Abs(currentX - targetPositions[i]); // 计算当前位置与目标的绝对距离 - if (distance < minDistance) // 如果当前距离比最小距离小 + float difference = Mathf.Abs(target - number); // 计算当前数与目标数的差值 + if (difference < minDifference) // 如果当前差值更小,更新最近的数 { - closestValue = targetPositions[i]; // 更新最近的目标位置 - minDistance = distance; // 更新最小距离 + closestNumber = number; + minDifference = difference; } } - return closestValue; // 返回最近目标的值 + return closestNumber; + } + + public void OnDrag(PointerEventData eventData) + { + + HandleFingerDragMove(eventData.position); + } + + public void OnBeginDrag(PointerEventData eventData) + { + m_oneFingerDragStartPos = Input.mousePosition; // 获取鼠标按下的起始位置 + } + + public void OnEndDrag(PointerEventData eventData) + { + mainBtnScript.MovePanel(FindClosestNumber(mainSceneRectTransform.anchoredPosition.x)); } } diff --git a/TheStrongestSnail/Assets/Scripts/Scene_shop/BaseUIPanel.cs b/TheStrongestSnail/Assets/Scripts/Scene_shop/BaseUIPanel.cs index 4f04eac..44c3fa3 100644 --- a/TheStrongestSnail/Assets/Scripts/Scene_shop/BaseUIPanel.cs +++ b/TheStrongestSnail/Assets/Scripts/Scene_shop/BaseUIPanel.cs @@ -53,4 +53,10 @@ public class BaseUIPanel : Base await Task.Delay(200); } + public async void closure() + { + await HidePanel(); + Destroy(gameObject); + + } } diff --git a/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab b/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab index 060ee27..b62fea7 100644 --- a/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab +++ b/TheStrongestSnail/Assets/prefabs/Convert2Panel.prefab @@ -769,7 +769,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 477.5, y: -746.79} + m_AnchoredPosition: {x: 477.5, y: -612.79} m_SizeDelta: {x: 955, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4401108870514250707 diff --git a/TheStrongestSnail/Assets/prefabs/ConvertPanel.prefab b/TheStrongestSnail/Assets/prefabs/ConvertPanel.prefab index 24dd3a9..89b45b8 100644 --- a/TheStrongestSnail/Assets/prefabs/ConvertPanel.prefab +++ b/TheStrongestSnail/Assets/prefabs/ConvertPanel.prefab @@ -499,6 +499,216 @@ MonoBehaviour: m_FlexibleWidth: -1 m_FlexibleHeight: -1 m_LayoutPriority: 1 +--- !u!1 &3282481423507550611 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8212839374132598223} + - component: {fileID: 8391879760233063898} + - component: {fileID: 3842282440082391373} + - component: {fileID: 4965909200949386473} + m_Layer: 5 + m_Name: ReturnBtn + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8212839374132598223 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3282481423507550611} + 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: 1446808872202028735} + m_Father: {fileID: 5777725415565958670} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 0} + m_AnchorMax: {x: 1, y: 0} + m_AnchoredPosition: {x: -190, y: 159.19165} + m_SizeDelta: {x: 189.5036, y: 156.2572} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &8391879760233063898 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3282481423507550611} + m_CullTransparentMesh: 1 +--- !u!114 &3842282440082391373 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3282481423507550611} + 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: 21300000, guid: 97b216ec7d802df47b90d31c157b3d19, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &4965909200949386473 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3282481423507550611} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 3842282440082391373} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 2608027775744710265} + m_TargetAssemblyTypeName: BaseUIPanel, Assembly-CSharp + m_MethodName: closure + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!1 &3792399695142846430 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1446808872202028735} + - component: {fileID: 5447311838446558435} + - component: {fileID: 3678254617614170230} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1446808872202028735 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3792399695142846430} + 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: 8212839374132598223} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 7} + m_SizeDelta: {x: 124, y: 92} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &5447311838446558435 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3792399695142846430} + m_CullTransparentMesh: 1 +--- !u!114 &3678254617614170230 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3792399695142846430} + 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: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 98639139831238044a2aa906c6985533, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 --- !u!1 &5423705521291279935 GameObject: m_ObjectHideFlags: 0 @@ -1227,6 +1437,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5777725414642374465} + - {fileID: 8212839374132598223} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1285,8 +1496,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 530b2572632928c469745e8007fafce2, type: 3} m_Name: m_EditorClassIdentifier: - Panel: {fileID: 0} - CloseBTN: {fileID: 0} + Panel: {fileID: 5777725414642374470} + CloseBTN: {fileID: 4965909200949386473} Button1: {fileID: 5423705522342026479} Button2: {fileID: 5423705521256640195} game: {fileID: 158567708259785437, guid: d07e5f76946f1694687a4ea513c37856, type: 3}