using CommonAI.Zone.Instance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XmdsCommon.Message;
using XmdsCommonServer.Plugin;
using XmdsCommonServer.Plugin.XmdsSkillTemplate.DamageCalculator;
using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills;
namespace XmdsCommonSkill.Plugin.Buffs
{
///
/// FileName: XmdsBuff_PropChange.cs
/// Author: Alex.Yu
/// Corporation:...
/// Description:
/// DateTime: 2015/6/10 20:07:30
///
public class XmdsBuff_PropChange : XmdsBuffBase
{
///
/// 当前变更类型.
///
public XmdsVirtual.UnitAttributeType CurentChangeType = 0;
public int CurrentValue = 0;
public bool IsPercent = true;
private List mOpList = new List();
public override int GetAbilityID()
{
return (int)XmdsCommon.Plugin.XmdsBuffProperties.XmdsBuffAbility.PropChange | (int)CurentChangeType;
}
public override void CopyTo(UnitBuff other)
{
var ret = other as XmdsBuff_PropChange;
ret.CurentChangeType = this.CurentChangeType;
ret.CurrentValue = this.CurrentValue;
ret.IsPercent = this.IsPercent;
base.CopyTo(other);
}
protected override void OnBindTemplate(ref CommonAI.Zone.BuffTemplate buffTemplate)
{
base.OnBindTemplate(ref buffTemplate);
}
protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state)
{
int v = (state.OverlayLevel + 1) * CurrentValue;
ChangeProp(hitter, CurentChangeType, v);
int valueMax = hitter.IsPlayerUnit() ? 10000 : 25000;
if(state.OverlayLevel > 10 || v > valueMax)
{
log.Warn("XmdsBuff_PropChange信息输出:" + this.BindBuffID + ", 层:" + state.OverlayLevel + ", " + CurentChangeType + ", 值:" + v +
", hitter:" + hitter.mInfo.ID + ", attacker: " + attacker.mInfo.ID + ", 场景:" + hitter.mUnit.Parent.GetSceneID() + ", 百分比:" + this.IsPercent);
}
}
protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace)
{
//指令集操作.
for (int i = 0; i < mOpList.Count; i++)
{
hitter.RemovePropChangeOperation(mOpList[i]);
}
mOpList.Clear();
}
private void ChangeProp(XmdsVirtual hitter, XmdsVirtual.UnitAttributeType type, int effectValue)
{
if(type == XmdsVirtual.UnitAttributeType.None)
{
XmdsVirtual.FormatLog("单位【{0}】,属性变更BUFF未指定更改能力类型", hitter.mProp.ServerData.BaseInfo.name);
return;
}
switch (type)
{
case XmdsVirtual.UnitAttributeType.Attack:
SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.GONG_JI_SHANG_SHENG, effectValue);
break;
case XmdsVirtual.UnitAttributeType.Defence:
SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.FANG_YU_SHANG_SHENG, effectValue);
break;
case XmdsVirtual.UnitAttributeType.HealEffect:
SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.ZHI_LIAO_SHANG_SHENG, effectValue);
break;
case XmdsVirtual.UnitAttributeType.HealedEffect:
SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.ZHI_LIAO_SHANG_SHENG, effectValue);
break;
case XmdsVirtual.UnitAttributeType.CritRate:
SendMsg(hitter, CommonAI.XmdsConstConfig.BattleFloatTipsType.BAO_JI_SHANG_SHENG, effectValue);
break;
default:
break;
}
XmdsVirtual.PropChangeOperation pco;
pco = hitter.CreatePropChangeOpertation(this);
pco.Type = type;
pco.Value = effectValue;
pco.OpType = GetOptType();
mOpList.Add(hitter.AddPropChangeOperation(pco));
}
private float GetValue(float changeValue, float UnitProp)
{
float ret = 0;
if (IsPercent == true)
{
ret = UnitProp * (changeValue / XmdsDamageCalculator.PERER);
}
else
{
ret = changeValue;
}
return ret;
}
private XmdsVirtual.PropChangeOperation.OperateType GetOptType()
{
if (IsPercent)
{
return XmdsVirtual.PropChangeOperation.OperateType.Percent;
}
else
{
return XmdsVirtual.PropChangeOperation.OperateType.Value;
}
}
private void SendMsg(XmdsVirtual target, CommonAI.XmdsConstConfig.BattleFloatTipsType type, float effectvalue)
{
if (ShowBuffTips == false) { return; }
if (effectvalue > 0)
{
BattleFloatTipsEventB2C evt = new BattleFloatTipsEventB2C();
evt.Type = type;
target.SendBattleFloatTipsEventB2C(evt);
}
}
}
}