public override void UpdateImpersonateStatus(bool isPrimaryHero) { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); var hero = isPrimaryHero ? PlayerModel.Hero1Model : PlayerModel.Hero2Model; Trace.Assert(hero != null); Storyboard sb = (Resources[isPrimaryHero ? "sbStartImpersonate" : "sbStartImpersonate2"] as Storyboard); if (!string.IsNullOrEmpty(hero.ImpersonatedHeroName)) { converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; converter.CropRect = new Int32Rect(71, 28, 145, 145); ImageSource source = converter.Convert(new object[] { this, hero.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; if (isPrimaryHero) { impersonateEffect.Texture2 = new ImageBrush(source); } else { impersonateEffect1.Texture2 = new ImageBrush(source); } sb.Begin(); } else { sb.Stop(); } }
public override void UpdateImpersonateStatus(bool isPrimaryHero) { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); var hero = isPrimaryHero ? PlayerModel.Hero1Model : PlayerModel.Hero2Model; Trace.Assert(hero != null); Storyboard sb; if (PlayerModel.Hero2 == null) { sb = (Resources["sbStartImpersonate"] as Storyboard); } else if (isPrimaryHero) { sb = (Resources["sbStartImpersonate1"] as Storyboard); } else { sb = (Resources["sbStartImpersonate2"] as Storyboard); } if (!string.IsNullOrEmpty(hero.ImpersonatedHeroName)) { converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; Effects.RippleTransitionEffect effect; if (PlayerModel.Hero2 == null) { converter.CropRect = new Int32Rect(28, 46, 220, 132); effect = impersonateEffect; } else if (isPrimaryHero) { converter.CropRect = new Int32Rect(60, 30, 208, 125); effect = impersonateEffect1; } else { converter.CropRect = new Int32Rect(63, 20, 126, 178); effect = impersonateEffect2; } ImageSource source = converter.Convert(new object[] { this, hero.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; effect.Texture2 = new ImageBrush(source); sb.Begin(); } else { sb.Stop(); } }
public override void UpdateImpersonateStatus(bool isPrimaryHero) { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); var hero = isPrimaryHero ? PlayerModel.Hero1Model : PlayerModel.Hero2Model; Trace.Assert(hero != null); Storyboard sb; if (PlayerModel.Hero2 == null) { sb = (Resources["sbStartImpersonate"] as Storyboard); } else if (isPrimaryHero) { sb = (Resources["sbStartImpersonate1"] as Storyboard); } else { sb = (Resources["sbStartImpersonate2"] as Storyboard); } if (!string.IsNullOrEmpty(hero.ImpersonatedHeroName)) { converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; Effects.RippleTransitionEffect effect; if (PlayerModel.Hero2 == null) { converter.CropRect = new Int32Rect(28, 46, 220, 132); effect = impersonateEffect; } else if (isPrimaryHero) { converter.CropRect = new Int32Rect(60, 30, 208, 125); effect = impersonateEffect1; } else { converter.CropRect = new Int32Rect(63, 20, 126, 178); effect = impersonateEffect2; } ImageSource source = converter.Convert(new object[] { this, hero.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; effect.Texture2 = new ImageBrush(source); sb.Begin(); } else { sb.Stop(); } }
public override void UpdateImpersonateStatus(bool isPrimaryHero) { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); var hero = isPrimaryHero ? PlayerModel.Hero1Model : PlayerModel.Hero2Model; Trace.Assert(hero != null); Storyboard sb = (Resources[isPrimaryHero ? "sbStartImpersonate" : "sbStartImpersonate2"] as Storyboard); if (!string.IsNullOrEmpty(hero.ImpersonatedHeroName)) { converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; converter.CropRect = new Int32Rect(71, 28, 145, 145); ImageSource source = converter.Convert(new object[] { this, hero.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; if (isPrimaryHero) impersonateEffect.Texture2 = new ImageBrush(source); else impersonateEffect1.Texture2 = new ImageBrush(source); sb.Begin(); } else { sb.Stop(); } }
void model_PropertyChanged(object sender, PropertyChangedEventArgs e) { PlayerViewModel model = sender as PlayerViewModel; if (e.PropertyName == "CurrentPhase") { if (model.CurrentPhase == Core.Games.TurnPhase.Inactive) { imgPhase.Visibility = System.Windows.Visibility.Hidden; } else { imgPhase.Visibility = System.Windows.Visibility.Visible; Storyboard animation = Resources["sbPhaseChange"] as Storyboard; animation.Begin(this); } } else if (e.PropertyName == "TimeOutSeconds") { Duration duration = new Duration(TimeSpan.FromSeconds(model.TimeOutSeconds)); DoubleAnimation doubleanimation = new DoubleAnimation(100d, 0d, duration); progressBar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation); } else if (e.PropertyName == "IsDead") { Storyboard deathAnimation = (Resources["sbDeathTransition"] as Storyboard); Trace.Assert(deathAnimation != null); if (model.IsDead) { deathAnimation.Begin(); } else { deathAnimation.Stop(); } } else if (e.PropertyName == "IsIronShackled") { if (model.IsIronShackled) { tieSuoAnimation2.Start(); } Uri uri = GameSoundLocator.GetSystemSound("IronShackled"); GameSoundPlayer.PlaySoundEffect(uri); } else if (e.PropertyName == "ImpersonatedHeroName") { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; converter.CropRect = new Int32Rect(28,46,220,132); ImageSource source = converter.Convert(new object[]{ this, model.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; impersonateEffect.Texture2 = new ImageBrush(source); Storyboard sb = (Resources["sbStartImpersonate"] as Storyboard); if (!string.IsNullOrEmpty(model.ImpersonatedHeroName)) { sb.Begin(); } else { sb.Stop(); } } }
void model_PropertyChanged(object sender, PropertyChangedEventArgs e) { PlayerViewModel model = sender as PlayerViewModel; if (e.PropertyName == "CurrentPhase") { if (model.CurrentPhase == Core.Games.TurnPhase.Inactive) { imgPhase.Visibility = System.Windows.Visibility.Hidden; } else { imgPhase.Visibility = System.Windows.Visibility.Visible; Storyboard animation = Resources["sbPhaseChange"] as Storyboard; animation.Begin(this); } } else if (e.PropertyName == "IsDead") { Storyboard deathAnimation = (Resources["sbDeathTransition"] as Storyboard); Trace.Assert(deathAnimation != null); if (model.IsDead) { deathAnimation.Begin(); } else { deathAnimation.Stop(); } } else if (e.PropertyName == "IsIronShackled") { if (model.IsIronShackled) { tieSuoAnimation2.Start(); } } else if (e.PropertyName == "ImpersonatedHeroName") { Sanguosha.UI.Resources.FileNameToImageSourceConverter converter = new UI.Resources.FileNameToImageSourceConverter(); converter.StringFormat = "Resources/Images/Heroes/Full/{0}.png"; converter.ResourceKeyFormat = "Hero.{0}.Image"; converter.CropRect = new Int32Rect(71,28,145,145); ImageSource source = converter.Convert(new object[]{ this, model.ImpersonatedHeroName }, typeof(ImageSource), null, null) as ImageSource; impersonateEffect.Texture2 = new ImageBrush(source); Storyboard sb = (Resources["sbStartImpersonate"] as Storyboard); if (!string.IsNullOrEmpty(model.ImpersonatedHeroName)) { sb.Begin(); } else { sb.Stop(); } } }