/// <summary> /// 更新对象目标面板中的生命值 /// </summary> void TargetInfo_LifeChanged(object sender, ValueEffectEventArgs e) { RoleBase role = sender as RoleBase; targetInfo.UpdateLife(role.Life, role.LifeMax); if (role.Life == 0) { targetInfo.Visibility = Visibility.Collapsed; } }
/// <summary> /// 角色生命值改变 /// </summary> void role_LifeChanged(object sender, ValueEffectEventArgs e) { RoleBase role = sender as RoleBase; if (role != null) { if (e.Effect == ValueEffects.Death) { space.RemoveRole(role); } else { FlyableText flyableText = new FlyableText() { SpaceLayer = role.SpaceLayer, Z = role.Z }; flyableText.SetAttackText(e.Effect, e.ChangedValue); double x = role.Position.X - flyableText.ContentWidth / 2; double y = role.Position.Y - (role.State == States.Riding ? 185 : 145); EventHandler handler = null; flyableText.MoveCompleted += handler = delegate { flyableText.MoveCompleted -= handler; space.RemoveUIElement(flyableText); }; space.AddUIElement(flyableText); flyableText.Move(new Point(x, y), new Point(x, y - 80), 6.5, MoveModes.InjureText); } } }