备份CatanBuilding瘦身独立工程
This commit is contained in:
88
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs
Normal file
88
Assets/Scripts/Aquarium/UI/AquariumEggTips.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumEggTips : MonoBehaviour, IAquariumTips
|
||||
{
|
||||
public Image icon;
|
||||
public TMP_Text text_name;
|
||||
public Image bar;
|
||||
public TMP_Text text_time;
|
||||
public Button btn_speedup;
|
||||
public GameObject[] card_info;
|
||||
AquariumSlotData slotData;
|
||||
AquariumSlot aquariumSlot;
|
||||
public void SetActive(bool value)
|
||||
{
|
||||
gameObject.SetActive(value);
|
||||
}
|
||||
public void SetData(AquariumSlot aquariumSlot)
|
||||
{
|
||||
this.aquariumSlot = aquariumSlot;
|
||||
this.slotData = aquariumSlot.slotData;
|
||||
|
||||
for (int i = 0; i < card_info.Length; i++)
|
||||
{
|
||||
card_info[i].SetActive(false);
|
||||
}
|
||||
|
||||
UpdateBar(ZZTimeHelper.UtcNow());
|
||||
|
||||
AquariumEgg aquariumEgg = GContext.container.Resolve<Tables>().TbAquariumEgg.GetOrDefault(slotData.eggId);
|
||||
|
||||
if (aquariumEgg != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetText(aquariumEgg.Name_l10n_key);
|
||||
var quantity = aquariumEgg.HatchFishQuantity;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon, aquariumEgg.Icon);
|
||||
|
||||
List<int> hatchFishQuality = aquariumEgg.HatchFishQuality;
|
||||
bool showNum = false;
|
||||
int max = 1;
|
||||
int min = hatchFishQuality[0];
|
||||
if (hatchFishQuality.Count > 1)
|
||||
{
|
||||
showNum = true;
|
||||
max = hatchFishQuality[^1];
|
||||
}
|
||||
int index = 0;
|
||||
TMP_Text text_fish_num;
|
||||
for (int i = 0; i < hatchFishQuality.Count; i++)
|
||||
{
|
||||
index = hatchFishQuality[i] - 1;
|
||||
if (index < card_info.Length)
|
||||
{
|
||||
card_info[index].SetActive(true);
|
||||
text_fish_num = card_info[index].transform.Find("text_fish_num").GetComponent<TMP_Text>();
|
||||
if (showNum)
|
||||
{
|
||||
text_fish_num.text = $"{min}~{max}";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_fish_num.text = min.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool UpdateBar(DateTime dateTime)
|
||||
{
|
||||
float time = (float)(dateTime - slotData.startTime).TotalHours + slotData.accelerationHatch;
|
||||
bar.fillAmount = time / slotData.hatchTime;
|
||||
int timeRemaining = (int)((slotData.hatchTime - time) * 3600);
|
||||
if (timeRemaining <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user