117 lines
3.3 KiB
C#
117 lines
3.3 KiB
C#
using Assets.Scripts;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
using Assets.Scripts.Apis.Models;
|
|
using System;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class MessagePanelScript : MonoBehaviour
|
|
{
|
|
CanvasGroup canvas;
|
|
Text text;
|
|
RawImage head;
|
|
string Name ="";
|
|
string url ="";
|
|
bool run = false;
|
|
|
|
private void Awake()
|
|
{
|
|
canvas = transform.GetComponent<CanvasGroup>();
|
|
EventQueueSystem.AddListener<JoinMessageEvent>(JoinHandler);
|
|
text = transform.Find("Name").GetComponent<Text>();
|
|
head = transform.Find("RawImage").GetComponent<RawImage>();
|
|
}
|
|
private void JoinHandler(JoinMessageEvent e)
|
|
{
|
|
Name = e.name;
|
|
url = e.url;
|
|
}
|
|
float timer = 2f;
|
|
private void Update()
|
|
{
|
|
timer -= Time.deltaTime;
|
|
if (timer <= 0)//定时器 一秒执行一次
|
|
{
|
|
if (!string.IsNullOrEmpty(Name))
|
|
{
|
|
text.text = Name;
|
|
canvas.DOFade(1, 2);
|
|
Name = string.Empty;
|
|
}
|
|
else
|
|
{
|
|
canvas.DOFade(0, 2);
|
|
}
|
|
if (!string.IsNullOrEmpty(url))
|
|
{
|
|
Utils.DisplayImage(head, url, false);
|
|
url = string.Empty;
|
|
}
|
|
timer = 2.0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class JoinMessageEvent : GameEvent
|
|
{
|
|
public string name;//人物名称
|
|
public string url;//头像地址
|
|
|
|
public JoinMessageEvent(string name,string url)
|
|
{
|
|
this.name = name;
|
|
this.url = url;
|
|
}
|
|
}
|
|
//赛事开始事件3
|
|
public class CompetitonStartMessageEvent : GameEvent
|
|
{
|
|
public string title;//赛事标题
|
|
public string SceneName;//场景名称
|
|
public int competitionId;//赛事id
|
|
public int routeId;//路书id
|
|
public DateTime StartTime;//赛事开始时间
|
|
|
|
|
|
public CompetitonStartMessageEvent(string Title, int Id, int RouteId, DateTime StartTime,string SceneName)
|
|
{
|
|
this.title = Title;
|
|
this.competitionId = Id;
|
|
this.routeId = RouteId;
|
|
this.StartTime = StartTime;
|
|
this.SceneName = SceneName;
|
|
}
|
|
}
|
|
//首页消息提醒
|
|
public class LinkedMessageEvent : GameEvent
|
|
{
|
|
public int routeId;//线路Id
|
|
public string routeName;
|
|
public string content;//消息
|
|
public string avatar;
|
|
public string nickname;
|
|
public LinkedMessageEvent(int routeId, string content)
|
|
{
|
|
this.routeId = routeId;
|
|
this.content = content;
|
|
}
|
|
public LinkedMessageEvent(int routeId, string content,string avatar,string nickname,string routeName)
|
|
{
|
|
this.routeId = routeId;
|
|
this.content = content;
|
|
this.avatar = avatar;
|
|
this.nickname = nickname;
|
|
this.routeName = routeName;
|
|
}
|
|
|
|
private void CreateContent()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|