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

98 lines
2.9 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 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 FragmentCityExp : FragmentBase
{
public GridRenderer OriginGridRenderer;
public GridRenderer TargetGridRenderer;
public CityInfoRenderer TargetCityInfoRenderer;
public int Dis;
private float _step1_time;
private float _step2_time;
private bool _step1_start;
private bool _step2_bounce;
public FragmentCityExp(FragmentCityExpData data) : base()
{
OriginGridRenderer = data.OriginGridRenderer;
TargetGridRenderer = data.TargetGridRenderer;
TargetCityInfoRenderer = data.TargetCityInfoRenderer;
_step1_time = 0f;
Dis = data.Dis;
if (Dis > 5) Dis = 5;
if (Dis == 2) Dis = 1;
// 目前等待时间不和dis挂钩了 2格距离的收获城市经验也和1格距离收获经验的时间是一样的,但是N格的话时间还是长的
float tmpTime = Table.Instance.ProjectileTypeDataAssets.GetProjectileTypeInfo(ProjectileType.CityExp, out var info)
? info.AnimTime
: 0.2f;
_step2_time = tmpTime * Dis;
_step1_start = false;
_step2_bounce = false;
Duration = _step2_time; // + Table.Instance.AnimDataAssets.BounceTime;
}
public override bool CheckDone(float progressTime)
{
//超时保险
if (progressTime > Duration * 2)
{
Debug.Log($"Fragement Timeout {this.GetType()}");
return true;
}
if (!_step1_start || !_step2_bounce) return false;
if (progressTime <= Duration)
return false;
return true;
}
public override void OnUpdate(float progressTime)
{
//Step #1执行第一步
if (progressTime >= _step1_time && !_step1_start)
{
_step1_start = true;
MapRenderer.Instance.ProjectileManager.CreateProjectile(OriginGridRenderer.GridVector3(),TargetGridRenderer.GridVector3(),ProjectileType.CityExp,Dis);
return;
}
//Step #2执行第一步 - 更新对应城市 并且弹动
if (progressTime >= _step2_time && !_step2_bounce)
{
_step2_bounce = true;
//播放格子弹动效果
//TargetGridRenderer.SetBounceAnim();
}
}
}
}