90 lines
2.8 KiB
C#
90 lines
2.8 KiB
C#
/*
|
|
* @Author: 白哉
|
|
* @Description:
|
|
* @Date: 2025年07月01日 星期二 11:07:48
|
|
* @Modify:
|
|
*/
|
|
|
|
|
|
using System.Collections.Generic;
|
|
using Logic.TH1_Anim;
|
|
using TH1_Anim.Fragments;
|
|
using UnityEngine;
|
|
|
|
namespace TH1_Anim
|
|
{
|
|
public enum FragmentType{
|
|
None,
|
|
Bounce,
|
|
Move,
|
|
Attack,
|
|
AttackAndCounter,
|
|
AttackAndCounterDie,
|
|
MoveKill,
|
|
NotMoveKill,
|
|
Max
|
|
}
|
|
|
|
public static class FragmentFactory
|
|
{
|
|
public static FragmentBase Create(FragmentType type,IFragmentData data)
|
|
{
|
|
return type switch
|
|
{
|
|
FragmentType.Move => new FragmentMove(data as FragmentMoveData),
|
|
FragmentType.AttackAndCounter or FragmentType.AttackAndCounterDie => new FragmentAttackAndCounter(data as FragmentAttackAndCounterData),
|
|
FragmentType.Attack => new FragmentAttack(data as FragmentAttackAndCounterData),
|
|
FragmentType.MoveKill => new FragmentMoveKill(data as FragmentAttackAndCounterData),
|
|
FragmentType.NotMoveKill => new FragmentNotMoveKill(data as FragmentAttackAndCounterData),
|
|
_ => null
|
|
};
|
|
}
|
|
}
|
|
public class FragmentManager
|
|
{
|
|
public static FragmentManager Instance = new FragmentManager();
|
|
private FragmentManager() { }
|
|
|
|
public List<FragmentBase> Fragment => _fragments;
|
|
private List<FragmentBase> _fragments =new List<FragmentBase>();
|
|
|
|
|
|
public void AddFragment(FragmentBase fragment)
|
|
{
|
|
_fragments.Add(fragment);
|
|
Update();
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
foreach (var fragment in _fragments)
|
|
{
|
|
switch( fragment.State)
|
|
{
|
|
case FragmentState.Wrong:
|
|
fragment.OnFinished();
|
|
fragment.State = FragmentState.Finished;
|
|
break;
|
|
case FragmentState.Prepare:
|
|
fragment.OnStart(Time.time);
|
|
fragment.State = FragmentState.Playing;
|
|
break;
|
|
case FragmentState.Playing:
|
|
fragment.OnUpdate(Time.time - fragment.StartTime);
|
|
if (fragment.CheckDone(Time.time - fragment.StartTime))
|
|
{
|
|
fragment.OnFinished();
|
|
fragment.State = FragmentState.Finished;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
for (int i = _fragments.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_fragments[i].State != FragmentState.Finished) continue;
|
|
_fragments.RemoveAt(i);
|
|
}
|
|
}
|
|
}
|
|
} |