备份CatanBuilding瘦身独立工程
This commit is contained in:
92
Assets/Scripts/UI/HomeReport/ReportPanel.cs
Normal file
92
Assets/Scripts/UI/HomeReport/ReportPanel.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
|
||||
public class ReportPanel : MonoBehaviour
|
||||
{
|
||||
PhotoReport photoReport;
|
||||
EventReport eventReport;
|
||||
Tables tables;
|
||||
IReportService reportService;
|
||||
IDisposable disposable;
|
||||
bool isEnable = true;
|
||||
private void Awake()
|
||||
{
|
||||
reportService = GContext.container.Resolve<IReportService>();
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
photoReport = transform.Find("photo_report").GetComponent<PhotoReport>();
|
||||
eventReport = transform.Find("Event_report").GetComponent<EventReport>();
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
disposable = GContext.OnEvent<ReportData>().Subscribe(OnReportEvent);
|
||||
//NextReport();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
void OnReportEvent(ReportData reportEvent)
|
||||
{
|
||||
switch (reportEvent.type)
|
||||
{
|
||||
case ReportDataType.Picture:
|
||||
//PlayPhotoReport(reportEvent);
|
||||
break;
|
||||
case ReportDataType.Bomb:
|
||||
case ReportDataType.Heist:
|
||||
case ReportDataType.Aquarium:
|
||||
PlayEventReport(reportEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
async void PlayPhotoReport(ReportData reportEvent)
|
||||
{
|
||||
Picture _data = tables.TbPicture.GetOrDefault(reportEvent.id);
|
||||
if (_data != null)
|
||||
{
|
||||
photoReport.gameObject.SetActive(true);
|
||||
photoReport.SetData(_data, reportEvent.playFabId);
|
||||
await Awaiters.Seconds(4f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
photoReport.gameObject.SetActive(false);
|
||||
}
|
||||
NextReport();
|
||||
}
|
||||
async void PlayEventReport(ReportData reportEvent)
|
||||
{
|
||||
eventReport.gameObject.SetActive(true);
|
||||
eventReport.SetData(reportEvent.playFabId, reportEvent.content, reportEvent.type);
|
||||
await Awaiters.Seconds(4f);
|
||||
if (!isEnable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
eventReport.gameObject.SetActive(false);
|
||||
NextReport();
|
||||
}
|
||||
void NextReport()
|
||||
{
|
||||
if (this == null || enabled == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var data = reportService.GetReportData();
|
||||
if (data != null)
|
||||
{
|
||||
OnReportEvent(data);
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
isEnable = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user