Example #1
0
 /// <summary>
 /// 魔法/技能攻击产生伤害
 /// </summary>
 public void CastingToHurt(Sprite obj,MagicArgs args)
 {
     //各种伤害情况判断(实际不这么写,需要真实的数值公式计算)
     int damage = Global.random.Next(this.MAG + args.DamageMin, this.MAG + args.DamageMax);
     obj.ChangeLife(-damage, ValueEffects.Decrease);
     //伤害后如果对象生命为0
     if (obj.Life == 0) {
         obj.ChangeLife(0, ValueEffects.Death);
         obj.IsAlive = false;
         if (State == States.Attack) { this.Stand(); }
         this.Target = null;
     } else {
         //显示魔法装饰特效
         if (args.SpecialEffect != SpecialEffects.None) {
             Animation animation = new Animation() { Code = (int)args.SpecialEffect, Coordinate = obj.Center };
             EventHandler handler = null;
             animation.Disposed += handler = delegate {
                 animation.Disposed -= handler;
                 obj.RemoveTemporaryEffect();
             };
             obj.AddTemporaryEffect(animation);
         }
         //魔法附加效果
         switch (args.AdditionalEffect) {
             case AdditionalEffects.Injure:
                 obj.Injure();
                 break;
             case AdditionalEffects.Bounce:
                 obj.BeBounce(Scene.GetGameCoordinate(args.Coordinate), 100, 500);
                 break;
             case AdditionalEffects.BeKnock:
                 obj.BeKnock(40);
                 break;
         }
     }
 }
Example #2
0
 /// <summary>
 /// 重写释放方法
 /// </summary>
 public override void Dispose()
 {
     Target = null;
     magicArgs = null;
     auxiliary.Stop();
     auxiliary.Tick -= auxiliaryTick;
     UnloadStoryboardEvent(storyboard);
     base.Dispose();
 }
Example #3
0
 /// <summary>
 /// 普通攻击使对方造成伤害
 /// </summary>
 /// <param name="obj">对方精灵</param>
 public void AttackToHurt(Sprite obj)
 {
     int damage = this.ATK - obj.DEF < 0 ? 0 : this.ATK - obj.DEF + Global.random.Next(-30, 30);
     //各种伤害情况判断(实际不这么写,需要真实的数值公式计算)
     if (damage == 0 || Global.random.Next(100) < obj.DEX) {
         obj.ChangeLife(0, ValueEffects.Failure);
     } else if (Global.random.Next(100) == 99) {
         obj.ChangeLife(-damage * 2, ValueEffects.DoubleDecrease);
         obj.Injure();
     } else {
         obj.ChangeLife(-damage, ValueEffects.Decrease);
     }
     //伤害后如果对象生命为0
     if (obj.Life == 0) {
         obj.ChangeLife(0, ValueEffects.Death);
         obj.IsAlive = false;
         this.Stand();
         this.Target = null;
     } else {
         //附加被攻击特效
         if (this.AttactEffect != -1) {
             Animation animation = new Animation() { Code = this.AttactEffect, Coordinate = obj.Center };
             EventHandler handler = null;
             animation.Disposed += handler = delegate {
                 animation.Disposed -= handler;
                 obj.RemoveTemporaryEffect();
             };
             obj.AddTemporaryEffect(animation);
         }
     }
 }
Example #4
0
 /// <summary>
 /// 面朝向
 /// </summary>
 /// <param name="sprite">对方精灵</param>
 public void TowardTo(Sprite sprite)
 {
     Point current = new Point(Canvas.GetLeft(this) + Center.X, Canvas.GetTop(this) + Center.Y);
     Point target = new Point(Canvas.GetLeft(sprite) + sprite.Center.X, Canvas.GetTop(sprite) + sprite.Center.Y);
     SetDirection(current, target);
 }
Example #5
0
 /// <summary>
 /// 移除容器中的精灵
 /// </summary>
 /// <param name="sprite">精灵对象</param>
 void RemoveContainerSprite(Sprite sprite)
 {
     sprite.Dispose();
     container.Children.Remove(sprite);
     sprite = null;
 }
Example #6
0
 /// <summary>
 /// 移除精灵
 /// </summary>
 /// <param name="sprite">精灵对象</param>
 public void RemoveSprite(Sprite sprite)
 {
     sprites.Remove(sprite);
     RemoveContainerSprite(sprite);
 }
Example #7
0
 /// <summary>
 /// 添加精灵
 /// </summary>
 /// <param name="sprite">精灵对象</param>
 public void AddSprite(Sprite sprite)
 {
     sprites.Add(sprite);
     container.Children.Add(sprite);
 }