Esempio n. 1
0
        private void RefreshHeroPanel()
        {
            HeroStackPanel.Children.Clear();
            int count = GameEngine.Instance.Runtime.SelectHeroCount;

            this.SelectHeroCountText.Text = count.ToString();
            if (count < 3)
            {
                this.SelectHeroCountText.Text += "(需要3个)";
            }


            //heros
            int        k = 0;
            StackPanel currentStackPanel = null;

            foreach (var h in GameEngine.Instance.Runtime.Heros)
            {
                if (k % CommonSettings.HOST_CARD_IN_ONE_LINE == 0)
                {
                    k = 0;
                    currentStackPanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    HeroStackPanel.Children.Add(currentStackPanel);
                }
                RuntimeHero hero     = h;
                CardView    heroCard = CardView.CreateFromHero(h.Hero);
                heroCard.Opacity              = h.IsSelected ? 1 : 0.3;
                heroCard.MouseLeftButtonDown += (s, e) =>
                {
                    if (hero.IsSelected)
                    {
                        hero.IsSelected = false;
                        this.Dispatcher.BeginInvoke(() =>
                        {
                            RefreshHeroPanel();
                            ShowHeroInfo(h.Hero);
                        });
                    }
                    else
                    {
                        if (GameEngine.Instance.Runtime.SelectHeroCount < 3)
                        {
                            hero.IsSelected = true;
                            this.Dispatcher.BeginInvoke(() =>
                            {
                                RefreshHeroPanel();
                                ShowHeroInfo(h.Hero);
                            });
                        }
                        else
                        {
                            MessageBox.Show("最多选择3名上场英雄");
                        }
                    }
                };
                heroCard.MouseMove += (s, e) => { ShowHeroInfo(h.Hero); };
                currentStackPanel.Children.Add(heroCard);
            }
        }