using Assets.Scripts; using Assets.Scripts.Apis; using Assets.Scripts.Apis.Models; using Assets.Scripts.UI.Prefab.MapList; using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using UnityEngine.UI; public class MapListController : PFUIPanel { // Start is called before the first frame update [SerializeField] GameObject map; [SerializeField] GameObject content; [SerializeField] GameObject scroll; [HideInInspector] public int pageIndex = 0; #if UNITY_ANDROID || UNITY_IOS [HideInInspector] public int pageSize = 21; #else [HideInInspector] public int pageSize = 20; #endif [HideInInspector] public string hard = "全部"; private Transform distanceOptions; private Transform diffOptions; private Transform tdContainer; private Transform favContainer; private Transform sorts; private Transform sortDir; private Transform searchInput; //private Transform distanceOption; //private Transform distanceOption; private Button returnBtn; GameObject btnMapMode; public GameObject Content { get { return content; } } private bool isEnd = false; private Transform topContainer; void ResetPage() { var rect = transform.GetComponent(); rect.offsetMax = new Vector2(rect.offsetMax.x, 0); rect.offsetMin = new Vector2(rect.offsetMin.x, 0); rect.localScale = Vector3.one; rect.localPosition = Vector3.zero; } protected override void Start() { #if (UNITY_ANDROID || UNITY_IOS) topContainer = transform.Find("Top"); ResetPage(); //var rectTransform = transform.GetComponent(); //var offsetMax = rectTransform.offsetMax; //rectTransform.offsetMax = new Vector2(0, offsetMax.y); //var offsetMin = rectTransform.offsetMin; //rectTransform.offsetMin = new Vector2(0, offsetMin.y); var widthDelta = (transform.parent.parent.GetComponent().sizeDelta.x - transform.GetComponent().sizeDelta.x)/2; //筛选按钮 var topRect = topContainer.GetComponent(); topRect.localPosition = new Vector3(topRect.localPosition.x - widthDelta , topRect.localPosition.y, topRect.localPosition.z); if (!App.topRectStartX.HasValue) { App.topRectStartX = topRect.localPosition.x; } if (App.isFullScreen) { topRect.sizeDelta = new Vector2(topRect.sizeDelta.x + 20, topRect.sizeDelta.y); } var mc = transform.Find("MC"); UIManager.AddEvent(transform.Find("SwitchMode/BtnFilter").gameObject, EventTriggerType.PointerClick, b => { topContainer.DOLocalMoveX(App.topRectStartX.Value + topRect.rect.width, 0.3f); mc.gameObject.SetActive(true); mc.GetComponent().alpha = 0; mc.GetComponent().DOFade(1, 0.3f); }); UIManager.AddEvent(mc.gameObject, EventTriggerType.PointerClick, b => { topContainer.DOLocalMoveX(App.topRectStartX.Value, 0.3f); mc.GetComponent().DOFade(0, 0.3f).onComplete = () => { mc.gameObject.SetActive(false); }; }); map = Resources.Load("UI/Prefab/MapList/MapItem-Mobile"); #else topContainer = transform.Find("Panel").Find("Top"); #endif #if UNITY_STANDALONE_WIN btnMapMode = this.transform.Find("SwitchMode").gameObject; SetRounded(btnMapMode.transform, 64); UIManager.AddEvent(btnMapMode.transform.Find("GoList").gameObject, EventTriggerType.PointerClick, (e) => { Application.OpenURL("http://192.168.0.101:3081/Mine/Upload?token="+ App.CurrentUser.cookie); }); #endif transform.Find("MainNav").GetComponent().ShowBack(); sort = "Near"; sortDire = "asc"; //if (hardSelector != null) //{ // hardSelector.onValueChanged.AddListener(ChangeHard); //} //ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B"); if (content!=null) { //var transform = content.transform.GetComponent(); //var layout = content.GetComponent(); //if (layout != null) //{ // var width = transform.rect.width; // layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5); //} } distanceOptions = topContainer.Find("distanceOptions"); if (distanceOptions != null) { var dDropdown = distanceOptions.GetComponent(); dDropdown.options = MapFilterOptions.distances; dDropdown.onValueChanged.AddListener(ChangeDistance); } diffOptions = topContainer.Find("DifficultyContainer"); if (diffOptions != null) { foreach (Transform t in diffOptions) { var button = t.GetComponent