加入房间,踢人,准备等tcp命令
This commit is contained in:
1 parent
de8dd933e8
commit
06582201fa
101 files changed
+246552
-565
No files matched your search
@@ -11,11 +11,16 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class GameRoomApi : ApiBase
|
||||
{
|
||||
public JsonResult<object> Add(GameRoomModel record, List<string> fileNames)
|
||||
public async Task<JsonResult<object>> Add(string name,int routeId,string pwd,DateTime startTime,int closeTime,int maxMembers)
|
||||
{
|
||||
var result = Upload("GameRoom/Add", record, fileNames);
|
||||
var jsonResult = JsonConvert.DeserializeObject<JsonResult<object>>(result);
|
||||
return jsonResult;
|
||||
return await PostAsync<JsonResult<object>>($"GameRoom/Add", new {
|
||||
name,
|
||||
routeId,
|
||||
pwd,
|
||||
startTime,
|
||||
closeTime,
|
||||
maxMembers
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<GameRoomModel>>> GetList(int pageIndex, int pageSize,int? id = null)
|
||||
@@ -23,9 +28,14 @@ namespace Assets.Scripts.Apis
|
||||
return await GetAsync<JsonResult<List<GameRoomModel>>>($"GameRoom/GetList?pageIndex={pageIndex}&pageSize={pageSize}&id={id}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<JObject>> GetDetail(int id)
|
||||
public JsonResult<GameRoomModel> GetDetail(int id)
|
||||
{
|
||||
return await GetAsync<JsonResult<JObject>>($"GameRoom/GetDetail?Id={id}");
|
||||
return Get<JsonResult<GameRoomModel>>($"GameRoom/GetDetail?Id={id}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<JObject>> ConfirmRoomPwd(int id,string pwd)
|
||||
{
|
||||
return await GetAsync<JsonResult<JObject>>($"GameRoom/ConfirmRoomPwd?id={id}&pwd={pwd}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
public int MaxMembers { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string WxHeadImg { get; set; }
|
||||
public string MapRouteName { get; set; }
|
||||
@@ -25,5 +26,13 @@ namespace Assets.Scripts.Apis.Models
|
||||
public double AverageGrade { get; set; }
|
||||
public double Distance { get; set; }
|
||||
public double TotalClimb { get; set; }
|
||||
//视频文件名
|
||||
public string FileName { get; set; }
|
||||
public int MapRouteId { get; set; }
|
||||
//详情
|
||||
public string BestNickName { get; set; }
|
||||
public string BestWxHeadImg { get; set; }
|
||||
public string BestTotalTime { get; set; }
|
||||
public string FileUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ public static class App
|
||||
public static IDictionary<string, Texture> TextureCache = new Dictionary<string, Texture>();
|
||||
public static Texture CurrentUserHeadTexture;
|
||||
public static RouteResult routeResult;//骑行记录向骑行场景传值
|
||||
public static GameRoomModel gameRoomDetail;
|
||||
public static Texture DefaultRotateTexture { get; set; }
|
||||
//全局用 输入框或者下拉框修改标志位
|
||||
public static bool isChanged { get; set; }
|
||||
|
||||
@@ -413,7 +413,7 @@ public class MainController : BaseScene
|
||||
//App.MainDeviceAdapter.StopScan();
|
||||
//Debug.Log("StopScan");
|
||||
}
|
||||
MapUDPService.Send(0, App.CurrentUser.Id, new double[]{ 0d,0d}, competitionId: 0);
|
||||
MapUDPService.Send(0, App.CurrentUser.Id, new double[]{ 0d,0d}, competitionId: 0,roomId:(App.gameRoomDetail?.Id ?? 0));
|
||||
//发送消息
|
||||
|
||||
var list = MapUDPService.GetAllOnlineUserList();
|
||||
|
||||
@@ -8,11 +8,43 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts.Model
|
||||
{
|
||||
public class VideoMapModel {
|
||||
public double x { get; set; }
|
||||
public double y { get; set; }
|
||||
public double speed { get; set; }
|
||||
public int position { get; set; }
|
||||
public class RoomDetailModel
|
||||
{
|
||||
public int RoomId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public DateTime JoinAt { get; set; }
|
||||
public int Status { get; set; }
|
||||
public double Process { get; set; }
|
||||
public bool IsOwner { get; set; }
|
||||
|
||||
public static RoomDetailModel Parse(string msg)
|
||||
{
|
||||
var detail = new RoomDetailModel();
|
||||
try
|
||||
{
|
||||
var arr = msg.Split(',');
|
||||
detail.RoomId = Convert.ToInt32(arr[0], CultureInfo.InvariantCulture);
|
||||
detail.UserId = Convert.ToInt32(arr[1], CultureInfo.InvariantCulture);
|
||||
detail.JoinAt = Convert.ToDateTime(arr[2], CultureInfo.InvariantCulture);
|
||||
detail.Status = Convert.ToInt32(arr[3], CultureInfo.InvariantCulture);
|
||||
detail.Process = Convert.ToDouble(arr[4], CultureInfo.InvariantCulture);
|
||||
detail.IsOwner = Convert.ToBoolean(arr[5], CultureInfo.InvariantCulture);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
public class JoinGameRoomCommand
|
||||
{
|
||||
public byte CommandType { get; set; }
|
||||
public byte SubType { get; set; }
|
||||
public int V { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public DateTime JoinAt { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 排名
|
||||
@@ -378,6 +410,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
//public int V { get; set; }
|
||||
|
||||
public int FrameRate { get; set; }
|
||||
public int RoomId { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
}
|
||||
|
||||
public class GzipMsgModel
|
||||
@@ -439,17 +473,25 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
public string WatchIdList { get; set; }
|
||||
|
||||
public int? FrameRate { get; set; }
|
||||
public int? RoomId { get; set; }
|
||||
public RoomDetailModel RoomDetail { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
|
||||
public static ReceiveMsgModel Parse(string str)
|
||||
{
|
||||
var list = str.Split(',');
|
||||
if (list.Length != 15)
|
||||
if (list.Length < 14)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DateTime ? startTime = null;// string.IsNullOrEmpty(list[16]) ? null : Convert.ToDateTime(list[16], CultureInfo.InvariantCulture);
|
||||
if (!string.IsNullOrEmpty(list[16]))
|
||||
{
|
||||
startTime = Convert.ToDateTime(list[16], CultureInfo.InvariantCulture);
|
||||
}
|
||||
return new ReceiveMsgModel
|
||||
{
|
||||
RouteId = Convert.ToInt32(list[0],CultureInfo.InvariantCulture),
|
||||
@@ -468,9 +510,11 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
Cadence = Convert.ToDouble(list[12], CultureInfo.InvariantCulture),
|
||||
TotoalTicks = Convert.ToInt32(list[13], CultureInfo.InvariantCulture),
|
||||
FrameRate = Convert.ToInt32(list[14], CultureInfo.InvariantCulture),
|
||||
//RoomId = Convert.ToInt32(list[15], CultureInfo.InvariantCulture),
|
||||
//StartTime = startTime,
|
||||
};
|
||||
}
|
||||
catch
|
||||
catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -601,6 +645,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public int? FrameRate { get; set; }
|
||||
|
||||
public RoomDetailModel RoomDetail { get; set; }
|
||||
}
|
||||
|
||||
public class KeyPaire
|
||||
|
||||
@@ -110,36 +110,108 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Compress(string text)
|
||||
|
||||
//获取房间人物列表
|
||||
private static void SendGameRoomListPlayers(int[] roomIds)
|
||||
{
|
||||
var bytes = Encoding.Unicode.GetBytes(text);
|
||||
using (var mso = new MemoryStream())
|
||||
var model = new
|
||||
{
|
||||
using (var gs = new GZipStream(mso, CompressionMode.Compress))
|
||||
{
|
||||
gs.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
return mso.ToArray();
|
||||
}
|
||||
CommandType = 3,
|
||||
SubType = 0,
|
||||
V = 2,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
//加入对战房间
|
||||
public static void SendJoinGameRoom(int roomId, int userId,DateTime startTime)
|
||||
{
|
||||
var model = new
|
||||
{
|
||||
CommandType = 3,
|
||||
SubType = 1,
|
||||
UserId = userId,
|
||||
RoomId = roomId,
|
||||
JoinAt = startTime,
|
||||
V = 2,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
//发送准备状态
|
||||
public static void SendGameRoomReadyStatus(int roomId, int userId,int status)
|
||||
{
|
||||
var model = new
|
||||
{
|
||||
CommandType = 3,
|
||||
SubType = 2,
|
||||
UserId = userId,
|
||||
RoomId = roomId,
|
||||
Status = status,
|
||||
V = 2,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
//发送对战开始时间
|
||||
public static void SendGameRoomStartTime(int roomId,DateTime startTime)
|
||||
{
|
||||
var model = new
|
||||
{
|
||||
CommandType = 3,
|
||||
SubType = 3,
|
||||
RoomId = roomId,
|
||||
StartTime = startTime,
|
||||
V = 2,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
//踢人
|
||||
public static void SendGameRoomKick(int roomId,int userId,int onwerId)
|
||||
{
|
||||
var model = new
|
||||
{
|
||||
CommandType = 3,
|
||||
SubType = 4,
|
||||
RoomId = roomId,
|
||||
UserId = userId,
|
||||
OnwerId = onwerId,
|
||||
V = 2,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
|
||||
public static string Decompress(byte[] data)
|
||||
//发送当前loading进度
|
||||
private static void SendGameRoomLoadingProcess(int roomId, int userId,int process)
|
||||
{
|
||||
// Read the last 4 bytes to get the length
|
||||
byte[] lengthBuffer = new byte[4];
|
||||
Array.Copy(data, data.Length - 4, lengthBuffer, 0, 4);
|
||||
int uncompressedSize = BitConverter.ToInt32(lengthBuffer, 0);
|
||||
|
||||
var buffer = new byte[uncompressedSize];
|
||||
using (var ms = new MemoryStream(data))
|
||||
var model = new
|
||||
{
|
||||
using (var gzip = new GZipStream(ms, CompressionMode.Decompress))
|
||||
{
|
||||
gzip.Read(buffer, 0, uncompressedSize);
|
||||
}
|
||||
}
|
||||
return Encoding.Unicode.GetString(buffer);
|
||||
CommandType = 3,
|
||||
SubType = 5,
|
||||
V = 2,
|
||||
RoomId = roomId,
|
||||
UserId = userId,
|
||||
Process = process,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
|
||||
private static void SendGameRoomBaseMsg(int roomId, int userId,int process)
|
||||
{
|
||||
var model = new
|
||||
{
|
||||
CommandType = 3,
|
||||
V = 2,
|
||||
RoomId = roomId,
|
||||
UserId = userId,
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
_udpService.Send(sendBytes, sendBytes.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送心跳包
|
||||
/// </summary>
|
||||
@@ -207,7 +279,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
/// <param name="exit">是否退出</param>
|
||||
public static void Send(int RouteId, int MemberId, double[] Point, bool IsCompleted = false, bool exit = false,
|
||||
double endDistance = 0, bool showVirtual = false, byte commandType = 1, double speed = 0, bool isVirtual = false, double preDistance = 0,
|
||||
double weightKg = 0, int competitionId = 0, bool saved = false,double? heartRate = 0, double power = 0, double? cadence = 0,int totalTicks = 0, int frameRate = 0)
|
||||
double weightKg = 0, int competitionId = 0, bool saved = false,double? heartRate = 0, double power = 0, double? cadence = 0,int totalTicks = 0, int frameRate = 0, int roomId = 0,DateTime? startTime = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -235,7 +307,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
WeightKg = weightKg,
|
||||
Competitionid = competitionId,
|
||||
Saved = saved,
|
||||
FrameRate = frameRate
|
||||
FrameRate = frameRate,
|
||||
RoomId = roomId,//房间Id
|
||||
StartTime = startTime
|
||||
//V = 1
|
||||
};
|
||||
var sendBytes = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(model));
|
||||
@@ -282,7 +356,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public static List<OnlineUser> GetGameRoomList(int roomId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return onlineUserHelper.OnlineUsers.Where(c => c.RoomDetail != null && c.RoomDetail.RoomId == roomId).OrderBy(c=>c.Id).ToList();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static OnlineUser GetOnlineUserLastDataById(int userId)
|
||||
{
|
||||
@@ -493,6 +578,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
user.IsWatcher = user.WatcherList.Contains(item.MemberId);
|
||||
user.CreateTime = DateTime.MaxValue;
|
||||
user.FrameRate = item.FrameRate;
|
||||
user.RoomDetail = item.RoomDetail;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -196,6 +196,21 @@ namespace Assets.Scenes.Ride.Scripts.Network
|
||||
o.WatchIdList = w;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (t.IndexOf('g') == 0)
|
||||
{
|
||||
var g = t.Replace("g{", "").Replace("}", "");
|
||||
var glist = g.Split('|');
|
||||
foreach (var i in glist)
|
||||
{
|
||||
var gameRoom = RoomDetailModel.Parse(i);
|
||||
var owner = list.Where(c => c.MemberId == gameRoom.UserId).FirstOrDefault();
|
||||
if (owner != null)
|
||||
{
|
||||
owner.RoomDetail = gameRoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_action(list);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
}
|
||||
protected override int GetCurrentFrame()
|
||||
{
|
||||
return (int)(diff * 10) + manager.GetCurrentFrame();
|
||||
return this.currentFrame;//(int)(diff * 10) + manager.GetCurrentFrame();
|
||||
}
|
||||
protected override void ComputeVideo()
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Assets.Scripts.Scenes.VideoRide
|
||||
power = manager.UpdatePower();
|
||||
cadance = manager.UpdateCadence();
|
||||
//#if UNITY_EDITOR
|
||||
power = 50;
|
||||
power = 350;
|
||||
cadance = 150;
|
||||
heartRate = 160;
|
||||
//#endif
|
||||
|
||||
@@ -49,18 +49,44 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
public GameObject IconOwnerLight;
|
||||
|
||||
public GameObject JoinBtn;
|
||||
public GameObject Lock;
|
||||
public GameObject LockL;
|
||||
private ScrollRect Scroll;
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Rank { get; set; }
|
||||
public string Name { get; set; }
|
||||
private bool IsLock;
|
||||
|
||||
private int Id;
|
||||
|
||||
private string FileName;
|
||||
|
||||
private GameRoomListController manager;
|
||||
private GameRoomModel gameRoom;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
manager = FindObjectOfType<GameRoomListController>();
|
||||
Scroll = GetComponentInParent<ScrollRect>();
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerEnter, (e) =>
|
||||
{
|
||||
LockL.SetActive(IsLock);
|
||||
Lock.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
LockL.SetActive(false);
|
||||
Lock.SetActive(IsLock);
|
||||
});
|
||||
UIManager.AddEvent(JoinBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
|
||||
manager.SelectRoom(gameRoom);
|
||||
if (IsLock)
|
||||
{
|
||||
manager.ShowPwdConfirm();
|
||||
}
|
||||
else
|
||||
{
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
});
|
||||
}
|
||||
private float timer = 1f;
|
||||
@@ -76,8 +102,9 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
//This is called from the SetCell method in DataSource
|
||||
public void ConfigureCell(GameRoomModel cell, int cellIndex)
|
||||
{
|
||||
gameRoom = cell;
|
||||
RoomNameTxt.text = cell.Name;
|
||||
|
||||
FileName = cell.FileName;
|
||||
var gradeText = $"{Math.Round(cell.AverageGrade,2)}%";
|
||||
GradeLightTxt.text = gradeText;
|
||||
GradeTxt.text = gradeText;
|
||||
@@ -94,6 +121,11 @@ public class GameRoomCell : MonoBehaviour, ICell, IBeginDragHandler, IDragHandle
|
||||
RouteNameLightTxt.text = cell.MapRouteName;
|
||||
IdTxt.text = cell.Id.ToString().PadLeft(7,'0');
|
||||
|
||||
IsLock = cell.IsLock;
|
||||
Id = cell.Id;
|
||||
|
||||
Lock.SetActive(IsLock);
|
||||
LockL.SetActive(false);
|
||||
Utils.DisplayImage(AltitudeGraphImg, cell.AltitudeGraph);
|
||||
Utils.DisplayImage(Owner, cell.WxHeadImg);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using PolyAndCode.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomDownLoad : MonoBehaviour
|
||||
{
|
||||
public GameObject step1;
|
||||
public GameObject step2;
|
||||
public GameObject step3;
|
||||
|
||||
public GameObject downloadBtn;
|
||||
public GameObject backBtn;
|
||||
|
||||
public Slider downloadSlider;
|
||||
public GameObject runInbackBtn;
|
||||
|
||||
public GameObject enterBtn;
|
||||
public GameObject cancelBtn;
|
||||
|
||||
public GameObject downLoadList;
|
||||
public GameObject downLoadTask;
|
||||
|
||||
private GameRoomListController manager;
|
||||
private int RoomId { get; set; }
|
||||
private string FileName { get; set; }
|
||||
private string FileUrl { get; set; }
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, DownloadClick);
|
||||
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick);
|
||||
|
||||
UIManager.AddEvent(runInbackBtn, EventTriggerType.PointerClick, (d) =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
downLoadList.SetActive(true);
|
||||
var content = downLoadList.transform.Find("Scroll View/Viewport/Content");
|
||||
var list = FindObjectsOfType<GameRoomDownloadTask>();
|
||||
//新增
|
||||
var obj = list.Where(c => c.RoomId == RoomId).FirstOrDefault();
|
||||
if (obj == null)
|
||||
{
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
newtask.GetComponent<GameRoomDownloadTask>().Init(RoomId, gameObject);
|
||||
}
|
||||
});
|
||||
|
||||
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, (ee) =>
|
||||
{
|
||||
manager.GetInRoom();
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(cancelBtn, EventTriggerType.PointerClick, (ee) =>
|
||||
{
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int Id,string fileName,string url, GameRoomListController gameRoomListController)
|
||||
{
|
||||
RoomId = Id;
|
||||
FileName = fileName;
|
||||
FileUrl = url;
|
||||
manager = gameRoomListController;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
step2.SetActive(false);
|
||||
step3.SetActive(false);
|
||||
downloadSlider.value = 0f;
|
||||
}
|
||||
private void CancelClick(BaseEventData data)
|
||||
{
|
||||
Reset();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void DownloadClick(BaseEventData baseEventData)
|
||||
{
|
||||
var fileName = FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
var url = FileUrl;
|
||||
|
||||
step2.SetActive(true);
|
||||
|
||||
//新增
|
||||
var content = downLoadList.transform.Find("Scroll View/Viewport/Content");
|
||||
var newtask = Instantiate(downLoadTask, content);
|
||||
var currentTask = newtask.GetComponent<GameRoomDownloadTask>();
|
||||
currentTask.Init(RoomId, gameObject);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadVideo(fileName, url
|
||||
, (p, req) =>
|
||||
{
|
||||
downloadSlider.value = p;
|
||||
currentTask.UpdateProcess(p);
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
currentTask.UpdateProcess(100f);
|
||||
downloadSlider.value = 100f;
|
||||
step3.SetActive(true);
|
||||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 339fd75283bc4ae4caf3d8a4b00b6cad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomDownloadTask : MonoBehaviour
|
||||
{
|
||||
public GameObject btn;
|
||||
public Slider slider;
|
||||
public GameObject icon;
|
||||
private GameObject modal;
|
||||
|
||||
public GameObject done;
|
||||
public GameObject doneTxt;
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
modal.SetActive(true);
|
||||
transform.parent.parent.parent.parent.gameObject.SetActive(false);
|
||||
//TODO:
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int roomId,GameObject parent)
|
||||
{
|
||||
RoomId = roomId;
|
||||
modal = parent;
|
||||
}
|
||||
|
||||
public void UpdateProcess(float process)
|
||||
{
|
||||
slider.value = process;
|
||||
if (process >= 100)
|
||||
{
|
||||
done.SetActive(true);
|
||||
doneTxt.SetActive(true);
|
||||
icon.SetActive(false);
|
||||
slider.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e49b4427b935aa42b1c477c08b61661
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,6 +5,7 @@ using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -60,6 +61,32 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
transform.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
transform.GetComponent<Button>().onClick.AddListener(Ride);
|
||||
}
|
||||
var downloadBtn = transform.Find("DownLoadModal/DownLoad").gameObject;
|
||||
var downloading = transform.Find("DownLoadModal/Downloading").gameObject;
|
||||
var downloadTxt = transform.Find("DownLoadModal/Text").gameObject;
|
||||
var slider = transform.Find("DownLoadModal/Slider").GetComponent<Slider>();
|
||||
|
||||
var fileName = map.FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(map.EnableAR && !File.Exists(filepath));
|
||||
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
downloadBtn.SetActive(false);
|
||||
downloading.SetActive(true);
|
||||
downloadTxt.SetActive(false);
|
||||
slider.gameObject.SetActive(true);
|
||||
Loom.Current.StartCoroutine(Utils.DownloadVideo(map.FileName, map.Url, (p, req) =>
|
||||
{
|
||||
slider.value = p;
|
||||
}
|
||||
, (p) =>
|
||||
{
|
||||
slider.value = 100f;
|
||||
ShowOutLine();
|
||||
transform.Find("DownLoadModal").gameObject.SetActive(false);
|
||||
}));
|
||||
});
|
||||
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
|
||||
@@ -104,13 +131,19 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
|
||||
|
||||
private void Ride()
|
||||
{
|
||||
var list = FindObjectsOfType<GameRoomMapItem>();
|
||||
foreach (var item in list)
|
||||
var fileName = map.FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
if ((map.EnableAR && !File.Exists(filepath) )|| !map.EnableAR)
|
||||
{
|
||||
item.HiddenOutLine();
|
||||
var list = FindObjectsOfType<GameRoomMapItem>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.HiddenOutLine();
|
||||
}
|
||||
ShowOutLine();
|
||||
listController.Select(map);
|
||||
}
|
||||
ShowOutLine();
|
||||
listController.Select(map);
|
||||
}
|
||||
|
||||
public void ShowOutLine()
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomPassword : MonoBehaviour
|
||||
{
|
||||
public GameObject enterBtn;
|
||||
public GameObject backBtn;
|
||||
public InputField passwordInput;
|
||||
|
||||
public GameRoomListController manager;
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
passwordInput.onValueChanged.AddListener((e) =>
|
||||
{
|
||||
Password = e;
|
||||
});
|
||||
UIManager.AddEvent(enterBtn, EventTriggerType.PointerClick, ConfirmClick); //确定
|
||||
UIManager.AddEvent(backBtn, EventTriggerType.PointerClick, CancelClick); //取消
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
passwordInput.text = "";
|
||||
}
|
||||
|
||||
private async void ConfirmClick(BaseEventData baseEventData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Password))
|
||||
{
|
||||
Utils.showToast(gameObject, App.GetLocalString("room password can not be empty"));
|
||||
return;
|
||||
}
|
||||
var RoomId = manager.GetRoomId();
|
||||
var result = await ConfigHelper.GameRoomApi.ConfirmRoomPwd(RoomId, Password);
|
||||
if (!result.result)
|
||||
{
|
||||
Utils.showToast(gameObject, result.errMsg);
|
||||
return;
|
||||
}
|
||||
Refresh();
|
||||
gameObject.SetActive(false);
|
||||
manager.ShowDownLoadConfirm();
|
||||
}
|
||||
private void CancelClick(BaseEventData baseEventData)
|
||||
{
|
||||
Refresh();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea7f659ae39c16b46b8449abf56f3fea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
class GameRoomPlayerPanel : MonoBehaviour
|
||||
{
|
||||
public Text userNametxt;
|
||||
public Text weigthTxt;
|
||||
public Text ftpTxt;
|
||||
public RawImage head;
|
||||
|
||||
|
||||
public GameObject owner;
|
||||
public GameObject playerModal;
|
||||
public GameObject notInUseModal;
|
||||
public GameObject inviteModal;
|
||||
public GameObject kickModal;
|
||||
public GameObject me;
|
||||
public GameObject ready;
|
||||
|
||||
public GameObject kickBtn;
|
||||
public GameObject cancelBtn;
|
||||
|
||||
public int sort;
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var manager = FindObjectOfType<GameRoomDetailController>();
|
||||
var inviteBtn = inviteModal.transform.Find("InviteBtn").gameObject;
|
||||
UIManager.AddEvent(inviteBtn,EventTriggerType.PointerClick,(e)=> {
|
||||
Utils.CopyToClipboard($"GameRoom/{manager.GameRoom.Id}");
|
||||
Utils.showToast(transform.parent.gameObject, App.GetLocalString("copy to clipboard successfully!"));
|
||||
});
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
kickModal.SetActive(true);
|
||||
});
|
||||
UIManager.AddEvent(cancelBtn, EventTriggerType.PointerExit, (e) =>
|
||||
{
|
||||
kickModal.SetActive(false);
|
||||
});
|
||||
UIManager.AddEvent(kickBtn, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
MapUDPService.SendGameRoomKick(App.gameRoomDetail.Id, UserId, App.CurrentUser.Id);
|
||||
});
|
||||
}
|
||||
|
||||
public void Init(int userId, string userName,string headUrl,double weight, float ftp,bool isOwner,int Status)
|
||||
{
|
||||
UserId = userId;
|
||||
inviteModal.SetActive(false);
|
||||
notInUseModal.SetActive(false);
|
||||
Utils.DisplayHead(head, headUrl);
|
||||
|
||||
userNametxt.text = userName;
|
||||
weigthTxt.text = weight.ToString();
|
||||
ftpTxt.text = ftp.ToString();
|
||||
me.SetActive(App.CurrentUser.Id == userId);
|
||||
owner.SetActive(isOwner);
|
||||
//Show ready
|
||||
ready.SetActive(!isOwner && Status == 1);
|
||||
}
|
||||
|
||||
public void UpdatePlayer(int userId, string userName, string headUrl, double weight, float ftp, bool isOwner, int Status)
|
||||
{
|
||||
UserId = userId;
|
||||
inviteModal.SetActive(false);
|
||||
notInUseModal.SetActive(false);
|
||||
userNametxt.text = userName;
|
||||
weigthTxt.text = weight.ToString();
|
||||
ftpTxt.text = ftp.ToString();
|
||||
me.SetActive(App.CurrentUser.Id == userId);
|
||||
owner.SetActive(isOwner);
|
||||
ready.SetActive(!isOwner && Status == 1);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Ready()
|
||||
{
|
||||
ready.SetActive(true);
|
||||
}
|
||||
public void UnReady()
|
||||
{
|
||||
ready.SetActive(false);
|
||||
}
|
||||
public void ForceQuit()
|
||||
{
|
||||
//TODO:踢人
|
||||
NotInUse();
|
||||
}
|
||||
public void ShowQuitModal()
|
||||
{
|
||||
kickModal.SetActive(true);
|
||||
}
|
||||
public void ShowInviteModal()
|
||||
{
|
||||
UserId = 0;
|
||||
inviteModal.SetActive(true);
|
||||
}
|
||||
public void NotInUse()
|
||||
{
|
||||
UserId = 0;
|
||||
notInUseModal.SetActive(true);
|
||||
}
|
||||
|
||||
public void Me()
|
||||
{
|
||||
me.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fabe7328397c8f468d2fb938ca70f48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,203 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameRoomDetailController : PFUIPanel
|
||||
{
|
||||
|
||||
public RawImage Avatar;
|
||||
public Text idText;
|
||||
public Text roomName;
|
||||
public Text routeName;
|
||||
public Text distanceText;
|
||||
public Text eleText;
|
||||
public Text slopeText;
|
||||
public Text rideText;
|
||||
public RawImage altitudeGraph;
|
||||
|
||||
public GameObject bestTab;
|
||||
public Text bestTabName;
|
||||
public Text bestTabTimer;
|
||||
public RawImage bestTabHead;
|
||||
|
||||
public GameObject readyBtn;
|
||||
public GameObject startBtn;
|
||||
public GameObject quitBtn;
|
||||
public GameObject cancelBtn;
|
||||
|
||||
|
||||
|
||||
public GameRoomModel GameRoom { get; set; }
|
||||
public DateTime? StartTime { get; set; }
|
||||
public int Status { get; set; }
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
Utils.DisplayHead(Avatar, App.CurrentUser.WxHeadImg);
|
||||
UIManager.AddEvent(startBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
var startTime = UIManager.Now.GetDateTime().ToUniversalTime().AddMilliseconds(10);
|
||||
MapUDPService.SendGameRoomStartTime(App.gameRoomDetail.Id, startTime);
|
||||
});
|
||||
//准备
|
||||
UIManager.AddEvent(readyBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Status = 1;
|
||||
readyBtn.SetActive(false);
|
||||
cancelBtn.SetActive(true);
|
||||
MapUDPService.SendGameRoomReadyStatus(App.gameRoomDetail.Id, App.CurrentUser.Id, Status);
|
||||
});
|
||||
//取消准备
|
||||
UIManager.AddEvent(cancelBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
Status = 0;
|
||||
readyBtn.SetActive(true);
|
||||
cancelBtn.SetActive(false);
|
||||
MapUDPService.SendGameRoomReadyStatus(App.gameRoomDetail.Id, App.CurrentUser.Id, Status);
|
||||
});
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
GameRoom = App.gameRoomDetail;
|
||||
Init();
|
||||
}
|
||||
float timer = 0f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
MapUDPService.Send(0, App.CurrentUser.Id, new double[] { 0d, 0d }, competitionId: 0, roomId: GameRoom.Id);
|
||||
var list = MapUDPService.GetGameRoomList(GameRoom.Id);
|
||||
var playerList = FindObjectsOfType<GameRoomPlayerPanel>();
|
||||
//自己
|
||||
var mine = list.Where(c => c.RoomDetail.UserId == App.CurrentUser.Id).FirstOrDefault();
|
||||
if (mine != null)
|
||||
{
|
||||
//是否是房主
|
||||
var owner = mine.RoomDetail.IsOwner;
|
||||
readyBtn.SetActive(!owner);
|
||||
startBtn.SetActive(owner);
|
||||
//是否准备
|
||||
//readyBtn.SetActive(!owner && mine.RoomDetail.Status == 0);
|
||||
//cancelBtn.SetActive(!owner && mine.RoomDetail.Status == 1);
|
||||
}
|
||||
//新增/更新
|
||||
foreach (var item in list)
|
||||
{
|
||||
var current = playerList.Where(c => c.UserId == item.Id).FirstOrDefault();
|
||||
if (current == null)
|
||||
{
|
||||
var s = playerList.Where(c => c.UserId == 0).OrderBy(c=>c.sort).FirstOrDefault();
|
||||
if (s != null)
|
||||
{
|
||||
s.Init(item.Id,item.Name, item.HeadImage, item.Weight, item.FTP, item.RoomDetail.IsOwner, item.RoomDetail.Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
current.UpdatePlayer(item.Id, item.Name, item.HeadImage, item.Weight, item.FTP, item.RoomDetail.IsOwner,item.RoomDetail.Status);
|
||||
}
|
||||
}
|
||||
//删除
|
||||
foreach (var item in playerList)
|
||||
{
|
||||
if (item.UserId != 0)
|
||||
{
|
||||
var current = list.Where(c => c.Id == item.UserId).FirstOrDefault();
|
||||
if (current == null)
|
||||
{
|
||||
item.ShowInviteModal();
|
||||
}
|
||||
var myself = list.Where(c => c.RoomDetail.UserId == App.CurrentUser.Id).FirstOrDefault();
|
||||
if (myself == null)
|
||||
{
|
||||
Utils.showToast(gameObject,App.GetLocalString("you've been kicked out of the room"));
|
||||
UIManager.ShowGameRoomListPanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////监听startTime
|
||||
//var msg = list.Where(c => c.RoomDetail != null && c.RoomDetail.s.HasValue).FirstOrDefault();
|
||||
//if (msg != null)
|
||||
//{
|
||||
// StartTime = msg.StartTime.Value.ToLocalTime();
|
||||
// Debug.Log(StartTime);
|
||||
//}
|
||||
//倒计时
|
||||
|
||||
|
||||
//4.更换房间房主
|
||||
|
||||
//5.标记当前用户
|
||||
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
UIManager.AddEvent(startBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
//TODO:
|
||||
});
|
||||
UIManager.AddEvent(quitBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
//TODO:
|
||||
});
|
||||
UIManager.AddEvent(cancelBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
//TODO:
|
||||
});
|
||||
idText.text = GameRoom.Id.ToString().PadLeft(7, '0');
|
||||
roomName.text = GameRoom.Name;
|
||||
routeName.text = GameRoom.MapRouteName;
|
||||
distanceText.text = $"{Math.Round(GameRoom.Distance, 1)}KM";
|
||||
eleText.text = $"{Math.Round(GameRoom.TotalClimb, 0)}M";
|
||||
slopeText.text = $"{Math.Round(GameRoom.AverageGrade, 1)}%";
|
||||
if (!string.IsNullOrEmpty(GameRoom.BestNickName))
|
||||
{
|
||||
bestTab.SetActive(true);
|
||||
bestTabName.text = GameRoom.BestNickName;
|
||||
bestTabTimer.text = GameRoom.BestTotalTime;
|
||||
Utils.DisplayHead(bestTabHead, GameRoom.BestWxHeadImg);
|
||||
}
|
||||
Utils.DisplayHead(altitudeGraph, GameRoom.AltitudeGraph);
|
||||
}
|
||||
|
||||
public void Ready()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void NotInUse()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
App.gameRoomDetail = null;
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
App.gameRoomDetail = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62eee39fef61c1d479fb401e0ce37755
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.MapList;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -33,26 +35,60 @@ public class GameRoomListController : PFUIPanel
|
||||
private bool startMouse;
|
||||
List<string> hands = new List<string>();
|
||||
private int selectedRouteId;
|
||||
private MapRoute Map;
|
||||
private int pageIndex = 0;
|
||||
private bool isEnd = 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 GameObject btn30;
|
||||
private GameObject btn40;
|
||||
private GameObject btn50;
|
||||
private GameObject btn60;
|
||||
|
||||
private GameObject btn2;
|
||||
private GameObject btn3;
|
||||
private GameObject btn4;
|
||||
private GameObject btn5;
|
||||
private GameObject btn6;
|
||||
|
||||
private Transform enterRoomModal;
|
||||
|
||||
private string RoomName;
|
||||
private string Roompwd;
|
||||
private int hours;
|
||||
private int mins;
|
||||
private int CloseTime;
|
||||
private int Members;
|
||||
private GameRoomModel GameRoom;
|
||||
|
||||
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);
|
||||
InitStep1();
|
||||
|
||||
}
|
||||
|
||||
MapList = transform.Find("MapList").gameObject;
|
||||
enterRoomModal = transform.Find("EnterRoomModal");
|
||||
|
||||
InitStep1();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
@@ -76,7 +112,6 @@ public class GameRoomListController : PFUIPanel
|
||||
onEndEdit();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitStep1()
|
||||
{
|
||||
sort = "Near";
|
||||
@@ -221,67 +256,68 @@ public class GameRoomListController : PFUIPanel
|
||||
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;
|
||||
|
||||
previous = transform.Find("MapList/Modal/Left/Previous").gameObject;
|
||||
|
||||
create = transform.Find("MapList/Modal/Left/Create").gameObject;
|
||||
create.GetComponent<Button>().interactable = false;
|
||||
create.GetComponent<Button>().enabled = false;
|
||||
cancel = transform.Find("MapList/Modal/Left/Cancel").gameObject;
|
||||
|
||||
right = transform.Find("MapList/Modal/Right").gameObject;
|
||||
right2 = transform.Find("MapList/Modal/Right2").gameObject;
|
||||
|
||||
UIManager.AddEvent(cancel, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
MapList.SetActive(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);
|
||||
HandleStepBtn(next.name);
|
||||
});
|
||||
|
||||
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);
|
||||
HandleStepBtn(previous.name);
|
||||
});
|
||||
|
||||
UIManager.AddEvent(create, EventTriggerType.PointerClick, async (e) =>
|
||||
{
|
||||
var result = await ConfigHelper.GameRoomApi.Add(RoomName,selectedRouteId,Roompwd,UIManager.Now.GetDateTime(),CloseTime,Members);
|
||||
if (result.result)
|
||||
{
|
||||
MapList.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowAlert("error", result.errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
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()
|
||||
{
|
||||
//关门时间
|
||||
btn30 = right2.transform.Find("btn30").gameObject;
|
||||
btn40 = right2.transform.Find("btn40").gameObject;
|
||||
btn50 = right2.transform.Find("btn50").gameObject;
|
||||
btn60 = right2.transform.Find("btn60").gameObject;
|
||||
//房间人数
|
||||
btn2 = right2.transform.Find("btn2").gameObject;
|
||||
btn3 = right2.transform.Find("btn3").gameObject;
|
||||
btn4 = right2.transform.Find("btn4").gameObject;
|
||||
btn5 = right2.transform.Find("btn5").gameObject;
|
||||
btn6 = right2.transform.Find("btn6").gameObject;
|
||||
//房间名和密码
|
||||
var hourInputField = right2.transform.Find("HourInputField").GetComponent<InputField>();
|
||||
var minInputField = right2.transform.Find("MinInputField").GetComponent<InputField>();
|
||||
var roomNameInputField = right2.transform.Find("RoomNameInputField").GetComponent<InputField>();
|
||||
@@ -289,122 +325,123 @@ public class GameRoomListController : PFUIPanel
|
||||
//房间名
|
||||
roomNameInputField.onValueChanged.AddListener((e) => {
|
||||
RoomName = e;
|
||||
HandleFormInput();
|
||||
});
|
||||
//房间密码
|
||||
passwordInputField.onValueChanged.AddListener((e) => {
|
||||
Roompwd = e;
|
||||
HandleFormInput();
|
||||
});
|
||||
UIManager.AddEvent(minInputField.gameObject, EventTriggerType.Select, (e) => {
|
||||
hourInputField.GetComponent<Outline>().enabled = true;
|
||||
HandleFormInput();
|
||||
});
|
||||
//关门时间
|
||||
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;
|
||||
HandleCloseTimeBtnClick(30, btn30.name);
|
||||
});
|
||||
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;
|
||||
HandleCloseTimeBtnClick(40, btn40.name);
|
||||
});
|
||||
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;
|
||||
HandleCloseTimeBtnClick(50, btn50.name);
|
||||
});
|
||||
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;
|
||||
HandleCloseTimeBtnClick(60, btn60.name);
|
||||
});
|
||||
|
||||
//小时
|
||||
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;
|
||||
HandleCloseTimeBtnClick(CloseTime, hourInputField.name);
|
||||
});
|
||||
//分钟
|
||||
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;
|
||||
HandleCloseTimeBtnClick(CloseTime, minInputField.name);
|
||||
});
|
||||
//房间人数
|
||||
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;
|
||||
HandleMembersBtnClick(2, btn2.name);
|
||||
});
|
||||
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;
|
||||
HandleMembersBtnClick(3, btn3.name);
|
||||
});
|
||||
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;
|
||||
HandleMembersBtnClick(4, btn4.name);
|
||||
});
|
||||
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;
|
||||
HandleMembersBtnClick(5, btn5.name);
|
||||
});
|
||||
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;
|
||||
HandleMembersBtnClick(6, btn6.name);
|
||||
});
|
||||
|
||||
}
|
||||
private void HandleStepBtn(string btnName)
|
||||
{
|
||||
next.SetActive(btnName == previous.name);
|
||||
previous.SetActive(btnName != previous.name);
|
||||
cancel.SetActive(btnName == previous.name);
|
||||
create.SetActive(btnName != previous.name);
|
||||
right2.SetActive(btnName != previous.name);
|
||||
right.SetActive(btnName == previous.name);
|
||||
step1Btn.transform.Find("Title").GetComponent<Text>().color = btnName == previous.name ? Color.white : PFConstants.grey;
|
||||
step2Btn.transform.Find("Title").GetComponent<Text>().color = btnName != previous.name ? Color.white : PFConstants.grey;
|
||||
previous.transform.Find("Text").GetComponent<Text>().color = btnName == previous.name ? PFConstants.grey : Color.white;
|
||||
step1Btn.transform.Find("Bg").gameObject.SetActive(btnName == previous.name);
|
||||
step2Btn.transform.Find("Bg").gameObject.SetActive(btnName != previous.name);
|
||||
}
|
||||
private void HandleFormInput()
|
||||
{
|
||||
if (Members >= 2 && !string.IsNullOrEmpty(RoomName) && CloseTime > 0)
|
||||
{
|
||||
create.GetComponent<Image>().color = PFConstants.Pink;
|
||||
create.transform.Find("Text").GetComponent<Text>().color = Color.white;
|
||||
create.GetComponent<Button>().interactable = true;
|
||||
create.GetComponent<Button>().enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#5C5C6E", out Color grey);
|
||||
ColorUtility.TryParseHtmlString("#23232D", out Color dark);
|
||||
create.GetComponent<Image>().color = dark;
|
||||
create.transform.Find("Text").GetComponent<Text>().color = grey;
|
||||
create.GetComponent<Button>().interactable = false;
|
||||
create.GetComponent<Button>().enabled = false;
|
||||
}
|
||||
}
|
||||
private void HandleCloseTimeBtnClick(int closeTime,string btnName)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#3D3E4D", out Color grey);
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color pink);
|
||||
CloseTime = closeTime;
|
||||
btn30.GetComponent<Image>().color = btn30.name == btnName ? pink : grey;
|
||||
btn40.GetComponent<Image>().color = btn40.name == btnName ? pink : grey;
|
||||
btn50.GetComponent<Image>().color = btn50.name == btnName ? pink : grey;
|
||||
btn60.GetComponent<Image>().color = btn60.name == btnName ? pink : grey;
|
||||
HandleFormInput();
|
||||
}
|
||||
private void HandleMembersBtnClick(int members,string btnName)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#3D3E4D", out Color grey);
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color pink);
|
||||
Members = members;
|
||||
btn2.GetComponent<Image>().color = btn2.name == btnName ? pink : grey;
|
||||
btn3.GetComponent<Image>().color = btn3.name == btnName ? pink : grey;
|
||||
btn4.GetComponent<Image>().color = btn4.name == btnName ? pink : grey;
|
||||
btn5.GetComponent<Image>().color = btn5.name == btnName ? pink : grey;
|
||||
btn6.GetComponent<Image>().color = btn6.name == btnName ? pink : grey;
|
||||
HandleFormInput();
|
||||
}
|
||||
private void ChangeDistance(int index)
|
||||
{
|
||||
@@ -426,9 +463,63 @@ public class GameRoomListController : PFUIPanel
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
public void ShowPwdConfirm()
|
||||
{
|
||||
enterRoomModal.gameObject.SetActive(true);
|
||||
}
|
||||
//如果本地没有视频文件则弹窗下载否则直接进入房间
|
||||
public void ShowDownLoadConfirm()
|
||||
{
|
||||
var fileName = GameRoom.FileName;
|
||||
var path = PFConstants.VideoFolder;
|
||||
var filepath = path + "/" + fileName;
|
||||
var download = transform.Find("DownloadPanel").gameObject;
|
||||
if (!File.Exists(filepath))
|
||||
{
|
||||
download.SetActive(true);
|
||||
download.GetComponent<GameRoomDownLoad>().Init(RoomId, GameRoom.FileName, GameRoom.FileUrl, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (File.Exists(filepath))
|
||||
{
|
||||
GetInRoom();
|
||||
}
|
||||
}
|
||||
}
|
||||
private int RoomId;
|
||||
|
||||
public void GetInRoom()
|
||||
{
|
||||
var result = ConfigHelper.GameRoomApi.GetDetail(RoomId);
|
||||
if (result.result)
|
||||
{
|
||||
App.gameRoomDetail = result.data;
|
||||
//TODO:一些状态的校验
|
||||
//1.房间人数已经满了
|
||||
//2.房间状态不对
|
||||
//发送TCP信息
|
||||
MapUDPService.SendJoinGameRoom(App.gameRoomDetail.Id,App.CurrentUser.Id,UIManager.Now.GetDateTime().ToUniversalTime());
|
||||
UIManager.ShowGameRoomDetailPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, result.errMsg);
|
||||
}
|
||||
}
|
||||
public void SelectRoom(GameRoomModel room)
|
||||
{
|
||||
GameRoom = room;
|
||||
RoomId = GameRoom.Id;
|
||||
}
|
||||
|
||||
public int GetRoomId()
|
||||
{
|
||||
return RoomId;
|
||||
}
|
||||
public void Select(MapRoute map)
|
||||
{
|
||||
Map = map;
|
||||
selectedRouteId = map.Id;
|
||||
next.GetComponent<Image>().color = PFConstants.Pink;
|
||||
next.transform.Find("Text").GetComponent<Text>().color = Color.white;
|
||||
@@ -464,14 +555,14 @@ public class GameRoomListController : PFUIPanel
|
||||
GetList();
|
||||
}
|
||||
|
||||
void onEndEdit()
|
||||
private void onEndEdit()
|
||||
{
|
||||
var t = searchInput.GetComponent<InputField>().text;
|
||||
ftname = t;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void DisplayMaps(List<MapRoute> list)
|
||||
private void DisplayMaps(List<MapRoute> list)
|
||||
{
|
||||
if (map != null)
|
||||
{
|
||||
@@ -485,8 +576,7 @@ public class GameRoomListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async void GetList()
|
||||
private async void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname, distance, string.Join(",", hands), is3d, sort, sortDire);
|
||||
@@ -514,8 +604,6 @@ public class GameRoomListController : PFUIPanel
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//创建房间
|
||||
private void CreateGameRoom(BaseEventData data)
|
||||
{
|
||||
|
||||
@@ -106,6 +106,14 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("GameRoomListPanel", ref this.mGameRoomListController);
|
||||
}
|
||||
}
|
||||
private GameRoomDetailController mGameRoomDetailController;
|
||||
public GameRoomDetailController GameRoomDetailPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("GameRoomDetailPanel", ref this.mGameRoomDetailController);
|
||||
}
|
||||
}
|
||||
private SettingContoller mSettingContoller;
|
||||
public SettingContoller SettingModal
|
||||
{
|
||||
@@ -848,7 +856,10 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.GameRoomListPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
public static void ShowGameRoomDetailPanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.GameRoomDetailPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
public static void ShowDevicePanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, null, true);
|
||||
|
||||
@@ -889,5 +889,15 @@ namespace Assets.Scripts
|
||||
return time.ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetClipboard()
|
||||
{
|
||||
return UnityEngine.GUIUtility.systemCopyBuffer;
|
||||
}
|
||||
|
||||
public static void CopyToClipboard(string msg)
|
||||
{
|
||||
UnityEngine.GUIUtility.systemCopyBuffer = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user