2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.6 KiB
C#

using System;
using UnityEngine;
namespace Game
{
public class SkillHitInfo
{
public AttackBehaviour SkillParam;
public Vector3 HitDir;
public int OwnerEntity;
public int HitEntity; //0为非实体对象
public float AttackRate;
public float StunkRate;
public string SkillId; //是否技能造成的伤害
public bool IsBreak;
}
public class ClipAttack : TimelineClipBase
{
private AttackClip _mRealAsset;
public override void OnEnter()
{
_mRealAsset = Asset as AttackClip;
}
public override void OnStay()
{
var param = _mRealAsset.template;
var skill = Owner.skill;
var castShape = param.Shape;
var castDir = Owner.skill.CastDir;
castDir = new Vector3(castDir.x, 0, castDir.z); //忽略y
var rot = Quaternion.FromToRotation(Vector3.right, castDir);
var castPos = rot * castShape.Offset + Owner.Pos();
Util.DrawShape(castShape, castPos, castDir, Color.red);
Util.ForeachEnemies(Owner.Team(), target =>
{
var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos());
if (!isHit) return;
var targetID = target.ID();
var hitKey = new Tuple<int, int>(targetID, param.hitId);
if (Owner.skill.HitSet.Contains(hitKey)) return;
Owner.skill.HitSet.Add(hitKey);
var skillHitInfo = new SkillHitInfo
{
SkillParam = param,
AttackRate = 1,
StunkRate = 1,
OwnerEntity = Owner.ID(),
HitEntity = targetID,
HitDir = castDir,
SkillId = skill.SkillId.Value,
IsBreak = true,
};
if (!string.IsNullOrEmpty(skillHitInfo.SkillId))
{
var skillCfg = Util.GetSkillMasterConfigData(skillHitInfo.SkillId);
if (skillCfg != null)
{
var featureSkill = skillCfg.GetFeatureSkill();
skillHitInfo.AttackRate = featureSkill.AttackRate;
skillHitInfo.StunkRate = featureSkill.StunRate;
}
}
target.skill.HitInfo.Add(skillHitInfo);
});
}
public override void OnLeave()
{
}
}
}