示例#1
0
        public void NotifySkillUse(ActionLog log)
        {
            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
            {
                Trace.Assert(log.Source != null);
                PlayerViewBase player = playersMap[log.Source];
                if (log.SkillAction != null)
                {
                    string key1 = string.Format("{0}.Animation", log.SkillAction.GetType().Name);
                    string key2 = key1 + ".Offset";
                    bool animPlayed = false;
                    lock (equipAnimationResources)
                    {
                        if (equipAnimationResources.Contains(key1))
                        {
                            AnimationBase animation = equipAnimationResources[key1] as AnimationBase;
                            if (animation != null && animation.Parent == null)
                            {
                                Point offset = new Point(0, 0);
                                if (equipAnimationResources.Contains(key2))
                                {
                                    offset = (Point)equipAnimationResources[key2];
                                }
                                player.PlayAnimation(animation, 0, offset);
                                animPlayed = true;
                            }
                        }
                    }
                    if (log.SkillAction.IsSingleUse || log.SkillAction.IsAwakening)
                    {
                        ExcitingSkillAnimation anim = new ExcitingSkillAnimation();
                        anim.SkillName = log.SkillAction.GetType().Name;
                        anim.HeroName = log.Source.Hero.Name;
                        gridRoot.Children.Add(anim);
                        anim.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        anim.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                        anim.Start();
                        animPlayed = true;
                    }
                    if (!animPlayed && player != mainPlayerPanel)
                    {
                        string s = LogFormatter.Translate(log.SkillAction);
                        if (s != string.Empty)
                        {

                            ZoomTextAnimation anim = new ZoomTextAnimation() { Text = s };
                            player.PlayAnimation(anim, 1, new Point(0, 0));
                            animPlayed = true;
                        }
                    }
                    string soundKey = log.SkillAction.GetType().Name;
                    Uri uri = GameSoundLocator.GetSkillSound(soundKey, log.SpecialEffectHint);
                    GameSoundPlayer.PlaySoundEffect(uri);
                }
                if (log.CardAction != null)
                {
                    if (log.CardAction.Type is Shan)
                    {
                        player.PlayAnimation(new ShanAnimation(), 0, new Point(0, 0));
                    }
                    else if (log.CardAction.Type is RegularSha)
                    {
                        AnimationBase sha;
                        if (log.CardAction.SuitColor == SuitColorType.Red)
                        {
                            sha = new ShaAnimation();
                        }
                        else
                        {
                            sha = new ShaAnimation2();
                        }
                        player.PlayAnimation(sha, 0, new Point(0, 0));
                    }
                    else if (log.CardAction.Type is TieSuoLianHuan)
                    {
                        foreach (var p in log.Targets)
                        {
                            playersMap[p].PlayIronShackleAnimation();
                        }
                    }

                    bool? isMale = null;
                    if (log.Source != null) isMale = !log.Source.IsFemale;
                    Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.CardType, isMale);
                    var card = log.CardAction as Card;
                    if (card != null)
                    {
                        bool play = true;
                        if (card.Log != null && card.Log.SkillAction is IEquipmentSkill)
                        {
                            Uri uri = GameSoundLocator.GetSkillSound(card.Log.SkillAction.GetType().Name);
                            if (uri != null) play = false;
                        }
                        if (play) GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                    }
                }

                if (log.Targets.Count > 0)
                {
                    _LineUp(log.Source, log.Targets);
                    foreach (var target in log.Targets)
                    {
                        target.IsTargeted = true;
                    }
                }

                gameLogs.AppendLog(log);
                rtbLog.ScrollToEnd();

                _AppendKeyEventLog(log);
            });
        }
