using CommonAI.Zone.Instance;
using CommonAI.Zone.Formula;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XmdsCommon.Plugin;
using XmdsCommonServer.Plugin;
using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
using CommonAI.Zone;
using XmdsCommonSkill.Plugin.Interface;
using static XmdsCommonSkill.Plugin.Interface.ComSpellTemplate;
using CommonAI.Data;
using CommonAI.Zone.Helper;
using CommonLang;
using static CommonAI.Zone.Instance.InstanceUnit;

namespace XmdsCommonSkill.Plugin.Buffs
{
    /// <summary>
    /// FileName: XmdsBuff_Shield_AbsorbDamage.cs
    /// Author: Alex.Yu
    /// Corporation:... 
    /// Description: 护盾-受击释放法术
    /// DateTime: 2015/6/8 21:05:08
    /// </summary>

    public class XmdsBuff_Shield_HitLaunchSpell : XmdsBuff_Shield_AbsorbDamage
	{
		// 击盾,释放法术
		public LaunchSpell hitLaunchSpellInfo;

		// 击盾,加buff
		public int hitAddBuffID;
		//shabiyang
		public int hitAddBuffLayers;

        public override int GetAbilityID()
        {
            return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.SHIELD_HitLaunchSpell;
        }

		public override void CopyTo(UnitBuff other)
		{
			var ret = other as XmdsBuff_Shield_HitLaunchSpell;
			ret.hitLaunchSpellInfo = (LaunchSpell)this.hitLaunchSpellInfo.Clone();
			ret.hitAddBuffID = this.hitAddBuffID;
			ret.hitAddBuffLayers = this.hitAddBuffLayers;
			base.CopyTo(other);
		}

		protected override void OnAbsortDamage(XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source)
		{
			hitted.mUnit.Parent.unitLaunchSpell(XmdsSkillType.cardSkill, hitted.mUnit, this.hitLaunchSpellInfo, attacker.mUnit.X, attacker.mUnit.Y, attacker.mUnit.ID);

			if(hitAddBuffID > 0)
			{
				hitted.mUnit.AddBuff(hitAddBuffID, hitted.mUnit, 0, false, false, false, 0, hitAddBuffLayers);
			}			
		}
	}
}