TH1/Unity/Assets/Scripts/TH1_Anim/Fragments/FragmentCityExpUp.cs
2026-01-04 02:45:59 +08:00

85 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: 白哉
* @Description:
* @Date: 2025年07月01日 星期二 14:07:05
* @Modify:
*/
using JetBrains.Annotations;
using Logic.CrashSight;
using RuntimeData;
using TH1_Anim.UnitAtomAnim;
using TH1_DataAssetsScript;
using TH1_Logic.Core;
using TH1_Renderer;
using TH1_Renderer.UnitAtomAnim;
using TH1Renderer;
using UnityEngine;
namespace TH1_Anim.Fragments
{
public class FragmentCityExpUp : FragmentBase
{
public GridRenderer GridRenderer;
public CityInfoRenderer CityInfoRenderer;
public int Level;
public int LevelExp;
public bool IsDown;
private float _step1_time;
private bool _step1_bounce;
public FragmentCityExpUp(FragmentCityExpUpData data) : base()
{
GridRenderer = data.GridRenderer;
CityInfoRenderer = data.CityInfoRenderer;
Level = data.Level;
LevelExp = data.LevelExp;
IsDown = data.IsDown;
_step1_time = 0f;
_step1_bounce = false;
Duration = 0.2f;
}
public override bool CheckDone(float progressTime)
{
//超时保险
if (progressTime > Duration * 2)
{
Debug.Log($"Fragement Timeout {this.GetType()}");
return true;
}
if (!_step1_bounce) return false;
if (progressTime <= Duration)
return false;
return true;
}
public override void OnUpdate(float progressTime)
{
//Step #1执行第一步,弹动并且更新cityInfo的人口条部分和金钱部分
if (progressTime >= _step1_time && !_step1_bounce)
{
if (GridRenderer == null || CityInfoRenderer == null)
{
LogSystem.LogError($"Wrong With FragmentCityExpUp lv={Level},exp={LevelExp}");
_step1_bounce = true;
return;
}
_step1_bounce = true;
GridRenderer.SetBounceAnim();
CityInfoRenderer.UpdateLevelShow(Level,LevelExp);
//如果是降级或者Level <=0时的升级 可能会导致城市金币变化
if(IsDown || LevelExp <= 0)CityInfoRenderer.InstantUpdateCityCoinTech();
return;
}
}
}
}