先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
177 lines
5.4 KiB
C#
177 lines
5.4 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HomeBtnAquarium : MonoBehaviour
|
|
{
|
|
GameObject btn_guild_gray;
|
|
Button btn_fishingBox;
|
|
GameObject redpoint;
|
|
public CanvasGroup homeCanvasGroup;
|
|
FishingEventData fishingEventData;
|
|
AquariumManagerData data;
|
|
List<AquariumSlotData> slotDatas;
|
|
List<AquariumResultData> aquariumResultDatas;
|
|
|
|
bool isred;
|
|
DateTime refreshTime;
|
|
private void Awake()
|
|
{
|
|
fishingEventData = GContext.container.Resolve<FishingEventData>();
|
|
btn_guild_gray = transform.Find("icon_gray").gameObject;
|
|
redpoint = transform.Find("redpoint").gameObject;
|
|
btn_fishingBox = GetComponent<Button>();
|
|
bool IsAquariumOpen = fishingEventData.IsAquariumOpen;
|
|
btn_guild_gray.SetActive(!IsAquariumOpen);
|
|
if (IsAquariumOpen)
|
|
{
|
|
Synchrodata();
|
|
}
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_fishingBox.onClick.AddListener(OnClickGoTo);
|
|
//btn_fishingBox.onClick.AddListener(OnClickGoTo);
|
|
}
|
|
public void Synchrodata()
|
|
{
|
|
//从服务器拿数据
|
|
var dataSever = AquariumManager.GetAquariumManagerData();
|
|
if (dataSever == null)
|
|
{
|
|
ShowRed();
|
|
}
|
|
else
|
|
{
|
|
data = dataSever;
|
|
var nowTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
|
refreshTime = nowTime.Date.AddDays(1);
|
|
if (nowTime.Date.DayOfYear != data.refreshDay)
|
|
{
|
|
data.adCount = 0;
|
|
data.refreshCount = 0;
|
|
data.refreshDay = nowTime.Date.DayOfYear;
|
|
}
|
|
|
|
if (data.isHome || data.slotDatas == null)
|
|
{
|
|
IsHome(nowTime);
|
|
}
|
|
else
|
|
{
|
|
slotDatas = new List<AquariumSlotData>();
|
|
int count = data.slot - data.aquariumHurtDatas.Count;
|
|
if (count > 0)
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
AquariumHurtData aquariumHurtData = new AquariumHurtData();
|
|
data.aquariumHurtDatas.Add(aquariumHurtData);
|
|
}
|
|
}
|
|
count = data.slot - data.aquariumResultDatas.Count;
|
|
if (count > 0)
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
AquariumResultData aquariumResultData = new AquariumResultData();
|
|
data.aquariumResultDatas.Add(aquariumResultData);
|
|
}
|
|
}
|
|
aquariumResultDatas = data.aquariumResultDatas;
|
|
|
|
for (int i = 0; i < data.slot; i++)
|
|
{
|
|
var slotData = data.slotDatas[i];
|
|
if (!slotData.IsResult() && !aquariumResultDatas[slotData.index].IsResult())
|
|
{
|
|
slotDatas.Add(slotData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void IsHome(DateTime dateTime)
|
|
{
|
|
bool isRefresh = refreshTime < dateTime;
|
|
if (data.refreshCount < GContext.container.Resolve<Tables>().TbAquariumConfig.RefreshTime || isRefresh)
|
|
{
|
|
ShowRed();
|
|
}
|
|
}
|
|
void ShowRed()
|
|
{
|
|
isred = true;
|
|
redpoint.SetActive(true);
|
|
}
|
|
|
|
void OnClickGoTo()
|
|
{
|
|
if (!fishingEventData.IsAquariumOpen)
|
|
{
|
|
ToastPanel.Show(fishingEventData.GetTipforUnlocked(fishingEventData.OpenAquariumID));
|
|
return;
|
|
}
|
|
EnterGame();
|
|
}
|
|
void EnterGame()
|
|
{
|
|
homeCanvasGroup.blocksRaycasts = false;
|
|
if (data != null && !data.isHome && data.slotDatas != null)
|
|
{
|
|
FishingAquariumAct.CloudType = 3;
|
|
}
|
|
else
|
|
{
|
|
FishingAquariumAct.CloudType = 1;
|
|
}
|
|
GContext.Publish(new UnloadActToNextAct("FishingAquariumAct", UITypes.AquariumCloudPanel, 0.75f));
|
|
homeCanvasGroup.blocksRaycasts = true;
|
|
}
|
|
private void Update()
|
|
{
|
|
if (!fishingEventData.IsAquariumOpen || data == null || isred)
|
|
{
|
|
return;
|
|
}
|
|
DateTime dateTime = ZZTimeHelper.UtcNow();
|
|
if (data.isHome || data.slotDatas == null)
|
|
{
|
|
IsHome(dateTime.UtcNowOffset());
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < slotDatas.Count; i++)
|
|
{
|
|
var slotData = slotDatas[i];
|
|
var HatchTime = slotData.FishHatchTime();
|
|
var FishGrowthTime = slotData.FishGrowthTime();
|
|
bool isHatch = HatchTime < dateTime;
|
|
if (isHatch)
|
|
{
|
|
//鱼鱼
|
|
bool growth = FishGrowthTime < dateTime;
|
|
//检查是否受伤
|
|
//正常的成长时间 自然时间+加速成长-总恢复时间
|
|
float normalH = (float)(dateTime - HatchTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
|
|
|
float injuryH = slotData.injuryGrowthTime;
|
|
|
|
//受伤时的成长进度大于正常的成长进度=还没恢复
|
|
if (growth && injuryH < normalH)
|
|
{
|
|
//成熟并且没有受伤
|
|
ShowRed();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|