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.
85 lines
3.1 KiB
C#
85 lines
3.1 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
public class SkillHitInfo
|
|
{
|
|
public AttackBehaviour SkillParam;
|
|
public float AttackRate;
|
|
public float StunkRate;
|
|
public int OwnerEntity;
|
|
public int HitEntity; //0为非实体对象
|
|
public Vector3 HitDir;
|
|
public bool IsDealed; //已经结算
|
|
public string SkillId; //是否技能造成的伤害
|
|
public uint Performance; //性能tag的mask
|
|
public int StaggerLevel;
|
|
public bool IsBreak;
|
|
public EHitType HitType;
|
|
}
|
|
|
|
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)
|
|
{
|
|
var targetID = target.ID();
|
|
var hitKey = new Tuple<int, int>(targetID, param.hitId);
|
|
if (Owner.skill.SkillHitInfo.ContainsKey(hitKey)) return;
|
|
var skillHitInfo = new SkillHitInfo
|
|
{
|
|
SkillParam = param,
|
|
AttackRate = 1,
|
|
StunkRate = 1,
|
|
OwnerEntity = Owner.ID(),
|
|
HitEntity = targetID,
|
|
HitDir = castDir,
|
|
IsDealed = false,
|
|
SkillId = skill.SkillId.Value,
|
|
Performance = 0,
|
|
StaggerLevel = param.staggerLevel,
|
|
IsBreak = true,
|
|
HitType = param.hitType,
|
|
};
|
|
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;
|
|
}
|
|
}
|
|
|
|
Owner.skill.SkillHitInfo[hitKey] = skillHitInfo;
|
|
}
|
|
});
|
|
}
|
|
|
|
public override void OnLeave()
|
|
{
|
|
}
|
|
}
|
|
} |