Exemplo n.º 1
0
 /// <summary>
 /// 魔法/技能攻击产生效果(伤害/治疗)
 /// </summary>
 public void CastingToEffect(RoleBase target, MagicArgs args)
 {
     //依据魔法实效类型处理
     switch (args.MagicEffectType) {
         case MagicEffectTypes.Gain:
             target.ChangeLife(Convert.ToInt32(args.Tag), ValueEffects.Increase);
             break;
         case MagicEffectTypes.Reduction:
             //模拟伤害计算
             int damage = RandomSeed.Next(this.MAG + args.EffectMin, this.MAG + args.EffectMax);
             if (RandomSeed.Next(100) > 90) {
                 target.ChangeLife(0, ValueEffects.Failure);
                 return;
             } else if (RandomSeed.Next(100) > 85) {
                 //暴击
                 target.ChangeLife(-damage * 2, ValueEffects.DoubleDecrease);
             } else {
                 target.ChangeLife(-damage, ValueEffects.Decrease);
             }
             //伤害后如果对象生命为0
             if (target.Life == 0) {
                 target.ChangeLife(0, ValueEffects.Death);
                 if (Action == Actions.Attack && !isSpecialMove) { this.Stop(); }
                 this.Target = null;
                 return;
             }
             break;
     }
     //显示魔法附加效果
     if (args.AdditionalEffect != AdditionalEffects.None) {
         EventHandler handler = null;
         AnimationBase animation = new AnimationBase() {
             Code = (int)args.AdditionalEffect,
             Position = target.Center,
             Z = 1000,
         };
         animation.Disposed += handler = (s0, e0) => {
             animation.Disposed -= handler;
             target.RemoveEffect(EffectTypes.Temporary);
         };
         target.AddEffect(animation, EffectTypes.Temporary);
     }
     //魔法特殊效果
     switch (args.SpecialEffect) {
         case SpecialEffects.Injure:
             target.Injure();
             break;
         case SpecialEffects.Bounce:
             target.BeBounce(args.Position, Convert.ToDouble(args.Tag), 500);
             break;
         case SpecialEffects.Knock:
             //target.BeKnock(40);
             break;
         case SpecialEffects.Freeze:
             //测试,50%几率命中
             if (RandomSeed.Next(100) > 50) {
                 target.BeFreeze(Convert.ToDouble(args.Tag));
             }
             break;
         case SpecialEffects.Petrifaction:
             //测试,50%几率命中
             if (RandomSeed.Next(100) > 50) {
                 target.BePetrifaction(Convert.ToDouble(args.Tag));
             }
             break;
         case SpecialEffects.Poison:
             target.BePoison(RandomSeed.Next(200, 500), Convert.ToDouble(args.Tag));
             break;
         case SpecialEffects.Quiver:
             target.Quiver(6);
             break;
     }
 }