|
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
// 近战攻击
|
public class CloseCombatBullet : Bullet
|
{
|
|
protected int keyFrameIndex = 0;
|
|
protected int frame = 0;
|
|
public CloseCombatBullet(BattleObject _caster, SkillConfig _skillConfig, List<H0604_tagUseSkillAttack.tagSkillHurtObj> _hurtList, BattleField _battleField, Action _onComplete)
|
: base(_caster, _skillConfig, _hurtList, _battleField, _onComplete)
|
{
|
|
}
|
|
|
public override void Start()
|
{
|
base.Start();
|
|
// 用skillconfig.xp来判断不保险
|
MotionName motionName = GetMotionName(skillConfig.SkillMotionName);
|
caster.motionBase.PlayAnimation(motionName, false);
|
}
|
|
public MotionName GetMotionName(string strMotionName)
|
{
|
return Enum.Parse<MotionName>(strMotionName);
|
}
|
|
|
protected override void OnSkillComplete()
|
{
|
foreach (var hurtObj in hurtList)
|
{
|
BattleObject targetObj = battleField.battleObjMgr.GetBattleObject((int)hurtObj.ObjID);
|
if (targetObj != null)
|
{
|
long curHP = GeneralDefine.GetFactValue(hurtObj.CurHP, hurtObj.CurHPEx);
|
targetObj.teamHero.curHp = curHP;
|
}
|
}
|
base.OnSkillComplete();
|
|
}
|
|
|
protected override void PopDamage()
|
{
|
if (keyFrameIndex >= skillConfig.DamageDivide.Length)
|
{
|
Debug.LogError("CloseCombatBullet PopDamage keyFrameIndex out of range: " + keyFrameIndex);
|
return;
|
}
|
|
int[] tenKDamagePercentArray = skillConfig.DamageDivide[keyFrameIndex++];
|
|
foreach (var hurtObj in hurtList)
|
{
|
long factDamage = GeneralDefine.GetFactValue(hurtObj.HurtHP, hurtObj.HurtHPEx);
|
List<long> damageList = new List<long>();
|
for (int i = 0; i < tenKDamagePercentArray.Length; i++)
|
{
|
long damage = (long)(Mathf.Round(factDamage * tenKDamagePercentArray[i] / 10000.0f));
|
damageList.Add(damage);
|
}
|
|
BattleObject targetObj = battleField.battleObjMgr.GetBattleObject((int)hurtObj.ObjID);
|
if (targetObj != null)
|
{
|
// 播放受击动作
|
targetObj.Hurt(damageList, hurtObj.AttackType);
|
}
|
}
|
}
|
}
|