/// <summary> /// 改变最大生命值 /// </summary> public void ChangeLifeMax(int changedValue, ValueEffects effect) { int change = LifeMax + changedValue; LifeMax = change < 0 ? 0 : change; if (LifeMaxChanged != null) { LifeMaxChanged(this, new ValueEffectEventArgs() { ChangedValue = changedValue, Effect = effect }); } }
/// <summary> /// 设置值 /// </summary> /// <param name="effect"></param> /// <param name="value"></param> public void SetText(ValueEffects effect, double value) { switch (effect) { case ValueEffects.None: break; case ValueEffects.Increase: Content = value.ToString(); BodyWeight = FontWeights.Bold; BodySize = 24; BodyStyle = FontStyles.Normal; BodyColor = new SolidColorBrush(Color.FromArgb(255, 1, 130, 178)); break; case ValueEffects.Decrease: Content = value.ToString(); BodyWeight = FontWeights.Bold; BodySize = 24; BodyStyle = FontStyles.Normal; BodyColor = Global.RainbowBrush(213, 99, 99, 247, 219, 123); break; case ValueEffects.DoubleDecrease: Content = string.Format("CritHit!! {0}", value); BodyWeight = FontWeights.Bold; BodySize = 30; BodyStyle = FontStyles.Italic; BodyColor = Global.RainbowBrush(235, 0, 0, 254, 200, 200); break; case ValueEffects.Failure: Content = "回 避"; BodyWeight = FontWeights.Bold; BodySize = 24; BodyStyle = FontStyles.Italic; BodyColor = Global.RainbowBrush(29, 75, 159, 158, 191, 251); break; } }
/// <summary> /// 改变生命值 /// </summary> public void ChangeLife(int changedValue, ValueEffects effect) { double result = Life + changedValue; if (result < 0) { Life = 0; } else if (result > LifeMax) { Life = LifeMax; } else { Life = result; } if (LifeChanged != null) { LifeChanged(this, new ValueEffectEventArgs() { ChangedValue = changedValue, Effect = effect }); } }
/// <summary> /// 改变最大生命值 /// </summary> public void ChangeLifeMax(int changedValue, ValueEffects effect) { double result = LifeMax + changedValue; LifeMax = result < 0 ? 0 : result; if (LifeMaxChanged != null) { LifeMaxChanged(this, new ValueEffectEventArgs() { ChangedValue = changedValue, Effect = effect }); } }
/// <summary> /// 设置战斗效果文字 /// </summary> /// <param name="effect"></param> /// <param name="effectValue"></param> public void SetAttackText(ValueEffects effect, int effectValue) { string value = effectValue.ToString(); int length = value.Length; string[] temp = new string[length]; for (int i = 0; i < length; i++) { temp[i] = value.Substring(i, 1); } EntityObject symbol = new EntityObject() { Source = GlobalMethod.GetImage(string.Format("Number/{0}.png", effect.ToString()), UriType.Project) }; this.Children.Add(symbol); ContentWidth += symbol.RealWidth; ContentHeight = symbol.RealHeight; switch (effect) { case ValueEffects.Increase: case ValueEffects.Decrease: case ValueEffects.DoubleDecrease: case ValueEffects.PoisonDecrease: for (int i = effectValue < 0 ? 1 : 0; i < length; i++) { EntityObject text = new EntityObject() { Source = GlobalMethod.GetImage(string.Format("Number/{0}{1}.png", effect.ToString(), temp[i]), UriType.Project) }; this.Children.Add(text); Canvas.SetLeft(text, ContentWidth); ContentWidth += text.RealWidth; } break; } }