备份CatanBuilding瘦身独立工程
This commit is contained in:
198
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs
Normal file
198
Assets/Scripts/Aquarium/UI/SellingPopupItem.cs
Normal file
@@ -0,0 +1,198 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SellingPopupItem : MonoBehaviour
|
||||
{
|
||||
public Button btn_toggle;
|
||||
public GameObject checkmark;
|
||||
public GameObject icon_hurt;
|
||||
public GameObject icon_killed;
|
||||
public Image bar;
|
||||
public Image bar_hurt;
|
||||
public Image icon_fish;
|
||||
public GameObject done;
|
||||
public Image icon_rate;
|
||||
public TMP_Text text_time;
|
||||
public GameObject recoverting;
|
||||
public TMP_Text text_time2;
|
||||
public GameObject text_max;
|
||||
public TMP_Text text_cash;
|
||||
public GameObject killed;
|
||||
public TMP_Text text_killed;
|
||||
public AquariumSlotData slotData;
|
||||
AquariumFish aquariumFish;
|
||||
DateTime StartTime;
|
||||
float injuryH;
|
||||
float baseRewardCount;
|
||||
float allRewardCount;
|
||||
float WeightIncEvent;
|
||||
AquariumManager AM;
|
||||
AquariumResultData aquariumResultDatas;
|
||||
[HideInInspector]
|
||||
public bool isMax;
|
||||
private void Awake()
|
||||
{
|
||||
btn_toggle.onClick.AddListener(Click);
|
||||
}
|
||||
|
||||
void Click()
|
||||
{
|
||||
if (aquariumResultDatas != null && aquariumResultDatas.IsResult())
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_97"));
|
||||
return;
|
||||
}
|
||||
checkmark.SetActive(!checkmark.activeSelf);
|
||||
}
|
||||
public bool IsSell()
|
||||
{
|
||||
return aquariumResultDatas == null || checkmark.activeSelf && !aquariumResultDatas.IsResult();
|
||||
}
|
||||
public void SetData(AquariumSlotData slotData)
|
||||
{
|
||||
AM = GContext.container.Resolve<AquariumManager>();
|
||||
aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
||||
|
||||
this.slotData = slotData;
|
||||
aquariumFish = GContext.container.Resolve<Tables>().TbAquariumFish.GetOrDefault(slotData.aquariumFishID);
|
||||
StartTime = slotData.FishHatchTime();
|
||||
injuryH = slotData.injuryGrowthTime;
|
||||
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(slotData.fishItemID);
|
||||
PlayerFishData.SetFishIcon(icon_fish, item);//鱼头像
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_rate, $"icon_fish_rate_tag_{item.Quality}");
|
||||
|
||||
PlayerData playerData = GContext.container.Resolve<PlayerData>();
|
||||
var weight = GContext.container.Resolve<AquariumManager>().GetWeightMag();
|
||||
WeightIncEvent = (1 + weight[slotData.aquariumFishID - 1]) * (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.MutantExtraSoldReward) * (1 + aquariumFish.MutantGrowthExtraSoldReward);
|
||||
}
|
||||
else
|
||||
{
|
||||
allRewardCount += baseRewardCount * WeightIncEvent * (1 + aquariumFish.GrowthExtraSoldReward);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBar(ZZTimeHelper.UtcNow());
|
||||
}
|
||||
public void UpdateBar(DateTime dateTime)
|
||||
{
|
||||
//正常的成长进度 自然时间+加速成长 - 全部恢复时间
|
||||
float normalH = (float)(dateTime - StartTime).TotalHours + slotData.accelerationGrowth - slotData.allRecoveryTime;
|
||||
//受伤时的成长进度
|
||||
|
||||
//受伤时的成长进度大于正常的成长进度
|
||||
float timeProgress;
|
||||
float barProgress;
|
||||
bar_hurt.gameObject.SetActive(false);
|
||||
icon_hurt.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(true);
|
||||
text_max.gameObject.SetActive(false);
|
||||
text_time.gameObject.SetActive(true);
|
||||
recoverting.gameObject.SetActive(false);
|
||||
isMax = false;
|
||||
timeProgress = normalH / slotData.growthTime;
|
||||
bar.gameObject.SetActive(true);
|
||||
if (aquariumResultDatas.IsResult())
|
||||
{
|
||||
bar.gameObject.SetActive(false);
|
||||
done.SetActive(true);
|
||||
killed.SetActive(true);
|
||||
text_time.gameObject.SetActive(false);
|
||||
AquariumResultData aquariumResultDatas = AM.data.aquariumResultDatas[slotData.index];
|
||||
text_killed.text = LocalizationMgr.GetFormatTextValue("UI_AquariumPanel_42", aquariumResultDatas.displayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
|
||||
if (injuryH > normalH)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
recoverting.gameObject.SetActive(true);
|
||||
bar.gameObject.SetActive(false);
|
||||
bar_hurt.gameObject.SetActive(true);
|
||||
icon_hurt.gameObject.SetActive(true);
|
||||
bar_hurt.fillAmount = (injuryH - normalH) / slotData.recoveryTime;
|
||||
barProgress = injuryH / slotData.growthTime;
|
||||
if (barProgress > 1)
|
||||
{
|
||||
timeProgress = 1 - ((injuryH - normalH) / slotData.growthTime);
|
||||
}
|
||||
|
||||
int timeRemaining = (int)((injuryH - normalH) * 3600);
|
||||
TimeSpan timeSpan = new TimeSpan(0, 0, timeRemaining);
|
||||
text_time2.text = ConvertTools.ConvertTime2(timeSpan);
|
||||
|
||||
if (timeProgress < 0)
|
||||
{
|
||||
timeProgress = 0;
|
||||
}
|
||||
}
|
||||
else if (normalH >= slotData.growthTime)
|
||||
{
|
||||
text_time.gameObject.SetActive(false);
|
||||
text_max.gameObject.SetActive(true);
|
||||
timeProgress = 1;
|
||||
barProgress = 1;
|
||||
isMax = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
barProgress = normalH / slotData.growthTime;
|
||||
bar.fillAmount = barProgress;
|
||||
}
|
||||
|
||||
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 = $"{ConvertTools.GetNumberString2((int)(rewardCount))}/{ConvertTools.GetNumberString2((int)allRewardCount)}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user