Example #1
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 #2
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 #3
0
 /// <summary>
 /// 添加身体特效
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void AddSurroundEffect(Animation animation)
 {
     RemoveSurroundEffect();
     surroundEffect = animation;
     this.Children.Add(surroundEffect);
 }
Example #4
0
 /// <summary>
 /// 添加临时特效
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void AddTemporaryEffect(Animation animation)
 {
     RemoveTemporaryEffect();
     temporaryEffect = animation;
     this.Children.Add(temporaryEffect);
 }
Example #5
0
 void Teleport_Completed(object sender, EventArgs e)
 {
     Storyboard storyboard = sender as Storyboard;
     storyboard.Completed -= Teleport_Completed;
     //加入传送时周身光束环绕效果
     Animation aura = new Animation() {
         Code = 1,
         Coordinate = this.Center,
     };
     EventHandler handler = null;
     aura.Disposed += handler = delegate {
         aura.Disposed -= handler;
         this.Children.Remove(aura);
     };
     this.Children.Add(aura);
 }
Example #6
0
 /// <summary>
 /// 添加选中特效
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void AddSelectedEffect(Animation animation)
 {
     RemoveSelectedEffect();
     selectedEffect = animation;
     this.Children.Add(selectedEffect);
 }
Example #7
0
 /// <summary>
 /// 移除动画
 /// </summary>
 /// <param name="animation">动画对象</param>
 void RemoveAnimation(Animation animation)
 {
     this.Children.Remove(animation);
     animation.Dispose();
 }
Example #8
0
 /// <summary>
 /// 移除容器中的动画
 /// </summary>
 /// <param name="animation">动画对象</param>
 void RemoveContainerAnimation(Animation animation)
 {
     animation.Dispose();
     container.Children.Remove(animation);
     animation = null;
 }
Example #9
0
 /// <summary>
 /// 实际地图背景下载完毕
 /// </summary>
 void realMapDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
 {
     WebClient realMapDownloader = sender as WebClient;
     realMapDownloader.OpenReadCompleted -= realMapDownloader_OpenReadCompleted;
     string[] args = e.UserState.ToString().Split(',');
     //如果异步与同步一致
     if (Convert.ToInt32(args[1]) == index) {
         //呈现实际地图背景
         BodyStretch = Stretch.None;
         BodySource = Global.GetWebImage(string.Format("Scene/{0}/RealMap.jpg", args[0]));
         //加载遮挡物
         IEnumerable<XElement> iMask = info.Element("Masks").Elements();
         for (int i = 0; i < iMask.Count(); i++) {
             XElement xMask = iMask.ElementAt(i);
             Mask mask = new Mask() {
                 BodySource = Global.GetWebImage(string.Format("Scene/{0}/Mask/{1}.png", args[0], xMask.Attribute("Code").Value)),
                 Opacity = (double)xMask.Attribute("Opacity"),
                 Coordinate = new Point((double)xMask.Attribute("X") - Offset.X, (double)xMask.Attribute("Y") - Offset.Y),
                 Z = (int)xMask.Attribute("Z") - Offset.Y
             };
             AddMask(mask);
         }
         //加载动画
         IEnumerable<XElement> iAnimation = info.Element("Animations").Elements();
         for (int i = 0; i < iAnimation.Count(); i++) {
             XElement xAnimation = iAnimation.ElementAt(i);
             Animation animation = new Animation() {
                 Code = (int)xAnimation.Attribute("Code"),
                 Opacity = (double)xAnimation.Attribute("Opacity"),
                 Coordinate = new Point((double)xAnimation.Attribute("X") - Offset.X, (double)xAnimation.Attribute("Y") - Offset.Y),
                 Z = (int)xAnimation.Attribute("Z") - Offset.Y,
                 Tip = xAnimation.Attribute("Tip").Value,
             };
             AddAnimation(animation);
         }
     }
 }
Example #10
0
 /// <summary>
 /// 移除动画
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void RemoveAnimation(Animation animation)
 {
     animations.Remove(animation);
     RemoveContainerAnimation(animation);
 }
Example #11
0
 /// <summary>
 /// 添加动画
 /// </summary>
 /// <param name="animation">动画对象</param>
 public void AddAnimation(Animation animation)
 {
     animations.Add(animation);
     container.Children.Add(animation);
 }