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#

2 years ago
using System;
using UnityEngine;
namespace Game
{
public class SkillHitInfo
{
public AttackBehaviour SkillParam;
2 years ago
public Vector3 HitDir;
2 years ago
public int OwnerEntity;
public int HitEntity; //0为非实体对象
2 years ago
public float AttackRate;
public float StunkRate;
2 years ago
public string SkillId; //是否技能造成的伤害
public bool IsBreak;
}
2 years ago
public class ClipAttack : TimelineClipBase
{
private AttackClip _mRealAsset;
2 years ago
public override void OnEnter()
{
_mRealAsset = Asset as AttackClip;
}
2 years ago
public override void OnStay()
{
var param = _mRealAsset.template;
2 years ago
var skill = Owner.skill;
var castShape = param.Shape;
2 years ago
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();
2 years ago
Util.DrawShape(castShape, castPos, castDir, Color.red);
Util.ForeachEnemies(Owner.Team(), target =>
2 years ago
{
var isHit = UtilShape.IsOverlap(castShape, castPos, castDir, target.hp.HitBoxShape, target.Pos());
2 years ago
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
2 years ago
{
2 years ago
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)
2 years ago
{
2 years ago
var featureSkill = skillCfg.GetFeatureSkill();
skillHitInfo.AttackRate = featureSkill.AttackRate;
skillHitInfo.StunkRate = featureSkill.StunRate;
2 years ago
}
}
2 years ago
target.skill.HitInfo.Add(skillHitInfo);
});
2 years ago
}
2 years ago
public override void OnLeave()
{
}
}
}