123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- 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
- {
- /// <summary>
- /// FileName: XmdsBuff_PropChange.cs
- /// Author: Alex.Yu
- /// Corporation:...
- /// Description:
- /// DateTime: 2015/6/10 20:07:30
- /// </summary>
- public class XmdsBuff_PropChange : XmdsBuffBase
- {
- /// <summary>
- /// 当前变更类型.
- /// </summary>
- public XmdsVirtual.UnitAttributeType CurentChangeType = 0;
- public int CurrentValue = 0;
- public bool IsPercent = true;
- private List<int> mOpList = new List<int>();
- 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.mUnit.IsPlayer ? 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);
- }
- }
- }
- }
|