126 lines
4.3 KiB
C#
126 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
using TH1_Anim.UnitAtomAnim;
|
|
using TH1Renderer;
|
|
using UnityEngine;
|
|
|
|
namespace TH1_Renderer.UnitAtomAnim
|
|
{
|
|
|
|
public static class UnitAtomAnimDataFactory
|
|
{
|
|
public static IUnitAtomAnimData Create(UnitAtomAnimType type,Vector2Int originGridPos,Vector2Int targetGridPos)
|
|
{
|
|
if (type is UnitAtomAnimType.AttackMove or UnitAtomAnimType.AttackMoveBack)
|
|
return new UnitAtomAnimMoveData(originGridPos,targetGridPos,null) { };
|
|
if(type is UnitAtomAnimType.Move)
|
|
return new UnitAtomAnimMoveData(originGridPos,targetGridPos,new List<Vector2Int>(){originGridPos,targetGridPos}) { };
|
|
if (type is UnitAtomAnimType.ParabolaMove)
|
|
return new UnitAtomAnimParabolaMoveData(originGridPos, targetGridPos) { };
|
|
Debug.Log("AtomAnimData:错误的type类型");
|
|
return null;
|
|
}
|
|
public static IUnitAtomAnimData Create(UnitAtomAnimType type,Vector2Int originGridPos,Vector2Int targetGridPos,List<Vector2Int> Path)
|
|
{
|
|
if (type is UnitAtomAnimType.Move)
|
|
return new UnitAtomAnimMoveData(originGridPos,targetGridPos,Path) { };
|
|
Debug.Log("AtomAnimData:错误的type类型");
|
|
return null;
|
|
}
|
|
|
|
public static IUnitAtomAnimData CreateUnitAtomAnimProjectile(UnitAtomAnimType type,ProjectileType projectileType,Vector2Int originGridPos,Vector2Int targetGridPos)
|
|
{
|
|
if (type is UnitAtomAnimType.Projectile)
|
|
return new UnitAtomAnimProjectileData(projectileType, originGridPos, targetGridPos) { };
|
|
Debug.Log("AtomAnimData:错误的type类型");
|
|
return null;
|
|
}
|
|
|
|
public static IUnitAtomAnimData Create(UnitAtomAnimType type)
|
|
{
|
|
if (type == UnitAtomAnimType.Bounce)
|
|
return new UnitAtomAnimBounceData() { };
|
|
Debug.Log("AtomAnimData:错误的type类型");
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
public abstract class IUnitAtomAnimData
|
|
{
|
|
public UnitAtomAnimType Type;
|
|
|
|
protected IUnitAtomAnimData(UnitAtomAnimType type)
|
|
{
|
|
Type = type;
|
|
}
|
|
|
|
}
|
|
|
|
public class UnitAtomAnimBounceData : IUnitAtomAnimData
|
|
{
|
|
public UnitAtomAnimBounceData() : base(UnitAtomAnimType.Bounce)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public class UnitAtomAnimCommonData : IUnitAtomAnimData
|
|
{
|
|
public UnitAtomAnimCommonData(UnitAtomAnimType type) : base(type)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
//Move KillMove AttackMove AttackMoveBack 全部用这个
|
|
public class UnitAtomAnimMoveData : IUnitAtomAnimData
|
|
{
|
|
public List<Vector2Int> Path;
|
|
public Vector2Int OriginGridPos;
|
|
public Vector2Int TargetGridPos;
|
|
public float DurationOverride;
|
|
|
|
public UnitAtomAnimMoveData(Vector2Int originGridPos, Vector2Int targetGridPos,List<Vector2Int> path,
|
|
float durationOverride = 0f) : base(UnitAtomAnimType.Move)
|
|
{
|
|
Path = path;
|
|
OriginGridPos = originGridPos;
|
|
TargetGridPos = targetGridPos;
|
|
DurationOverride = durationOverride;
|
|
}
|
|
}
|
|
|
|
public class UnitAtomAnimProjectileData : IUnitAtomAnimData
|
|
{
|
|
public ProjectileType ProjectileType;
|
|
public Vector2Int OriginGridPos;
|
|
public Vector2Int TargetGridPos;
|
|
|
|
public UnitAtomAnimProjectileData(ProjectileType projectileType, Vector2Int originGridPos,
|
|
Vector2Int targetGridPos) : base(UnitAtomAnimType.Projectile)
|
|
{
|
|
ProjectileType = projectileType;
|
|
OriginGridPos = originGridPos;
|
|
TargetGridPos = targetGridPos;
|
|
}
|
|
}
|
|
|
|
public class UnitAtomAnimParabolaMoveData : IUnitAtomAnimData
|
|
{
|
|
public Vector2Int OriginGridPos;
|
|
public Vector2Int TargetGridPos;
|
|
public float Height;
|
|
public float Duration;
|
|
|
|
public UnitAtomAnimParabolaMoveData(Vector2Int originGridPos, Vector2Int targetGridPos, float height = 18f,
|
|
float duration = 1.1f)
|
|
: base(UnitAtomAnimType.ParabolaMove)
|
|
{
|
|
OriginGridPos = originGridPos;
|
|
TargetGridPos = targetGridPos;
|
|
Height = height;
|
|
Duration = duration;
|
|
}
|
|
}
|
|
}
|