205 lines
7.6 KiB
C#
205 lines
7.6 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
using GameCore;
|
|
|
|
public class AquariumFishTips : MonoBehaviour, IAquariumTips
|
|
{
|
|
public Image icon;
|
|
public Image tag_fish;
|
|
public TMP_Text text_name;
|
|
public Image bar;
|
|
public Image bar_hurt;
|
|
public TMP_Text text_time;
|
|
public GameObject recoverting;
|
|
public TMP_Text text_time2;
|
|
public GameObject killed;
|
|
public GameObject sold;
|
|
public TMP_Text text_killed;
|
|
public GameObject text_max;
|
|
public Button btn_speedup;
|
|
public Button btn_sell;
|
|
public TMP_Text text_cash;
|
|
public GameObject mutated;
|
|
public TMP_Text fishcard;
|
|
AquariumSlotData slotData;
|
|
Item item;
|
|
FishData fishData;
|
|
AquariumSlot aquariumSlot;
|
|
AquariumFish aquariumFish;
|
|
AquariumManager AM;
|
|
Tables _tables;
|
|
|
|
DateTime StartTime;
|
|
float injuryH;
|
|
float allRewardCount;
|
|
float baseRewardCount;
|
|
float WeightIncEvent;
|
|
public void SetActive(bool value)
|
|
{
|
|
gameObject.SetActive(value);
|
|
}
|
|
public void SetData(AquariumSlot aquariumSlot)
|
|
{
|
|
AM = GContext.container.Resolve<AquariumManager>();
|
|
|
|
_tables = GContext.container.Resolve<Tables>();
|
|
this.aquariumSlot = aquariumSlot;
|
|
this.slotData = aquariumSlot.slotData;
|
|
item = _tables.TbItem.GetOrDefault(slotData.fishItemID);
|
|
fishData = _tables.TbFishData.GetOrDefault(item.RedirectID);
|
|
aquariumFish = _tables.TbAquariumFish.GetOrDefault(slotData.aquariumFishID);
|
|
StartTime = slotData.FishHatchTime();
|
|
injuryH = slotData.injuryGrowthTime;
|
|
mutated.SetActive(slotData.mutants > 0);
|
|
text_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(tag_fish, "icon_fish_rate_tag_" + item.Quality);
|
|
PlayerFishData.SetFishIcon(icon, item);//鱼头像
|
|
|
|
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
|
var weights = GContext.container.Resolve<AquariumManager>().GetWeightMag();
|
|
float weight = weights[slotData.aquariumFishID - 1];
|
|
fishcard.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_40", weight.ToPercentageString());
|
|
WeightIncEvent = (1 + weight) * (1 + playerData.benefitsCashMag) * (1 + playerData.benefitsAquariumCashMag);
|
|
|
|
baseRewardCount = slotData.allCash;
|
|
allRewardCount = 0;
|
|
int fishQ = slotData.fishMQ;
|
|
for (int i = 0; i < fishQ; i++)
|
|
{
|
|
if (slotData.mutants > i)
|
|
{
|
|
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.MutantGrowthExtraSoldReward) * (1 + aquariumFish.MutantExtraSoldReward);
|
|
}
|
|
else
|
|
{
|
|
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.GrowthExtraSoldReward);
|
|
}
|
|
}
|
|
|
|
UpdateBar(ZZTimeHelper.UtcNow());
|
|
}
|
|
|
|
|
|
public bool UpdateBar(DateTime dateTime)
|
|
{
|
|
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
|
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
|
|
|
//受伤时的成长进度加上本次恢复时间大于正常的成长进度
|
|
bar_hurt.gameObject.SetActive(false);
|
|
text_time.gameObject.SetActive(true);
|
|
recoverting.gameObject.SetActive(false);
|
|
text_max.gameObject.SetActive(false);
|
|
btn_speedup.gameObject.SetActive(true);
|
|
btn_sell.gameObject.SetActive(false);
|
|
killed.SetActive(false);
|
|
sold.SetActive(false);
|
|
float timeProgress = 1;
|
|
|
|
if (aquariumSlot.slotState == 5)
|
|
{
|
|
bar.transform.parent.gameObject.SetActive(false);
|
|
killed.SetActive(true);
|
|
btn_speedup.gameObject.SetActive(false);
|
|
text_time.gameObject.SetActive(false);
|
|
AquariumResultData aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
|
text_killed.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_42", aquariumResultDatas.displayName);
|
|
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{0}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
|
return false;
|
|
}
|
|
else if (aquariumSlot.slotState == 4)
|
|
{
|
|
bar.transform.parent.gameObject.SetActive(false);
|
|
sold.SetActive(true);
|
|
btn_speedup.gameObject.SetActive(false);
|
|
text_time.gameObject.SetActive(false);
|
|
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{ConvertTools.GetNumberString2(slotData.cash)}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
|
|
bar.transform.parent.gameObject.SetActive(true);
|
|
timeProgress = normalH / slotData.growthTime;
|
|
bar.fillAmount = 1;
|
|
if (injuryH > normalH)
|
|
{
|
|
text_time.gameObject.SetActive(false);
|
|
recoverting.gameObject.SetActive(true);
|
|
bar_hurt.gameObject.SetActive(true);
|
|
bar_hurt.fillAmount = (injuryH - normalH) / slotData.recoveryTime;
|
|
|
|
int timeRemaining = (int)((injuryH - normalH) * 3600);
|
|
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
|
text_time2.text = ConvertTools.ConvertTime2(timeSpan);
|
|
|
|
if (injuryH / slotData.growthTime > 1)
|
|
{
|
|
timeProgress = 1 - ((injuryH - normalH) / slotData.growthTime);
|
|
}
|
|
bar.fillAmount = 0;
|
|
if (timeProgress < 0)
|
|
{
|
|
timeProgress = 0;
|
|
}
|
|
}
|
|
else if (normalH >= slotData.growthTime)
|
|
{
|
|
text_time.gameObject.SetActive(false);
|
|
text_max.gameObject.SetActive(true);
|
|
btn_speedup.gameObject.SetActive(false);
|
|
btn_sell.gameObject.SetActive(true);
|
|
timeProgress = 1;
|
|
}
|
|
else
|
|
{
|
|
bar.fillAmount = normalH / slotData.growthTime;
|
|
}
|
|
|
|
if (timeProgress < 1)
|
|
{
|
|
int timeRemaining = (int)(slotData.growthTime * (1 - timeProgress) * 3600);
|
|
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
|
text_time.text = ConvertTools.ConvertTime2(timeSpan);
|
|
}
|
|
|
|
}
|
|
|
|
float rewardProgress = timeProgress;// normalH / slotData.growthTime;
|
|
if (rewardProgress > 1)
|
|
{
|
|
rewardProgress = 1;
|
|
}
|
|
|
|
//金币显示
|
|
int fishQ = slotData.fishMQ;
|
|
if (injuryH > normalH)
|
|
{
|
|
fishQ -= GContext.container.Resolve<AquariumManager>().data.aquariumHurtDatas[slotData.index].fishLQ;
|
|
if (fishQ <= 0)
|
|
{
|
|
fishQ = 1;
|
|
}
|
|
}
|
|
float rewardCount = 0;
|
|
for (int i = 0; i < fishQ; i++)
|
|
{
|
|
if (slotData.mutants > i)
|
|
{
|
|
rewardCount += baseRewardCount * (1 + aquariumFish.MutantExtraSoldReward) * (1 + aquariumFish.MutantGrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
|
}
|
|
else
|
|
{
|
|
rewardCount += baseRewardCount * (1 + aquariumFish.GrowthExtraSoldReward * rewardProgress) * WeightIncEvent;
|
|
}
|
|
}
|
|
|
|
text_cash.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_26", $"{ConvertTools.GetNumberString2((int)(rewardCount))}/{ConvertTools.GetNumberString2((int)allRewardCount)}");
|
|
return true;
|
|
}
|
|
}
|