Esempio n. 1
0
        /// <summary>
        /// 显伤脚本
        /// </summary>
        /// <param name="monster">对应的怪物</param>
        public void ShowDamage(int left, int top)
        {
            if (textBlock != null)
            {
                HideDamage();
            }
            Run run = new Run()
            {
                Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 150, 0)),
                FontWeight = FontWeight.FromOpenTypeWeight(999)
            };
            int damage = CalculationUtility.CalculateDamage(this);

            // -1代表不可战斗显示问号
            if (damage == -1)
            {
                run.Text = "???";
            }
            else
            {
                run.Text = damage + "";
            }
            textBlock = new TextBlock(run)
            {
                Height   = 20,
                FontSize = 13
            };
            Canvas.SetLeft(textBlock, left);
            Canvas.SetTop(textBlock, top);
            Panel.SetZIndex(textBlock, 9);
            FloorFactory.canvas.Children.Add(textBlock);
        }
Esempio n. 2
0
        /// <summary>
        /// 向Panel添加显示怪物资料的Canvas
        /// </summary>
        private void AddChildCanvas(MonsterImage monster)
        {
            Canvas parennt = new Canvas();

            #region 添加怪物图片
            Image image = new Image
            {
                Source = new BitmapImage(new Uri(MonsterImage.GetImagePaths((MonsterType)monster.GetFineType())[0], UriKind.Relative)),
                Height = 50,
                Width  = 50,
                Margin = new Thickness(10)
            };
            parennt.Children.Add(image);
            #endregion

            #region 添加怪物名称
            TextBox name = CreateTextBox(monster.GetFineType().ToString(), new SolidColorBrush(Color.FromRgb(255, 255, 255)), 80, 10);
            parennt.Children.Add(name);
            #endregion

            #region 添加怪物特殊能力
            TextBox ability = CreateTextBox(monster.Ability.ToString(), new SolidColorBrush(Color.FromRgb(255, 255, 255)), 80, 35);
            parennt.Children.Add(ability);
            #endregion

            #region 添加怪物血量
            TextBox hp = CreateTextBox("血量:" + monster.Hp, new SolidColorBrush(Color.FromRgb(209, 133, 42)), 200, 10);
            parennt.Children.Add(hp);
            #endregion

            #region 添加怪物攻击
            TextBox atk = CreateTextBox("攻击:" + monster.Atk, new SolidColorBrush(Color.FromRgb(209, 133, 42)), 310, 10);
            parennt.Children.Add(atk);
            #endregion

            #region 添加怪物防御
            TextBox def = CreateTextBox("防御:" + monster.Def, new SolidColorBrush(Color.FromRgb(209, 133, 42)), 420, 10);
            parennt.Children.Add(def);
            #endregion

            #region 添加获得的金币
            TextBox gold = CreateTextBox("金币:" + monster.Gold, new SolidColorBrush(Color.FromRgb(185, 185, 40)), 200, 35);
            parennt.Children.Add(gold);
            #endregion

            #region 添加获得的经验
            TextBox exp = CreateTextBox("经验:" + monster.Exp, new SolidColorBrush(Color.FromRgb(185, 185, 40)), 310, 35);
            parennt.Children.Add(exp);
            #endregion

            #region 添加打怪的损失
            string damage = CalculationUtility.CalculateDamage(monster) + "";
            if ("-1".Equals(damage))
            {
                damage = "???";
            }
            TextBox damageText = CreateTextBox("伤害:" + damage, new SolidColorBrush(Color.FromRgb(180, 45, 45)), 420, 35);
            parennt.Children.Add(damageText);
            #endregion

            #region 添加分割线
            Canvas canvas = new Canvas
            {
                Height     = 3,
                Width      = 550,
                Background = new SolidColorBrush(Color.FromRgb(200, 200, 200))
            };
            parennt.Children.Add(canvas);
            #endregion
            ContentItem.Children.Add(parennt);
        }