创建房间
This commit is contained in:
parent
597929cd32
commit
de8dd933e8
@ -19,6 +19,13 @@ public class ExportAssets : Editor
|
|||||||
GameObject game = Instantiate(prefab, Selection.activeTransform);
|
GameObject game = Instantiate(prefab, Selection.activeTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/UI/PFUIInputField", false, 100)]
|
||||||
|
static void CreatePFUIInputFieldCommand()
|
||||||
|
{
|
||||||
|
GameObject prefab = Resources.Load<GameObject>("UI/Control/PFUIInputField");
|
||||||
|
GameObject game = Instantiate(prefab, Selection.activeTransform);
|
||||||
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|||||||
3403
Assets/Resources/UI/Prefab/GameRoom/GameRoomMapItem.prefab
Normal file
3403
Assets/Resources/UI/Prefab/GameRoom/GameRoomMapItem.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5e5b68fa67717e542b3549918a2aa534
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -86,5 +86,7 @@ public static class PFConstants
|
|||||||
public static Color Yellow => new Color(0.8901961f, 0.8313726f, 0.1529412f, 0.6f);
|
public static Color Yellow => new Color(0.8901961f, 0.8313726f, 0.1529412f, 0.6f);
|
||||||
public static Color Orange => new Color(0.8901961f, 0.5686275f, 0.1529412f, 0.6f);
|
public static Color Orange => new Color(0.8901961f, 0.5686275f, 0.1529412f, 0.6f);
|
||||||
public static Color Red => new Color(0.8901961f, 0.2313726f, 0.1529412f, 0.6f);
|
public static Color Red => new Color(0.8901961f, 0.2313726f, 0.1529412f, 0.6f);
|
||||||
|
public static Color Pink => new Color(0.9764706f, 0.1882353f, 0.5254902f, 1f);
|
||||||
|
public static Color grey => new Color(0.3607843f, 0.3607843f, 0.4313726f, 1f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
281
Assets/Scripts/UI/Prefab/GameRoom/GameRoomMapItem.cs
Normal file
281
Assets/Scripts/UI/Prefab/GameRoom/GameRoomMapItem.cs
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
using Assets.Scripts;
|
||||||
|
using Assets.Scripts.Apis;
|
||||||
|
using Assets.Scripts.Apis.Models;
|
||||||
|
using DG.Tweening;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
||||||
|
public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler, IPointerUpHandler
|
||||||
|
{
|
||||||
|
public class PropNames
|
||||||
|
{
|
||||||
|
public static List<string> icons = new List<string> { "icon1", "icon2", "icon3" };
|
||||||
|
public static List<string> texts = new List<string> { "DistanceText", "EleText", "SlopeText" };
|
||||||
|
public static Dictionary<bool, string> colorDict = new Dictionary<bool, string>
|
||||||
|
{
|
||||||
|
{ true,"#ffffff"},{false,"#5c5c6e" }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public bool isModal = false;
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
GameRoomListController listController;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
width = this.GetComponent<RectTransform>().rect.width;
|
||||||
|
height = this.GetComponent<RectTransform>().rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
listController = FindObjectOfType<GameRoomListController>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
float? localY = null;
|
||||||
|
MapRoute map;
|
||||||
|
Dictionary<string, Texture> caches;
|
||||||
|
private MapRouteAreaItem area = null;
|
||||||
|
public void Initial(MapRoute myMap, Dictionary<string, Texture> caches, MapRouteAreaItem area = null)
|
||||||
|
{
|
||||||
|
if (caches != null)
|
||||||
|
{
|
||||||
|
this.caches = caches;
|
||||||
|
}
|
||||||
|
this.area = area;
|
||||||
|
map = myMap;
|
||||||
|
if (!isModal)
|
||||||
|
{
|
||||||
|
transform.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||||
|
transform.GetComponent<Button>().onClick.AddListener(Ride);
|
||||||
|
}
|
||||||
|
|
||||||
|
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||||
|
|
||||||
|
transform.Find("IdContainer/Text").GetComponent<Text>().text = $"#{myMap.Id}";
|
||||||
|
transform.Find("TimesContainer").gameObject.SetActive(myMap.MineCount > 0);
|
||||||
|
transform.Find("TimesContainer/Text").GetComponent<Text>().text = myMap.MineCountString;
|
||||||
|
transform.Find("Hot").gameObject.SetActive(myMap.IsFire);
|
||||||
|
var props = transform.Find("Props");
|
||||||
|
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance > 1000 ? "#0" : "#0.00")}KM";
|
||||||
|
props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString(myMap.TotalClimb > 1000 ? "#0" : "#0.00")}M";
|
||||||
|
props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
|
||||||
|
props.Find("rideText").GetComponent<Text>().text = myMap.TheHeat.ToString();
|
||||||
|
var tabContainer = transform.Find("TabContainer");
|
||||||
|
var diff = tabContainer.Find("Diff");
|
||||||
|
diff.Find("Text").GetComponent<Text>().text = myMap.Hard;
|
||||||
|
tabContainer.Find("3d").gameObject.SetActive(myMap.Enable3D);
|
||||||
|
tabContainer.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImage(myMap.CountryCode);
|
||||||
|
//if (!isModal)
|
||||||
|
//{
|
||||||
|
// transform.Find("CollectImg").GetComponent<Button>().onClick.RemoveAllListeners();
|
||||||
|
// transform.Find("CollectImg").GetComponent<Button>().onClick.AddListener(Collect);
|
||||||
|
//}
|
||||||
|
//transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
|
||||||
|
// UIManager.Instance.collectDict[myMap.IsFavorite];
|
||||||
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||||
|
//transform.Find("CollectImg").gameObject.SetActive(false);
|
||||||
|
#endif
|
||||||
|
transform.Find("BtnInfo").GetComponent<Button>().onClick.AddListener(Info);
|
||||||
|
transform.Find("BtnRide").GetComponent<Button>().onClick.AddListener(Ride);
|
||||||
|
|
||||||
|
Utils.DisplayImageTempDict(transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage, this.caches);
|
||||||
|
Utils.DisplayImageTempDict(transform.Find("MapHBImg").GetComponent<RawImage>(), myMap.AltitudeGraph, this.caches);
|
||||||
|
|
||||||
|
SetActive4Button(false);
|
||||||
|
|
||||||
|
var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
|
||||||
|
transform.Find("BtnContinue").gameObject.SetActive(isRecent);
|
||||||
|
transform.Find("BtnReride").gameObject.SetActive(isRecent);
|
||||||
|
transform.Find("MapHBImg").gameObject.SetActive(!isRecent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Ride()
|
||||||
|
{
|
||||||
|
var list = FindObjectsOfType<GameRoomMapItem>();
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
item.HiddenOutLine();
|
||||||
|
}
|
||||||
|
ShowOutLine();
|
||||||
|
listController.Select(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowOutLine()
|
||||||
|
{
|
||||||
|
var outlineDown = transform.Find("Panel").GetComponent<Outline>();
|
||||||
|
var outlineUp = transform.Find("MapTitleImg").GetComponent<Outline>();
|
||||||
|
outlineDown.effectDistance = new Vector2(2, 2);
|
||||||
|
outlineUp.effectDistance = new Vector2(2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HiddenOutLine()
|
||||||
|
{
|
||||||
|
var outlineDown = transform.Find("Panel").GetComponent<Outline>();
|
||||||
|
var outlineUp = transform.Find("MapTitleImg").GetComponent<Outline>();
|
||||||
|
outlineDown.effectDistance = new Vector2(0,0);
|
||||||
|
outlineUp.effectDistance = new Vector2(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Info()
|
||||||
|
{
|
||||||
|
UIManager.ShowMapDetailPanel(map.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerExit(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (isModal)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||||
|
if (localY != null)
|
||||||
|
{
|
||||||
|
transform.DOLocalMoveY(localY.Value, 0.3f);
|
||||||
|
}
|
||||||
|
//transform.Find("CollectImg").gameObject.SetActive(false);
|
||||||
|
transform.Find("Shadow").gameObject.SetActive(false);
|
||||||
|
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||||
|
SetColor(false);
|
||||||
|
#else
|
||||||
|
transform.Find("Shadow").GetComponent<Image>().DOFade(0, 0.3f);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
public void OnPointerEnter(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (isModal)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||||
|
if (localY == null)
|
||||||
|
{
|
||||||
|
localY = transform.localPosition.y;
|
||||||
|
}
|
||||||
|
//transform.Find("CollectImg").gameObject.SetActive(true);
|
||||||
|
transform.DOLocalMoveY(localY.Value + 5, 0.3f);
|
||||||
|
transform.Find("Shadow").gameObject.SetActive(true);
|
||||||
|
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
||||||
|
SetColor(true);
|
||||||
|
#else
|
||||||
|
transform.Find("Shadow").GetComponent<Image>().DOFade(1, 0.3f);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
void SetActive4Button(bool b)
|
||||||
|
{
|
||||||
|
transform.Find("MapHBImg").gameObject.SetActive(!b);
|
||||||
|
transform.Find("BtnInfo").gameObject.SetActive(b);
|
||||||
|
transform.Find("BtnRide").gameObject.SetActive(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetColor(bool isFav)
|
||||||
|
{
|
||||||
|
PropNames.icons.ForEach((v) =>
|
||||||
|
{
|
||||||
|
transform.Find("Props").Find(v).GetComponent<Image>().color = Utils.HexToColorHtml(
|
||||||
|
PropNames.colorDict[isFav]);
|
||||||
|
});
|
||||||
|
PropNames.texts.ForEach((v) =>
|
||||||
|
{
|
||||||
|
transform.Find("Props").Find(v).GetComponent<Text>().color = Utils.HexToColorHtml(
|
||||||
|
PropNames.colorDict[isFav]);
|
||||||
|
});
|
||||||
|
transform.Find("MapHBImg").GetComponent<RawImage>().color = Utils.HexToColorHtml(
|
||||||
|
PropNames.colorDict[isFav]);
|
||||||
|
}
|
||||||
|
async void Collect()
|
||||||
|
{
|
||||||
|
JsonResult<object> r;
|
||||||
|
//transform.Find("CollectImg").GetComponent<Button>().enabled = false;
|
||||||
|
if (map.IsFavorite)
|
||||||
|
{
|
||||||
|
r = await ConfigHelper.mapApi.CancelFav(map.Id.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = await ConfigHelper.mapApi.AddFav(map.Id.ToString());
|
||||||
|
}
|
||||||
|
transform.Find("CollectImg").GetComponent<Button>().enabled = true;
|
||||||
|
if (r.result)
|
||||||
|
{
|
||||||
|
map.IsFavorite = !map.IsFavorite;
|
||||||
|
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
|
||||||
|
UIManager.Instance.collectDict[map.IsFavorite];
|
||||||
|
if (this.model != null)
|
||||||
|
{
|
||||||
|
this.model.IsFavorite = map.IsFavorite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UIManager.ShowAlert("WARNING", r.errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NearRouteModel model { get; set; }
|
||||||
|
|
||||||
|
public void Show(Vector3 position, NearRouteModel model)
|
||||||
|
{
|
||||||
|
this.model = model;
|
||||||
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||||
|
this.Move(position);
|
||||||
|
#endif
|
||||||
|
this.gameObject.SetActive(true);
|
||||||
|
Initial(new MapRoute
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
Name = model.Name,
|
||||||
|
Hard = model.Hard,
|
||||||
|
CoverImage = model.CoverImage,
|
||||||
|
Enable3D = model.Enable3D,
|
||||||
|
TheHeat = model.TheHeat,
|
||||||
|
TotalClimb = model.TotalClimb,
|
||||||
|
AverageGrade = model.AverageGrade,
|
||||||
|
CountryCode = model.CountryCode,
|
||||||
|
AltitudeGraph = model.AltitudeGraph,
|
||||||
|
Distance = model.Distance,
|
||||||
|
IsFavorite = model.IsFavorite,
|
||||||
|
}, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Move(Vector3 position)
|
||||||
|
{
|
||||||
|
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||||
|
this.transform.position = position;
|
||||||
|
|
||||||
|
var localPosition = this.transform.localPosition;
|
||||||
|
localPosition.y = localPosition.y + (width * 2);
|
||||||
|
localPosition.x = localPosition.x - height;
|
||||||
|
|
||||||
|
this.transform.localPosition = localPosition;
|
||||||
|
this.transform.localScale = new Vector2(2, 2);
|
||||||
|
|
||||||
|
Debug.Log($"{ this.transform.localPosition.y }, { this.transform.localPosition.y }");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Hide()
|
||||||
|
{
|
||||||
|
#if UNITY_ANDROID || UNITY_IOS
|
||||||
|
this.gameObject.SetActive(false);
|
||||||
|
#else
|
||||||
|
DestroyImmediate(this.gameObject);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/UI/Prefab/GameRoom/GameRoomMapItem.cs.meta
Normal file
11
Assets/Scripts/UI/Prefab/GameRoom/GameRoomMapItem.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5b8467bb6fa339c4c9f6abbf32033a2a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,5 +1,9 @@
|
|||||||
|
|
||||||
using Assets.Scripts;
|
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 System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
@ -7,9 +11,31 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
public class GameRoomListController : PFUIPanel
|
public class GameRoomListController : PFUIPanel
|
||||||
{
|
{
|
||||||
|
[SerializeField] GameObject map;
|
||||||
private RawImage Avatar;
|
private RawImage Avatar;
|
||||||
private GameObject CreateRoomBtn;
|
private GameObject CreateRoomBtn;
|
||||||
private GameObject MapList;
|
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<string, Texture> caches = new Dictionary<string, Texture>();
|
||||||
|
private bool startMouse;
|
||||||
|
List<string> hands = new List<string>();
|
||||||
|
private int selectedRouteId;
|
||||||
|
private int pageIndex = 0;
|
||||||
|
private bool isEnd = false;
|
||||||
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
@ -22,19 +48,479 @@ public class GameRoomListController : PFUIPanel
|
|||||||
CreateRoomBtn = transform.Find("SwitchMode/GoList").gameObject;
|
CreateRoomBtn = transform.Find("SwitchMode/GoList").gameObject;
|
||||||
MapList = transform.Find("MapList").gameObject;
|
MapList = transform.Find("MapList").gameObject;
|
||||||
Utils.DisplayImage(Avatar, App.CurrentUser.WxHeadImg);
|
Utils.DisplayImage(Avatar, App.CurrentUser.WxHeadImg);
|
||||||
|
|
||||||
|
|
||||||
UIManager.AddEvent(CreateRoomBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, CreateGameRoom);
|
UIManager.AddEvent(CreateRoomBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, CreateGameRoom);
|
||||||
|
InitStep1();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||||
|
{
|
||||||
|
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||||
|
scroll.GetComponent<ScrollRect>().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<Dropdown>();
|
||||||
|
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<InputField>().onEndEdit.AddListener((s) =>
|
||||||
|
{
|
||||||
|
var t = searchInput.GetComponent<InputField>().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<Button>();
|
||||||
|
var image = t.GetComponent<Image>();
|
||||||
|
var text = t.Find("Text").GetComponent<Text>();
|
||||||
|
UIManager.AddEvent(button.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||||
|
{
|
||||||
|
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 = new Color(1, 1, 1, 1);
|
||||||
|
hands.Remove(MapFilterOptions.diffDict[text.text]);
|
||||||
|
}
|
||||||
|
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||||
|
Refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//排序条件
|
||||||
|
var sorts = topContainer.Find("FilterOptions");
|
||||||
|
if (sorts != null)
|
||||||
|
{
|
||||||
|
var drop = sorts.GetComponent<Dropdown>();
|
||||||
|
drop.options = MapFilterOptions.sorts;
|
||||||
|
drop.value = 0;
|
||||||
|
drop.onValueChanged.AddListener((int index) =>
|
||||||
|
{
|
||||||
|
var text = drop.options[index].text;
|
||||||
|
|
||||||
|
sort = MapFilterOptions.sortsDict[text];
|
||||||
|
if (sort == "Trend")
|
||||||
|
{
|
||||||
|
sort = "Hot";
|
||||||
|
}
|
||||||
|
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||||
|
if (sort == "Near")
|
||||||
|
{
|
||||||
|
image.sprite = Resources.Load<Sprite>("Images/UP");
|
||||||
|
sortDire = "asc";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||||
|
sortDire = "desc";
|
||||||
|
}
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//排序
|
||||||
|
sortDir = topContainer.Find("Dir");
|
||||||
|
if (sortDir)
|
||||||
|
{
|
||||||
|
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||||
|
UIManager.AddEvent(sortDir.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Refresh();
|
||||||
|
//下一步
|
||||||
|
step1Btn = transform.Find("MapList/Modal/Left/Step1Btn").gameObject;
|
||||||
|
step2Btn = transform.Find("MapList/Modal/Left/Step2Btn").gameObject;
|
||||||
|
next = transform.Find("MapList/Modal/Left/Next").gameObject;
|
||||||
|
previous = transform.Find("MapList/Modal/Left/Previous").gameObject;
|
||||||
|
create = transform.Find("MapList/Modal/Left/Create").gameObject;
|
||||||
|
cancel = transform.Find("MapList/Modal/Left/Cancel").gameObject;
|
||||||
|
right = transform.Find("MapList/Modal/Right").gameObject;
|
||||||
|
right2 = transform.Find("MapList/Modal/Right2").gameObject;
|
||||||
|
|
||||||
|
next.GetComponent<Button>().interactable = false;
|
||||||
|
next.GetComponent<Button>().enabled = false;
|
||||||
|
UIManager.AddEvent(next, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
next.SetActive(false);
|
||||||
|
previous.SetActive(true);
|
||||||
|
cancel.SetActive(false);
|
||||||
|
create.SetActive(true);
|
||||||
|
right2.SetActive(true);
|
||||||
|
right.SetActive(false);
|
||||||
|
step2Btn.transform.Find("Title").GetComponent<Text>().color = Color.white;
|
||||||
|
step1Btn.transform.Find("Title").GetComponent<Text>().color = PFConstants.grey;
|
||||||
|
previous.transform.Find("Text").GetComponent<Text>().color = Color.white;
|
||||||
|
step1Btn.transform.Find("Bg").gameObject.SetActive(false);
|
||||||
|
step2Btn.transform.Find("Bg").gameObject.SetActive(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
UIManager.AddEvent(previous, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
next.SetActive(true);
|
||||||
|
previous.SetActive(false);
|
||||||
|
cancel.SetActive(true);
|
||||||
|
create.SetActive(false);
|
||||||
|
right2.SetActive(false);
|
||||||
|
right.SetActive(true);
|
||||||
|
step1Btn.transform.Find("Title").GetComponent<Text>().color = Color.white;
|
||||||
|
step2Btn.transform.Find("Title").GetComponent<Text>().color = PFConstants.grey;
|
||||||
|
step1Btn.transform.Find("Bg").gameObject.SetActive(true);
|
||||||
|
step2Btn.transform.Find("Bg").gameObject.SetActive(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private GameObject step1Btn;
|
||||||
|
private GameObject step2Btn;
|
||||||
|
private GameObject next;
|
||||||
|
private GameObject previous;
|
||||||
|
private GameObject create;
|
||||||
|
private GameObject cancel;
|
||||||
|
|
||||||
|
private GameObject right;
|
||||||
|
private GameObject right2;
|
||||||
|
|
||||||
|
private string RoomName;
|
||||||
|
private string Roompwd;
|
||||||
|
private int hours;
|
||||||
|
private int mins;
|
||||||
|
private int CloseTime;
|
||||||
|
private int Members;
|
||||||
|
|
||||||
|
private void InitStep2()
|
||||||
|
{
|
||||||
|
var hourInputField = right2.transform.Find("HourInputField").GetComponent<InputField>();
|
||||||
|
var minInputField = right2.transform.Find("MinInputField").GetComponent<InputField>();
|
||||||
|
var roomNameInputField = right2.transform.Find("RoomNameInputField").GetComponent<InputField>();
|
||||||
|
var passwordInputField = right2.transform.Find("PasswordInputField").GetComponent<InputField>();
|
||||||
|
//房间名
|
||||||
|
roomNameInputField.onValueChanged.AddListener((e) => {
|
||||||
|
RoomName = e;
|
||||||
|
});
|
||||||
|
//房间密码
|
||||||
|
passwordInputField.onValueChanged.AddListener((e) => {
|
||||||
|
Roompwd = e;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(minInputField.gameObject, EventTriggerType.Select, (e) => {
|
||||||
|
hourInputField.GetComponent<Outline>().enabled = true;
|
||||||
|
});
|
||||||
|
//关门时间
|
||||||
|
var btn30 = right2.transform.Find("btn30").gameObject;
|
||||||
|
var btn40 = right2.transform.Find("btn40").gameObject;
|
||||||
|
var btn50 = right2.transform.Find("btn50").gameObject;
|
||||||
|
var btn60 = right2.transform.Find("btn60").gameObject;
|
||||||
|
ColorUtility.TryParseHtmlString("#3D3E4D", out Color grey);
|
||||||
|
ColorUtility.TryParseHtmlString("#F93086", out Color pink);
|
||||||
|
UIManager.AddEvent(btn30,EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
CloseTime = 30;
|
||||||
|
btn30.GetComponent<Image>().color = pink;
|
||||||
|
btn40.GetComponent<Image>().color = grey;
|
||||||
|
btn50.GetComponent<Image>().color = grey;
|
||||||
|
btn60.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn40, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
CloseTime = 40;
|
||||||
|
btn30.GetComponent<Image>().color = grey;
|
||||||
|
btn40.GetComponent<Image>().color = pink;
|
||||||
|
btn50.GetComponent<Image>().color = grey;
|
||||||
|
btn60.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn50, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
CloseTime = 50;
|
||||||
|
btn30.GetComponent<Image>().color = grey;
|
||||||
|
btn40.GetComponent<Image>().color = grey;
|
||||||
|
btn50.GetComponent<Image>().color = pink;
|
||||||
|
btn60.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn60, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
CloseTime = 60;
|
||||||
|
btn30.GetComponent<Image>().color = grey;
|
||||||
|
btn40.GetComponent<Image>().color = grey;
|
||||||
|
btn50.GetComponent<Image>().color = grey;
|
||||||
|
btn60.GetComponent<Image>().color = pink;
|
||||||
|
});
|
||||||
|
|
||||||
|
hourInputField.onValueChanged.AddListener((e) => {
|
||||||
|
hours = Convert.ToInt32(e);
|
||||||
|
CloseTime = hours * 60 + mins;
|
||||||
|
btn30.GetComponent<Image>().color = grey;
|
||||||
|
btn40.GetComponent<Image>().color = grey;
|
||||||
|
btn50.GetComponent<Image>().color = grey;
|
||||||
|
btn60.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
minInputField.onValueChanged.AddListener((e) => {
|
||||||
|
mins = Convert.ToInt32(e);
|
||||||
|
CloseTime = hours * 60 + mins;
|
||||||
|
btn30.GetComponent<Image>().color = grey;
|
||||||
|
btn40.GetComponent<Image>().color = grey;
|
||||||
|
btn50.GetComponent<Image>().color = grey;
|
||||||
|
btn60.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
//房间人数
|
||||||
|
var btn2 = right2.transform.Find("btn2").gameObject;
|
||||||
|
var btn3 = right2.transform.Find("btn3").gameObject;
|
||||||
|
var btn4 = right2.transform.Find("btn4").gameObject;
|
||||||
|
var btn5 = right2.transform.Find("btn5").gameObject;
|
||||||
|
var btn6 = right2.transform.Find("btn6").gameObject;
|
||||||
|
UIManager.AddEvent(btn2, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
Members = 2;
|
||||||
|
btn2.GetComponent<Image>().color = pink;
|
||||||
|
btn3.GetComponent<Image>().color = grey;
|
||||||
|
btn4.GetComponent<Image>().color = grey;
|
||||||
|
btn5.GetComponent<Image>().color = grey;
|
||||||
|
btn6.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn3, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
Members = 3;
|
||||||
|
btn2.GetComponent<Image>().color = grey;
|
||||||
|
btn3.GetComponent<Image>().color = pink;
|
||||||
|
btn4.GetComponent<Image>().color = grey;
|
||||||
|
btn5.GetComponent<Image>().color = grey;
|
||||||
|
btn6.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn4, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
Members = 4;
|
||||||
|
btn2.GetComponent<Image>().color = grey;
|
||||||
|
btn3.GetComponent<Image>().color = grey;
|
||||||
|
btn4.GetComponent<Image>().color = pink;
|
||||||
|
btn5.GetComponent<Image>().color = grey;
|
||||||
|
btn6.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn5, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
Members = 5;
|
||||||
|
btn2.GetComponent<Image>().color = grey;
|
||||||
|
btn3.GetComponent<Image>().color = grey;
|
||||||
|
btn4.GetComponent<Image>().color = grey;
|
||||||
|
btn5.GetComponent<Image>().color = pink;
|
||||||
|
btn6.GetComponent<Image>().color = grey;
|
||||||
|
});
|
||||||
|
UIManager.AddEvent(btn6, EventTriggerType.PointerClick, (e) =>
|
||||||
|
{
|
||||||
|
Members = 6;
|
||||||
|
btn2.GetComponent<Image>().color = grey;
|
||||||
|
btn3.GetComponent<Image>().color = grey;
|
||||||
|
btn4.GetComponent<Image>().color = grey;
|
||||||
|
btn5.GetComponent<Image>().color = grey;
|
||||||
|
btn6.GetComponent<Image>().color = pink;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void ChangeDistance(int index)
|
||||||
|
{
|
||||||
|
var text = distanceOptions.GetComponent<Dropdown>().options[index].text;
|
||||||
|
distance = MapFilterOptions.distanceDict[text];
|
||||||
|
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
private void OnEndDrag(BaseEventData arg0)
|
||||||
|
{
|
||||||
|
var scrollrect = scroll.GetComponent<ScrollRect>();
|
||||||
|
if (scrollrect.verticalNormalizedPosition < 0)
|
||||||
|
{
|
||||||
|
pageIndex++;
|
||||||
|
GetList();
|
||||||
|
}
|
||||||
|
if (scrollrect.verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||||
|
{
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Select(MapRoute map)
|
||||||
|
{
|
||||||
|
selectedRouteId = map.Id;
|
||||||
|
next.GetComponent<Image>().color = PFConstants.Pink;
|
||||||
|
next.transform.Find("Text").GetComponent<Text>().color = Color.white;
|
||||||
|
next.GetComponent<Button>().interactable = true;
|
||||||
|
next.GetComponent<Button>().enabled = true;
|
||||||
|
//Right2绑定值
|
||||||
|
var rawImage = right2.transform.Find("RawImage").GetComponent<RawImage>();
|
||||||
|
var MapHBImg = right2.transform.Find("MapHBImg").GetComponent<RawImage>();
|
||||||
|
var Country = right2.transform.Find("TabContainer/Country").GetComponent<RawImage>();
|
||||||
|
var routeName = right2.transform.Find("Name").GetComponent<Text>();
|
||||||
|
right2.transform.Find("Id").GetComponent<Text>().text = map.Id.ToString().PadLeft(7,'0');
|
||||||
|
Utils.DisplayImageTempDict(rawImage, map.CoverImage, this.caches);
|
||||||
|
Utils.DisplayImageTempDict(MapHBImg.GetComponent<RawImage>(), map.AltitudeGraph, this.caches);
|
||||||
|
|
||||||
|
right2.transform.Find("Name").GetComponent<Text>().text = map.Name;
|
||||||
|
var props = right2.transform.Find("Props");
|
||||||
|
props.Find("DistanceText").GetComponent<Text>().text = $"{map.Distance.ToString(map.Distance > 1000 ? "#0" : "#0.00")}KM";
|
||||||
|
props.Find("EleText").GetComponent<Text>().text = $"{(map.TotalClimb ?? 0.0).ToString(map.TotalClimb > 1000 ? "#0" : "#0.00")}M";
|
||||||
|
props.Find("SlopeText").GetComponent<Text>().text = $"{map.AverageGrade.ToString("#0.00")}%";
|
||||||
|
props.Find("rideText").GetComponent<Text>().text = map.TheHeat.ToString();
|
||||||
|
var tabContainer = right2.transform.Find("TabContainer");
|
||||||
|
var diff = tabContainer.Find("Diff");
|
||||||
|
diff.Find("Text").GetComponent<Text>().text = map.Hard;
|
||||||
|
tabContainer.Find("3d").gameObject.SetActive(map.Enable3D);
|
||||||
|
tabContainer.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImage(map.CountryCode);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void Refresh()
|
||||||
|
{
|
||||||
|
content.transform.DestroyChildren();
|
||||||
|
pageIndex = 0;
|
||||||
|
isEnd = false;
|
||||||
|
GetList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onEndEdit()
|
||||||
|
{
|
||||||
|
var t = searchInput.GetComponent<InputField>().text;
|
||||||
|
ftname = t;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayMaps(List<MapRoute> list)
|
||||||
|
{
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
var obj = Instantiate(map);
|
||||||
|
obj.GetComponent<GameRoomMapItem>().Initial(item, caches);
|
||||||
|
//obj.SendMessage("Initial", );
|
||||||
|
obj.transform.SetParent(content.transform);
|
||||||
|
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async void GetList()
|
||||||
|
{
|
||||||
|
if (isEnd) return;
|
||||||
|
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname, distance, string.Join(",", hands), is3d, sort, sortDire);
|
||||||
|
if (res.result)
|
||||||
|
{
|
||||||
|
if (res.data.Count == 0)
|
||||||
|
{
|
||||||
|
if (pageIndex != 0)
|
||||||
|
{
|
||||||
|
isEnd = true;
|
||||||
|
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("当前没查到内容");
|
||||||
|
scroll.transform.Find("Error").gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isEnd = false;
|
||||||
|
DisplayMaps(res.data);
|
||||||
|
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//创建房间
|
//创建房间
|
||||||
private void CreateGameRoom(BaseEventData data)
|
private void CreateGameRoom(BaseEventData data)
|
||||||
{
|
{
|
||||||
MapList.SetActive(true);
|
MapList.SetActive(true);
|
||||||
|
InitStep2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user