示例#2
0
        public void NotifySkillUse(ActionLog log)
        {
            if (ViewModelBase.IsDetached) return;
            Trace.Assert(log.Source != null);
            PlayerViewBase player = playersMap[log.Source];
            bool soundPlayed = false;
            if (log.SkillAction != null)
            {
                string key1 = string.Format("{0}.Animation", log.SkillAction.GetType().Name);
                string key2 = key1 + ".Offset";
                bool animPlayed = false;
                lock (equipAnimationResources)
                {
                    if (equipAnimationResources.Contains(key1))
                    {
                        AnimationBase animation = null;
                        Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                        {
                            animation = equipAnimationResources[key1] as AnimationBase;
                        });
                        if (animation != null && animation.Parent == null)
                        {
                            Point offset = new Point(0, 0);
                            if (equipAnimationResources.Contains(key2))
                            {
                                offset = (Point)equipAnimationResources[key2];
                            }
                            player.PlayAnimationAsync(animation, 0, offset);
                            animPlayed = true;
                        }
                    }
                }
                if (log.SkillAction.IsSingleUse || log.SkillAction.IsAwakening)
                {
                    Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate()
                    {
                        ExcitingSkillAnimation anim = new ExcitingSkillAnimation();
                        anim.SkillName = log.SkillAction.GetType().Name;
                        anim.HeroName = log.SkillAction.HeroTag.Name;
                        gridRoot.Children.Add(anim);
                        anim.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        anim.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                        anim.Start();
                    });
                    animPlayed = true;
                }
                if (!animPlayed && player != mainPlayerPanel)
                {
                    string s = LogFormatter.Translate(log.SkillAction);
                    if (s != string.Empty)
                    {
                        RegularSkillAnimation anim = null;
                        Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                        {
                            anim = new RegularSkillAnimation() { Text = s };
                        });
                        Trace.Assert(anim != null);
                        player.PlayAnimationAsync(anim, 1, new Point(0, 0));
                        animPlayed = true;
                    }
                }
                string soundKey = log.SkillAction.GetType().Name;
                Uri uri = GameSoundLocator.GetSkillSound(soundKey, log.SpecialEffectHint);
                GameSoundPlayer.PlaySoundEffect(uri);
                soundPlayed = uri != null;
            }
            else if (log.GameAction == GameAction.None)
            {
                bool? isMale = null;
                if (log.Source != null) isMale = !log.Source.IsFemale;
                Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.Name, isMale);
                GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                soundPlayed = cardSoundUri != null;
            }
            if (log.CardAction != null && log.GameAction != GameAction.None)
            {
                if (log.CardAction.Type is TieSuoLianHuan)
                {
                    foreach (var p in log.Targets)
                    {
                        Application.Current.Dispatcher.BeginInvoke((ThreadStart)delegate()
                        {
                            playersMap[p].PlayIronShackleAnimation();
                        });
                    }
                }
                else
                {
                    ICard c = log.CardAction;
                    string key1;
                    key1 = string.Format("{0}.{1}.Animation", c.Type.GetType().Name, c.SuitColor == SuitColorType.Red ? "Red" : "Black");
                    if (!baseCardAnimationResources.Contains(key1))
                    {
                        key1 = string.Format("{0}.Animation", c.Type.GetType().Name);
                    }
                    string key2 = key1 + ".Offset";
                    lock (baseCardAnimationResources)
                    {
                        if (baseCardAnimationResources.Contains(key1))
                        {
                            AnimationBase animation = null;
                            Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                            {
                                animation = baseCardAnimationResources[key1] as AnimationBase;
                            });
                            if (animation != null && animation.Parent == null)
                            {
                                Point offset = new Point(0, 0);
                                if (baseCardAnimationResources.Contains(key2))
                                {
                                    offset = (Point)baseCardAnimationResources[key2];
                                }
                                player.PlayAnimationAsync(animation, 0, offset);
                            }
                        }
                    }
                }

                bool? isMale = null;
                if (log.Source != null) isMale = !log.Source.IsFemale;
                Uri cardSoundUri = GameSoundLocator.GetCardSound(log.CardAction.Type.Name, isMale);
                var card = log.CardAction as Card;
                if (card != null)
                {
                    bool play = true;
                    if (card.Log != null && card.Log.SkillAction is IEquipmentSkill)
                    {
                        Uri uri = GameSoundLocator.GetSkillSound(card.Log.SkillAction.GetType().Name);
                        if (uri != null) play = false;
                    }
                    if (play && !soundPlayed) GameSoundPlayer.PlaySoundEffect(cardSoundUri);
                }
            }

            if (log.GameAction != GameAction.None || log.SkillAction != null && log.CardAction == null || log.ShowCueLine)
            {
                if (log.Targets.Count > 0)
                {
                    _LineUp(log.Source, log.Targets);
                    foreach (var target in log.Targets)
                    {
                        target.IsTargeted = true;
                    }
                }

                if (log.Targets.Count == 1 && log.SecondaryTargets != null && log.SecondaryTargets.Count > 0)
                {
                    _LineUp(log.Targets[0], log.SecondaryTargets);
                    foreach (var target in log.SecondaryTargets)
                    {
                        target.IsTargeted = true;
                    }
                }
            }

            if (!log.SkillSoundOnly)
            {
                Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                {
                    gameLogs.AppendLog(log);
                    rtbLog.ScrollToEnd();
                });

                Application.Current.Dispatcher.Invoke((ThreadStart)delegate()
                {
                    _AppendKeyEventLog(log);
                });
            }
        }