2021-04-09 15:57:50 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Apis;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
using Assets.Scripts.Apis.Models;
|
2021-04-09 15:57:50 +08:00
|
|
|
|
using Assets.Scripts.UI.Prefab.MapList;
|
2021-04-01 11:01:05 +08:00
|
|
|
|
using System;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
2021-04-01 11:01:05 +08:00
|
|
|
|
using UnityEngine.EventSystems;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
2021-04-09 09:44:06 +08:00
|
|
|
|
public class MapListController : PFUIPanel
|
2021-03-25 16:55:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
[SerializeField] GameObject map;
|
|
|
|
|
|
[SerializeField] GameObject content;
|
2021-04-01 11:01:05 +08:00
|
|
|
|
[SerializeField] GameObject scroll;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
[HideInInspector] public int pageIndex = 0;
|
|
|
|
|
|
[HideInInspector] public int pageSize = 20;
|
|
|
|
|
|
[HideInInspector] public string hard = "全部";
|
2021-04-09 15:57:50 +08:00
|
|
|
|
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;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
private Button returnBtn;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
GameObject btnMapMode;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
public GameObject Content {
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return content;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private bool isEnd = false;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
protected override void Start()
|
2021-03-25 16:55:36 +08:00
|
|
|
|
{
|
2021-04-01 11:01:05 +08:00
|
|
|
|
//if (hardSelector != null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// hardSelector.onValueChanged.AddListener(ChangeHard);
|
|
|
|
|
|
//}
|
2021-04-15 15:57:29 +08:00
|
|
|
|
btnMapMode = this.transform.Find("SwitchMode").gameObject;
|
|
|
|
|
|
SetRounded(btnMapMode.transform, 64);
|
2021-04-14 15:02:33 +08:00
|
|
|
|
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowBigMapPanel();
|
|
|
|
|
|
});
|
2021-03-25 16:55:36 +08:00
|
|
|
|
if (content!=null)
|
|
|
|
|
|
{
|
2021-04-01 11:01:05 +08:00
|
|
|
|
//var transform = content.transform.GetComponent<RectTransform>();
|
|
|
|
|
|
//var layout = content.GetComponent<GridLayoutGroup>();
|
|
|
|
|
|
//if (layout != null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var width = transform.rect.width;
|
|
|
|
|
|
// layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
|
|
|
|
|
|
//}
|
2021-03-25 16:55:36 +08:00
|
|
|
|
}
|
2021-04-09 15:57:50 +08:00
|
|
|
|
distanceOptions = transform.Find("Panel").Find("Panel").Find("distanceOptions");
|
|
|
|
|
|
if (distanceOptions != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dDropdown = distanceOptions.GetComponent<Dropdown>();
|
|
|
|
|
|
dDropdown.options = MapFilterOptions.distances;
|
|
|
|
|
|
dDropdown.onValueChanged.AddListener(ChangeDistance);
|
|
|
|
|
|
}
|
|
|
|
|
|
diffOptions = transform.Find("Panel").Find("Panel").Find("DifficultyContainer");
|
|
|
|
|
|
if (diffOptions != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (Transform t in diffOptions)
|
|
|
|
|
|
{
|
|
|
|
|
|
var button = t.GetComponent<Button>();
|
|
|
|
|
|
var image = t.GetComponent<Image>();
|
|
|
|
|
|
var text = t.Find("Text").GetComponent<Text>();
|
|
|
|
|
|
button.onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ColorUtility.TryParseHtmlString("#23232D", out Color c1);
|
|
|
|
|
|
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
|
|
|
|
|
{
|
|
|
|
|
|
ColorUtility.TryParseHtmlString("#F93086", out Color c);
|
|
|
|
|
|
image.color = c;
|
|
|
|
|
|
text.color = new Color(1, 1, 1,1);
|
|
|
|
|
|
hands.Add(MapFilterOptions.diffDict[text.text]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ColorUtility.TryParseHtmlString("#6E6E7D", out Color c);
|
|
|
|
|
|
image.color = c1;
|
|
|
|
|
|
text.color = c;
|
|
|
|
|
|
hands.Remove(MapFilterOptions.diffDict[text.text]);
|
|
|
|
|
|
}
|
|
|
|
|
|
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-15 15:57:29 +08:00
|
|
|
|
BindHeadImage();
|
2021-03-25 16:55:36 +08:00
|
|
|
|
GetList();
|
2021-04-01 11:01:05 +08:00
|
|
|
|
if (scroll != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
|
|
|
|
|
}
|
|
|
|
|
|
//UIManager.AddEvent(transform.Find("Panel").Find("Panel"))
|
2021-03-25 16:55:36 +08:00
|
|
|
|
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
|
|
|
|
|
|
//obj.transform.parent = transform.parent;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
|
|
|
|
|
|
var btnQuit = this.transform.Find("BtnQuit");
|
|
|
|
|
|
if(btnQuit != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
returnBtn = btnQuit.GetComponent<Button>();
|
|
|
|
|
|
UIManager.AddEvent(returnBtn.gameObject, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowHomePanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-04-09 15:57:50 +08:00
|
|
|
|
tdContainer = transform.Find("Panel").Find("Panel").Find("3dContainer");
|
|
|
|
|
|
favContainer = transform.Find("Panel").Find("Panel").Find("FavContainer");
|
|
|
|
|
|
if (tdContainer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
tdContainer.GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var gou = tdContainer.Find("Gou").gameObject;
|
|
|
|
|
|
bool v = !gou.activeSelf;
|
|
|
|
|
|
gou.SetActive(v);
|
|
|
|
|
|
is3d = v;
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (favContainer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
favContainer.GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var gou = favContainer.Find("Gou").gameObject;
|
|
|
|
|
|
bool v = !gou.activeSelf;
|
|
|
|
|
|
gou.SetActive(v);
|
|
|
|
|
|
isFav = v;
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
searchInput = transform.Find("Panel").Find("Panel").Find("SearchInput");
|
|
|
|
|
|
if (searchInput != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ftname = searchInput.GetComponent<InputField>().text;
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
sorts = transform.Find("Panel").Find("Panel").Find("FilterOptions");
|
|
|
|
|
|
if (sorts != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var drop = sorts.GetComponent<Dropdown>();
|
|
|
|
|
|
drop.options = MapFilterOptions.sorts;
|
|
|
|
|
|
drop.value = 3;
|
|
|
|
|
|
drop.onValueChanged.AddListener((int index)=>
|
|
|
|
|
|
{
|
|
|
|
|
|
sort = drop.options[index].text;
|
|
|
|
|
|
var image = sortDir.Find("Image").GetComponent<Image>();
|
|
|
|
|
|
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
|
|
|
|
|
sortDire = "desc";
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
sortDir = transform.Find("Panel").Find("Panel").Find("Dir");
|
|
|
|
|
|
if (sortDir)
|
|
|
|
|
|
{
|
|
|
|
|
|
var image = sortDir.Find("Image").GetComponent<Image>();
|
|
|
|
|
|
sortDir.GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (image.sprite.name == "DOWN")
|
|
|
|
|
|
{
|
|
|
|
|
|
image.sprite = Resources.Load<Sprite>("Images/UP");
|
|
|
|
|
|
sortDire = "asc";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
|
|
|
|
|
sortDire = "desc";
|
|
|
|
|
|
}
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2021-03-25 16:55:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 15:57:29 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 绑定头像
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
void BindHeadImage()
|
|
|
|
|
|
{
|
|
|
|
|
|
var headImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
|
|
|
|
|
|
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
|
|
|
|
|
var rect = ((RectTransform)headImage.transform).rect;
|
|
|
|
|
|
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
|
|
|
|
|
headImage.material = material;
|
|
|
|
|
|
|
|
|
|
|
|
Utils.DisplayImage(StartCoroutine, headImage, App.CurrentUser.WxHeadImg);
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.AddEvent(headImage.gameObject, EventTriggerType.PointerClick, (e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowEditUserPanel();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-01 11:01:05 +08:00
|
|
|
|
private void OnEndDrag(BaseEventData arg0)
|
2021-03-25 16:55:36 +08:00
|
|
|
|
{
|
2021-04-01 11:01:05 +08:00
|
|
|
|
var scrollrect = scroll.GetComponent<ScrollRect>();
|
|
|
|
|
|
if (scrollrect.verticalNormalizedPosition <= 0)
|
2021-03-25 16:55:36 +08:00
|
|
|
|
{
|
2021-04-01 11:01:05 +08:00
|
|
|
|
Debug.Log(scrollrect.verticalNormalizedPosition);
|
|
|
|
|
|
pageIndex++;
|
|
|
|
|
|
GetList();
|
2021-03-25 16:55:36 +08:00
|
|
|
|
}
|
2021-04-01 11:01:05 +08:00
|
|
|
|
if (scrollrect.verticalNormalizedPosition >= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-09 15:57:50 +08:00
|
|
|
|
private void ChangeDistance(int index)
|
2021-04-01 11:01:05 +08:00
|
|
|
|
{
|
2021-04-09 15:57:50 +08:00
|
|
|
|
var text = distanceOptions.GetComponent<Dropdown>().options[index].text;
|
|
|
|
|
|
distance = MapFilterOptions.distanceDict[text];
|
|
|
|
|
|
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
|
|
|
|
|
Refresh();
|
2021-04-01 11:01:05 +08:00
|
|
|
|
//var text = hardSelector.options[index].text;
|
|
|
|
|
|
//if (text == "全部难度")
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
2021-03-25 16:55:36 +08:00
|
|
|
|
}
|
2021-04-09 15:57:50 +08:00
|
|
|
|
//查询条件
|
|
|
|
|
|
string ftname = "";
|
|
|
|
|
|
string distance = "";
|
|
|
|
|
|
List<string> hands = new List<string>();
|
|
|
|
|
|
bool is3d = false,isFav = false;
|
|
|
|
|
|
string sort = "Hot",sortDire = "desc";
|
|
|
|
|
|
//string name = "";
|
|
|
|
|
|
//string name = "";
|
2021-03-25 16:55:36 +08:00
|
|
|
|
public void GetList()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isEnd) return;
|
2021-04-09 15:57:50 +08:00
|
|
|
|
var res = ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
|
2021-03-25 16:55:36 +08:00
|
|
|
|
if (res.result)
|
|
|
|
|
|
{
|
2021-04-09 15:57:50 +08:00
|
|
|
|
if (res.data.Count == 0 && pageIndex != 0)
|
2021-03-25 16:55:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
isEnd = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-04-09 15:57:50 +08:00
|
|
|
|
isEnd = false;
|
2021-03-25 16:55:36 +08:00
|
|
|
|
DisplayMaps(res.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void DisplayMaps(List<MapRoute> list)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (map != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
var obj = Instantiate(map);
|
2021-04-09 09:44:06 +08:00
|
|
|
|
obj.GetComponent<MapItem>().Initial(item);
|
2021-03-25 16:55:36 +08:00
|
|
|
|
//obj.SendMessage("Initial", );
|
|
|
|
|
|
obj.transform.parent = content.transform;
|
|
|
|
|
|
obj.transform.localScale = new Vector3(1, 1, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Refresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
content.transform.DestroyChildren();
|
|
|
|
|
|
pageIndex = 0;
|
|
|
|
|
|
GetList();
|
|
|
|
|
|
}
|
2021-04-09 15:57:50 +08:00
|
|
|
|
void ResetList()
|
|
|
|
|
|
{
|
|
|
|
|
|
distance = "";
|
|
|
|
|
|
hands = new List<string>();
|
|
|
|
|
|
name = "";
|
|
|
|
|
|
Refresh();
|
|
|
|
|
|
}
|
2021-03-25 16:55:36 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|