コード例 #1
0
ファイル: MiscHelper.cs プロジェクト: dghkd/FlowerMaster
        /// <summary>
        /// 添加游戏日志
        /// </summary>
        /// <param name="log">日志内容</param>
        /// <param name="type">日志类型</param>
        public static void AddLog(string log, LogType type = LogType.Default)
        {
            System.Windows.Media.Color typeColor = Colors.White;
            switch (type)
            {
            case LogType.System:
                typeColor = Colors.Bisque;

                break;

            case LogType.Search:
                typeColor = Colors.Violet;
                break;

            case LogType.Stage:
                typeColor = Colors.LightGreen;
                break;

            case LogType.Boss:
                typeColor = Colors.LightCoral;
                break;

            case LogType.Gacha:
            case LogType.Levelup:
                typeColor = Colors.Yellow;
                break;

            case LogType.Sell:
                typeColor = Colors.DarkOrange;
                break;

            case LogType.Mailbox:
                typeColor = Colors.DeepSkyBlue;
                break;

            case LogType.Default:
            default:
                typeColor = Colors.White;
                break;
            }
            if (!main.Dispatcher.CheckAccess())
            {
                main.Dispatcher.Invoke(new Action(() =>
                {
                    Paragraph p  = new Paragraph();
                    Run timeText = new Run()
                    {
                        Text = DateTime.Now.ToString("HH:mm:ss") + " ", Foreground = new SolidColorBrush(Colors.Gray)
                    };
                    Run logText = new Run()
                    {
                        Text = log, Foreground = new SolidColorBrush(typeColor)
                    };
                    p.Inlines.Add(timeText);
                    p.Inlines.Add(logText);
                    p.LineHeight = 3;
                    main.gameLog.Document.Blocks.Add(p);
                    main.gameLog.ScrollToEnd();
                    if (type != LogType.System && type != LogType.Debug)
                    {
                        main.stLog.Text = log;
                    }
                }));
            }
            else
            {
                Paragraph p        = new Paragraph();
                Run       timeText = new Run()
                {
                    Text = DateTime.Now.ToString("HH:mm:ss") + " ", Foreground = new SolidColorBrush(Colors.Gray)
                };
                Run logText = new Run()
                {
                    Text = log, Foreground = new SolidColorBrush(typeColor)
                };
                p.Inlines.Add(timeText);
                p.Inlines.Add(logText);
                p.LineHeight = 3;
                main.gameLog.Document.Blocks.Add(p);
                main.gameLog.ScrollToEnd();
                if (type != LogType.System && type != LogType.Debug)
                {
                    main.stLog.Text = log;
                }
            }
            if (type != LogType.System && type != LogType.Debug)
            {
                LogsHelper.LogGame(log);
            }
        }
