using Assets.Scripts; using Assets.Scripts.Apis.Models; using Assets.Scripts.UI.Prefab.MapList; using System; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class GameRoomListController : PFUIPanel { [SerializeField] GameObject map; private RawImage Avatar; private GameObject CreateRoomBtn; private GameObject MapList; private Transform sorts; private Transform sortDir; private Transform topContainer; private Transform content; private GameObject scroll; private Transform distanceOptions; private Transform searchInput; private string sort = "", sortDire = ""; private bool isFav; private int pageSize = 10; private string ftname = ""; private string distance = ""; private bool is3d = false; public Dictionary caches = new Dictionary(); private bool startMouse; List hands = new List(); private int selectedRouteId; private int pageIndex = 0; private bool isEnd = false; protected override void Awake() { base.Awake(); } protected override void Start() { base.Start(); Avatar = transform.Find("Avatar").GetComponent(); CreateRoomBtn = transform.Find("SwitchMode/GoList").gameObject; MapList = transform.Find("MapList").gameObject; Utils.DisplayImage(Avatar, App.CurrentUser.WxHeadImg); UIManager.AddEvent(CreateRoomBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, CreateGameRoom); InitStep1(); } private void Update() { if (Input.GetAxis("Mouse ScrollWheel") != 0) { if (scroll.GetComponent().verticalNormalizedPosition <= 0 || scroll.GetComponent().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1)) { startMouse = true; } } else { if (startMouse) { startMouse = false; OnEndDrag(null); } } if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return)) { onEndEdit(); } } private void InitStep1() { sort = "Near"; sortDire = "asc"; var mapList = transform.Find("MapList"); topContainer = transform.Find("MapList/Modal/Right/Top/Container"); content = transform.Find("MapList/Modal/Right/Scroll View/Viewport/Content"); scroll = transform.Find("MapList/Modal/Right/Scroll View").gameObject; if (scroll != null) { UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag); } distanceOptions = topContainer.Find("distanceOptions"); if (distanceOptions != null) { var dDropdown = distanceOptions.GetComponent(); dDropdown.options = MapFilterOptions.distances; dDropdown.onValueChanged.AddListener(ChangeDistance); } var tdContainer = topContainer.Find("3dContainer"); var favContainer = topContainer.Find("FavContainer"); //是否是3d if (tdContainer != null) { UIManager.AddEvent(tdContainer.gameObject, EventTriggerType.PointerClick, (b) => { var gou = tdContainer.Find("Gou").gameObject; bool v = !gou.activeSelf; gou.SetActive(v); is3d = v; Refresh(); }); } //是否收藏 if (favContainer != null) { UIManager.AddEvent(favContainer.gameObject, EventTriggerType.PointerClick, (b) => { var gou = favContainer.Find("Gou").gameObject; bool v = !gou.activeSelf; gou.SetActive(v); isFav = v; Refresh(); }); } //搜索框 searchInput = topContainer.Find("SearchInput"); if (searchInput != null) { searchInput.GetComponent().onEndEdit.AddListener((s) => { var t = searchInput.GetComponent().text; ftname = t; }); UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) => { onEndEdit(); }); } //难度 var diffOptions = topContainer.Find("DifficultyContainer"); if (diffOptions != null) { foreach (Transform t in diffOptions) { var button = t.GetComponent