对战界面&3d模型
This commit is contained in:
1 parent
4665feab7c
commit
597929cd32
130 files changed
+48220
-20627
No files matched your search
@@ -0,0 +1,31 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class GameRoomApi : ApiBase
|
||||
{
|
||||
public JsonResult<object> Add(GameRoomModel record, List<string> fileNames)
|
||||
{
|
||||
var result = Upload("GameRoom/Add", record, fileNames);
|
||||
var jsonResult = JsonConvert.DeserializeObject<JsonResult<object>>(result);
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<GameRoomModel>>> GetList(int pageIndex, int pageSize,int? id = null)
|
||||
{
|
||||
return await GetAsync<JsonResult<List<GameRoomModel>>>($"GameRoom/GetList?pageIndex={pageIndex}&pageSize={pageSize}&id={id}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<JObject>> GetDetail(int id)
|
||||
{
|
||||
return await GetAsync<JsonResult<JObject>>($"GameRoom/GetDetail?Id={id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21c3d62ae7900454aa0f6c1e95a0ceac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class GameRoomModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime StartTime { get; set; }
|
||||
public int CloseTime { get; set; }
|
||||
public int MaxMembers { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string WxHeadImg { get; set; }
|
||||
public string MapRouteName { get; set; }
|
||||
public bool Enable3D { get; set; }
|
||||
public bool EnableAR { get; set; }
|
||||
public bool IsLock { get; set; }
|
||||
public string AltitudeGraph { get; set; }
|
||||
public double AverageGrade { get; set; }
|
||||
public double Distance { get; set; }
|
||||
public double TotalClimb { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 509cf709d01091e4396af46896c7fef5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -78,5 +78,15 @@ namespace Assets.Scripts
|
||||
return _rowerApi;
|
||||
}
|
||||
}
|
||||
|
||||
private static GameRoomApi _gameRoomApi;
|
||||
public static GameRoomApi GameRoomApi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_gameRoomApi == null) _gameRoomApi = new GameRoomApi();
|
||||
return _gameRoomApi;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b51d137d095adf14688fd496c878e65f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,126 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using Assets.Scripts;
|
||||
|
||||
public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandler, IEndDragHandler,IScrollHandler
|
||||
{
|
||||
public Text IdTxt;
|
||||
public Text RouteNameTxt;
|
||||
public Text RouteNameLightTxt;
|
||||
public Text RoomNameTxt;
|
||||
|
||||
public Text DistanceTxt;
|
||||
public Text AltitudeGraphTxt;
|
||||
public Text GradeTxt;
|
||||
|
||||
public Text DistanceLightTxt;
|
||||
public Text AltitudeGraphLightTxt;
|
||||
public Text GradeLightTxt;
|
||||
|
||||
public Text MembersTxt;
|
||||
|
||||
public Image HoverBgImg;
|
||||
|
||||
public Image IconDitanceImg;
|
||||
public Image IconElevationImg;
|
||||
public Image IconGradeImg;
|
||||
|
||||
public Image IconDistanceLightImg;
|
||||
public Image IconElevationLightImg;
|
||||
public Image IconGradeLightImg;
|
||||
|
||||
public RawImage AltitudeGraphImg;
|
||||
|
||||
public RawImage Owner;
|
||||
public RawImage Head1;
|
||||
public RawImage Head2;
|
||||
public RawImage Head3;
|
||||
public RawImage Head4;
|
||||
public RawImage Head5;
|
||||
|
||||
public GameObject IconOwnerLight;
|
||||
|
||||
public GameObject JoinBtn;
|
||||
private ScrollRect Scroll;
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Rank { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Scroll = GetComponentInParent<ScrollRect>();
|
||||
UIManager.AddEvent(JoinBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
private float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
|
||||
//This is called from the SetCell method in DataSource
|
||||
public void ConfigureCell(GameRoomModel cell, int cellIndex)
|
||||
{
|
||||
RoomNameTxt.text = cell.Name;
|
||||
|
||||
var gradeText = $"{Math.Round(cell.AverageGrade,2)}%";
|
||||
GradeLightTxt.text = gradeText;
|
||||
GradeTxt.text = gradeText;
|
||||
|
||||
var distanceText = $"{Math.Round(cell.Distance,1)}KM";
|
||||
DistanceTxt.text = distanceText;
|
||||
DistanceLightTxt.text = distanceText;
|
||||
|
||||
var totalClimbText = $"{Math.Round(cell.TotalClimb)}M";
|
||||
AltitudeGraphTxt.text = totalClimbText;
|
||||
AltitudeGraphLightTxt.text = totalClimbText;
|
||||
|
||||
RouteNameTxt.text = cell.MapRouteName;
|
||||
RouteNameLightTxt.text = cell.MapRouteName;
|
||||
IdTxt.text = cell.Id.ToString().PadLeft(7,'0');
|
||||
|
||||
Utils.DisplayImage(AltitudeGraphImg, cell.AltitudeGraph);
|
||||
Utils.DisplayImage(Owner, cell.WxHeadImg);
|
||||
}
|
||||
public void UpdateItem(string name, string gender, string id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnBeginDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnEndDrag(eventData);
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
Scroll.OnScroll(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e41ced7d3258ef847b6fc96779d53bf2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomList : MonoBehaviour, IRecyclableScrollRectDataSource
|
||||
{
|
||||
[SerializeField]
|
||||
RecyclableScrollRect _recyclableScrollRect;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform _rectTransform;
|
||||
|
||||
[SerializeField]
|
||||
InputField _searchInputField;
|
||||
|
||||
[SerializeField]
|
||||
GameObject _searchBtn;
|
||||
|
||||
[SerializeField]
|
||||
private int _dataLength;
|
||||
private bool _isInit;
|
||||
|
||||
//Dummy data List
|
||||
private List<GameRoomModel> _list = new List<GameRoomModel>();
|
||||
|
||||
//Recyclable scroll rect's data source must be assigned in Awake.
|
||||
private void Awake()
|
||||
{
|
||||
_recyclableScrollRect.DataSource = this;
|
||||
_ = GetDataAsync();
|
||||
_searchInputField.onValueChanged.AddListener((e) => {
|
||||
if (!string.IsNullOrEmpty(e))
|
||||
{
|
||||
_ = GetDataAsync(Convert.ToInt32(e));
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(_searchBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Refreash);
|
||||
}
|
||||
private void Refreash(BaseEventData data)
|
||||
{
|
||||
_ = GetDataAsync();
|
||||
}
|
||||
private async Task GetDataAsync(int? id =null)
|
||||
{
|
||||
if (_list != null) _list.Clear();
|
||||
var result = await ConfigHelper.GameRoomApi.GetList(0, 1000, id);
|
||||
if (result.result)
|
||||
{
|
||||
_list = result.data;
|
||||
_recyclableScrollRect.ReloadData();
|
||||
}
|
||||
}
|
||||
float timer = 1f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
|
||||
#region DATA-SOURCE
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. return the list length.
|
||||
/// </summary>
|
||||
public int GetItemCount()
|
||||
{
|
||||
return _list.Count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data source method. Called for a cell every time it is recycled.
|
||||
/// Implement this method to do the necessary cell configuration.
|
||||
/// </summary>
|
||||
public void SetCell(ICell cell, int index)
|
||||
{
|
||||
//Casting to the implemented Cell
|
||||
var item = cell as GameRoomCell;
|
||||
item.ConfigureCell(_list[index], index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c114c143939361e41bd29f69f311e91c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
using Assets.Scripts;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameRoomListController : PFUIPanel
|
||||
{
|
||||
private RawImage Avatar;
|
||||
private GameObject CreateRoomBtn;
|
||||
private GameObject MapList;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
Avatar = transform.Find("Avatar").GetComponent<RawImage>();
|
||||
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);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
//创建房间
|
||||
private void CreateGameRoom(BaseEventData data)
|
||||
{
|
||||
MapList.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91e95d79d64980640a8c089210e5572c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -29,6 +29,7 @@ public class HomeController : PFUIPanel
|
||||
[SerializeField] Button BtnRide;
|
||||
[SerializeField] Transform userInfo;
|
||||
Transform BtnMatch, BtnTraining;
|
||||
Transform BtnBattle;
|
||||
private MainNav mainNav;
|
||||
private Dictionary<string, Sprite[]> dict;
|
||||
// Start is called before the first frame update
|
||||
@@ -55,6 +56,15 @@ public class HomeController : PFUIPanel
|
||||
});
|
||||
mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
|
||||
mainNav.ShowExit();
|
||||
|
||||
UIManager.AddEvent(transform.Find("TodayData/ChangePlayerBtn").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowChangePlayerPanel();
|
||||
});
|
||||
BtnBattle = transform.Find("MainFuncContainer/BtnBattle");
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerClick, GoGameRoom);
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerEnter, OnHover);
|
||||
UIManager.AddEvent(BtnBattle.gameObject, EventTriggerType.PointerExit, OnExit);
|
||||
#endif
|
||||
var BtnContainer = transform.Find("MainFuncContainer");
|
||||
UIManager.AddEvent(BtnRide.gameObject, EventTriggerType.PointerClick, GoRide);
|
||||
@@ -118,6 +128,10 @@ public class HomeController : PFUIPanel
|
||||
};
|
||||
|
||||
}
|
||||
private void GoGameRoom(BaseEventData e)
|
||||
{
|
||||
UIManager.ShowGameRoomListPanel();
|
||||
}
|
||||
private void GoRide(BaseEventData e)
|
||||
{
|
||||
Debug.Log(App.firstEnter.ToString());
|
||||
|
||||
@@ -97,6 +97,15 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("DevicePanel", ref this.mDeviceController);
|
||||
}
|
||||
}
|
||||
|
||||
private GameRoomListController mGameRoomListController;
|
||||
public GameRoomListController GameRoomListPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("GameRoomListPanel", ref this.mGameRoomListController);
|
||||
}
|
||||
}
|
||||
private SettingContoller mSettingContoller;
|
||||
public SettingContoller SettingModal
|
||||
{
|
||||
@@ -835,6 +844,11 @@ public class UIManager : MonoBehaviour
|
||||
UIManager.Show(UIManager.Instance.NewHomePanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
public static void ShowGameRoomListPanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.GameRoomListPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
public static void ShowDevicePanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, null, true);
|
||||
@@ -1092,6 +1106,34 @@ public class UIManager : MonoBehaviour
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//处理EventTrigger 拦截scroll事件触发问题
|
||||
var scrollView = gameObject.GetComponentInParent<ScrollRect>();
|
||||
if (scrollView != null)
|
||||
{
|
||||
EventTrigger.Entry entryBegin = new EventTrigger.Entry(), entryDrag = new EventTrigger.Entry(), entryEnd = new EventTrigger.Entry(), entrypotential = new EventTrigger.Entry()
|
||||
, entryScroll = new EventTrigger.Entry();
|
||||
|
||||
entryBegin.eventID = EventTriggerType.BeginDrag;
|
||||
entryBegin.callback.AddListener((data) => { scrollView.OnBeginDrag((PointerEventData)data); });
|
||||
et.triggers.Add(entryBegin);
|
||||
|
||||
entryDrag.eventID = EventTriggerType.Drag;
|
||||
entryDrag.callback.AddListener((data) => { scrollView.OnDrag((PointerEventData)data); });
|
||||
et.triggers.Add(entryDrag);
|
||||
|
||||
entryEnd.eventID = EventTriggerType.EndDrag;
|
||||
entryEnd.callback.AddListener((data) => { scrollView.OnEndDrag((PointerEventData)data); });
|
||||
et.triggers.Add(entryEnd);
|
||||
|
||||
entrypotential.eventID = EventTriggerType.InitializePotentialDrag;
|
||||
entrypotential.callback.AddListener((data) => { scrollView.OnInitializePotentialDrag((PointerEventData)data); });
|
||||
et.triggers.Add(entrypotential);
|
||||
|
||||
entryScroll.eventID = EventTriggerType.Scroll;
|
||||
entryScroll.callback.AddListener((data) => { scrollView.OnScroll((PointerEventData)data); });
|
||||
et.triggers.Add(entryScroll);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Close(MonoBehaviour obj)
|
||||
|
||||
Reference in new issue
Block a user