コード例 #2
0
ファイル: MiscHelper.cs プロジェクト: dghkd/FlowerMaster
 /// <summary>
 /// 添加扭蛋日志
 /// </summary>
 /// <param name="cards">角色信息</param>
 public static void AddGachaLog(JArray cards)
 {
     if (!main.gameLog.Dispatcher.CheckAccess())
     {
         main.gameLog.Dispatcher.Invoke(new Action(() =>
         {
             string logs  = "进行了一次扭蛋,获得:";
             Paragraph p  = new Paragraph();
             Run timeText = new Run()
             {
                 Text = DateTime.Now.ToString("HH:mm:ss") + " ", Foreground = new SolidColorBrush(Colors.Gray)
             };
             Run log = new Run()
             {
                 Text = "进行了一次扭蛋,获得:", Foreground = new SolidColorBrush(Colors.Yellow)
             };
             p.Inlines.Add(timeText);
             p.Inlines.Add(log);
             p.LineHeight = 3;
             int cnt      = 0;
             foreach (JObject card in cards)
             {
                 string cardStr = DataUtil.Cards.GetName(int.Parse(card["characterId"].ToString()));
                 System.Windows.Media.Color color = Colors.White;
                 if (cards.Count == 10 && cardStr == "★3茉莉")
                 {
                     color = Colors.Red;
                 }
                 else if (cardStr.IndexOf("★1") != -1)
                 {
                     color = Colors.LightSteelBlue;
                 }
                 else if (cardStr.IndexOf("★2") != -1)
                 {
                     color = Colors.Aquamarine;
                 }
                 else if (cardStr.IndexOf("★3") != -1)
                 {
                     color = Colors.Chocolate;
                 }
                 else if (cardStr.IndexOf("★4") != -1)
                 {
                     color = Colors.Silver;
                 }
                 else if (cardStr.IndexOf("★5") != -1)
                 {
                     color = Colors.Gold;
                 }
                 else if (cardStr.IndexOf("★6") != -1)
                 {
                     color = Colors.Violet;
                 }
                 if (cnt > 0)
                 {
                     Run cardTextEnd = new Run()
                     {
                         Text = "、", Foreground = new SolidColorBrush(Colors.Yellow)
                     };
                     p.Inlines.Add(cardTextEnd);
                 }
                 Run cardText = new Run()
                 {
                     Text = card["bookStatus"].ToString() == "2" ? cardStr + "(新)" : cardStr, Foreground = new SolidColorBrush(color)
                 };
                 p.Inlines.Add(cardText);
                 logs += card["bookStatus"].ToString() == "2" ? cardStr + "(新)、" : cardStr + "、";
                 cnt++;
             }
             main.gameLog.Document.Blocks.Add(p);
             main.gameLog.ScrollToEnd();
             LogsHelper.LogGame(logs.Substring(0, logs.Length - 1));
         }));
     }
     else
     {
         string    logs     = "进行了一次扭蛋,获得:";
         Paragraph p        = new Paragraph();
         Run       timeText = new Run()
         {
             Text = DateTime.Now.ToString("HH:mm:ss") + " ", Foreground = new SolidColorBrush(Colors.Gray)
         };
         Run log = new Run()
         {
             Text = "进行了一次扭蛋,获得:", Foreground = new SolidColorBrush(Colors.Yellow)
         };
         p.Inlines.Add(timeText);
         p.Inlines.Add(log);
         p.LineHeight = 3;
         int cnt = 0;
         foreach (JObject card in cards)
         {
             string cardStr = DataUtil.Cards.GetName(int.Parse(card["characterId"].ToString()));
             System.Windows.Media.Color color = Colors.White;
             if (cards.Count == 10 && cardStr == "★3茉莉")
             {
                 color = Colors.Red;
             }
             else if (cardStr.IndexOf("★1") != -1)
             {
                 color = Colors.LightSteelBlue;
             }
             else if (cardStr.IndexOf("★2") != -1)
             {
                 color = Colors.Aquamarine;
             }
             else if (cardStr.IndexOf("★3") != -1)
             {
                 color = Colors.Chocolate;
             }
             else if (cardStr.IndexOf("★4") != -1)
             {
                 color = Colors.Silver;
             }
             else if (cardStr.IndexOf("★5") != -1)
             {
                 color = Colors.Gold;
             }
             else if (cardStr.IndexOf("★6") != -1)
             {
                 color = Colors.Violet;
             }
             if (cnt > 0)
             {
                 Run cardTextEnd = new Run()
                 {
                     Text = ",", Foreground = new SolidColorBrush(Colors.Yellow)
                 };
                 p.Inlines.Add(cardTextEnd);
             }
             Run cardText = new Run()
             {
                 Text = card["bookStatus"].ToString() == "2" ? cardStr + "(新)" : cardStr, Foreground = new SolidColorBrush(color)
             };
             p.Inlines.Add(cardText);
             logs += card["bookStatus"].ToString() == "2" ? cardStr + "(新)、" : cardStr + "、";
             cnt++;
         }
         main.gameLog.Document.Blocks.Add(p);
         main.gameLog.ScrollToEnd();
         LogsHelper.LogGame(logs.Substring(0, logs.Length - 1));
     }
 }