|
|
|
|
@ -9,19 +9,21 @@ namespace Game
|
|
|
|
|
public AttackBehaviour SkillParam;
|
|
|
|
|
public Vector3 HitDir;
|
|
|
|
|
public int OwnerEntity;
|
|
|
|
|
public int HitEntity; //0为非实体对象
|
|
|
|
|
public int HitEntity;
|
|
|
|
|
public float AttackRate;
|
|
|
|
|
public float StunkRate;
|
|
|
|
|
public string SkillId; //是否技能造成的伤害
|
|
|
|
|
public bool IsBreak;
|
|
|
|
|
public int hitIndex;
|
|
|
|
|
public int hitCount;
|
|
|
|
|
public int HitIndex;
|
|
|
|
|
public int HitCount;
|
|
|
|
|
public float Rank;
|
|
|
|
|
public bool Continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ClipAttack : TimelineClipBase
|
|
|
|
|
{
|
|
|
|
|
private AttackClip _mRealAsset;
|
|
|
|
|
private List<GameEntity> _tempTargetList = new List<GameEntity>();
|
|
|
|
|
private readonly List<SkillHitInfo> _tempHitInfoList = new List<SkillHitInfo>();
|
|
|
|
|
|
|
|
|
|
public override void OnEnter()
|
|
|
|
|
{
|
|
|
|
|
@ -33,47 +35,41 @@ namespace Game
|
|
|
|
|
var param = _mRealAsset.template;
|
|
|
|
|
var skill = Owner.skill;
|
|
|
|
|
var castShape = param.Shape;
|
|
|
|
|
var castDir = skill.CastDir;
|
|
|
|
|
castDir = new Vector3(castDir.x, 0, castDir.z); //忽略y
|
|
|
|
|
var castDir = Util.IgnoreY(skill.CastDir);
|
|
|
|
|
var rot = Quaternion.FromToRotation(Vector3.right, castDir);
|
|
|
|
|
var castPos = rot * castShape.Offset + Owner.Pos();
|
|
|
|
|
|
|
|
|
|
Util.DrawShape(castShape, castPos, castDir, Color.red);
|
|
|
|
|
_tempTargetList.Clear();
|
|
|
|
|
|
|
|
|
|
_tempHitInfoList.Clear();
|
|
|
|
|
var (rankMin, rankMax) = (float.MaxValue, float.MinValue);
|
|
|
|
|
Util.ForeachEnemies(Owner.Team(), target =>
|
|
|
|
|
{
|
|
|
|
|
//检测命中
|
|
|
|
|
var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos());
|
|
|
|
|
if (!isHit) return;
|
|
|
|
|
|
|
|
|
|
//排除重复命中
|
|
|
|
|
var hitKey = new Tuple<int, int>(target.ID(), param.hitId);
|
|
|
|
|
if (skill.HitSet.Contains(hitKey)) return;
|
|
|
|
|
skill.HitSet.Add(hitKey);
|
|
|
|
|
|
|
|
|
|
_tempTargetList.Add(target);
|
|
|
|
|
});
|
|
|
|
|
_tempTargetList.Sort((l, r) =>
|
|
|
|
|
{
|
|
|
|
|
var lRank = GetRank(param.hitOrderType, l, castPos, castDir);
|
|
|
|
|
var rRank = GetRank(param.hitOrderType, r, castPos, castDir);
|
|
|
|
|
return lRank.CompareTo(rRank);
|
|
|
|
|
});
|
|
|
|
|
var hitNum = _tempTargetList.Count;
|
|
|
|
|
for (var i = 0; i < hitNum; i++)
|
|
|
|
|
{
|
|
|
|
|
var target = _tempTargetList[i];
|
|
|
|
|
var targetID = target.ID();
|
|
|
|
|
//计算结算顺序rank
|
|
|
|
|
var rank = GetRank(param.hitOrderType, target, castPos, castDir);
|
|
|
|
|
if (rank < rankMin) rankMin = rank;
|
|
|
|
|
if (rank > rankMax) rankMax = rank;
|
|
|
|
|
|
|
|
|
|
var skillHitInfo = new SkillHitInfo
|
|
|
|
|
{
|
|
|
|
|
SkillParam = param,
|
|
|
|
|
AttackRate = 1,
|
|
|
|
|
StunkRate = 1,
|
|
|
|
|
OwnerEntity = Owner.ID(),
|
|
|
|
|
HitEntity = targetID,
|
|
|
|
|
HitEntity = target.ID(),
|
|
|
|
|
HitDir = GetHitDir(param.hitDirType, target, castPos, castDir),
|
|
|
|
|
SkillId = skill.SkillId.Value,
|
|
|
|
|
IsBreak = true,
|
|
|
|
|
hitIndex = i,
|
|
|
|
|
hitCount = hitNum
|
|
|
|
|
Rank = rank,
|
|
|
|
|
};
|
|
|
|
|
if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
|
|
|
|
|
{
|
|
|
|
|
@ -86,7 +82,31 @@ namespace Game
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skill.HitInfo.Enqueue(skillHitInfo);
|
|
|
|
|
_tempHitInfoList.Add(skillHitInfo);
|
|
|
|
|
});
|
|
|
|
|
_tempHitInfoList.Sort((l, r) => l.Rank.CompareTo(r.Rank));
|
|
|
|
|
var hitNum = _tempHitInfoList.Count;
|
|
|
|
|
var rankGroup = 0;
|
|
|
|
|
var rankRange = rankMax - rankMin; //rank范围大小
|
|
|
|
|
var rankRangeEach = rankRange / GameConst.HitMaxSettle; //单个group的rank范围大小
|
|
|
|
|
for (var i = 0; i < hitNum; i++)
|
|
|
|
|
{
|
|
|
|
|
var info = _tempHitInfoList[i];
|
|
|
|
|
info.HitIndex = i;
|
|
|
|
|
info.HitCount = hitNum;
|
|
|
|
|
|
|
|
|
|
var rate = (info.Rank - rankMin) / rankRange;
|
|
|
|
|
if (rate > rankGroup * rankRangeEach)
|
|
|
|
|
{
|
|
|
|
|
rankGroup++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
info.Continue = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Util.Print(info.Continue);
|
|
|
|
|
skill.HitInfo.Enqueue(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|