Ejemplo n.º 1
0
        /// <summary>
        /// 截图游戏并保存
        /// </summary>
        public static void ScreenShot()
        {
            if (!Directory.Exists("screenshot"))
            {
                Directory.CreateDirectory("screenshot");
            }

            string path = @"screenshot\" + LogsHelper.GetServerName() + "_" + LogsHelper.GetFilePlayerName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + "." + DataUtil.Config.sysConfig.capFormat.ToString().ToLower();

            System.Windows.Point p = new System.Windows.Point();
            var screenPoint        = main.WinFormHost.PointToScreen(p);
            int x      = (int)screenPoint.X;
            int y      = (int)screenPoint.Y;
            int width  = Convert.ToInt32(main.WinFormHost.Width);
            int height = Convert.ToInt32(main.WinFormHost.Height);

            var image = ScreenHelper.CaptureScreen(x, y, width, height);

            var format = Path.GetExtension(path) == ".jpg"
                ? ImageFormat.Jpeg
                : ImageFormat.Png;

            image.Save(path, format);
            AddLog("截圖已經保存到文件" + path);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理扭蛋角色列表信息
        /// </summary>
        /// <param name="pack">封包数据结构体</param>
        /// <returns>处理结果标志</returns>
        private static int ProcessGachaLineup(PacketInfo pack)
        {
            JArray cards = (JArray)pack.data["masterGachaItemList"];

            if (cards.Count > 0)
            {
                foreach (JObject card in cards)
                {
                    LogsHelper.LogDebug(card["itemId"].ToString() + "=" + card["name"].ToString());
                }
            }
            return(E_SUCCESS);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 处理扭蛋结果信息封包
        /// </summary>
        /// <param name="pack">封包数据结构体</param>
        /// <returns>处理结果标志</returns>
        private static int ProcessGachaResult(PacketInfo pack)
        {
            JArray cards = (JArray)pack.data["userCharacterList"];

            if (cards.Count > 0)
            {
                List <string> list = new List <string>();
                foreach (JObject card in cards)
                {
                    list.Add(card["characterId"].ToString());
                }
                MiscHelper.AddGachaLog(cards);
                LogsHelper.LogGacha(list);
            }
            return(E_SUCCESS);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 解析封包结构体
        /// </summary>
        /// <param name="pack">封包结构体</param>
        /// <returns>解析结果</returns>
        private static int Process(PacketInfo pack)
        {
            try
            {
                //处理日服DMM用户信息-获取用户昵称
                if ((DataUtil.Game.gameServer == (int)GameInfo.ServersList.Japan || DataUtil.Game.gameServer == (int)GameInfo.ServersList.JapanR18 ||
                     DataUtil.Game.gameServer == (int)GameInfo.ServersList.TradChinese || DataUtil.Game.gameServer == (int)GameInfo.ServersList.TradChineseR18) && pack.funcUrl.IndexOf("/social/") != -1)
                {
                    if (pack.funcApi == "/rpc")
                    {
                        return(ProcessDMMUserInfo(pack));
                    }
                    else
                    {
                        return(E_FAILED);
                    }
                }
                //处理美服用户信息-获取用户昵称
                else if ((DataUtil.Game.gameServer == (int)GameInfo.ServersList.American || DataUtil.Game.gameServer == (int)GameInfo.ServersList.AmericanR18) && pack.funcUrl.IndexOf("/rpc") != -1)
                {
                    return(ProcessNutakuUserInfo(pack));
                }
                //判断是否为游戏接口封包
                else if (pack.funcUrl.IndexOf("/api/v1/") != -1)
                {
#if DEBUG
                    LogsHelper.LogDebug("【请求】" + pack.funcApi + "\r\n【响应】" + pack.rawData + "\r\n================================================================");
                    LogsHelper.LogDebug("【时间】" + DateTime.UtcNow);
#endif
                    //更新服务器时间
                    if (pack.data["serverTime"] != null)
                    {
                        DataUtil.Game.serverTime = Convert.ToDateTime(pack.data["serverTime"].ToString());
                    }
                    //确认游戏是否在线
                    if (pack.data["resultCode"] != null)
                    {
                        int status = Convert.ToInt16(pack.data["resultCode"].ToString());
                        if (status == 1)
                        {
                            DataUtil.Game.isOnline = false;
                        }
                    }
                    //----- 游戏数据处理开始 -----
                    //游戏登录
                    if (pack.funcApi == "/user/login")
                    {
                        return(ProcessPlayerLoginInfo(pack));
                    }
                    //好友列表
                    else if (pack.funcApi == "/friend/getFriendList")
                    {
                        return(ProcessFriendList(pack));
                    }
                    //花盆开花时间信息
                    else if (pack.funcApi == "/garden/getUserGardenPlant")
                    {
                        return(ProcessUserGardenPlant(pack));
                    }
                    //收获花盆
                    else if (pack.funcApi == "/garden/saveGardenPlantHarvest")
                    {
                        return(ProcessGardenPlantHarvest(pack));
                    }
                    //游戏探索
                    else if (pack.funcApi == "/searchQuest/saveSearchQuest")
                    {
                        return(ProcessPlayerSearchInfo(pack));
                    }
                    //主页BOSS战开始
                    else if (pack.funcApi == "/raidBoss/saveRaidBossStart")
                    {
                        return(ProcessRaidBossStart(pack));
                    }
                    //主页BOSS战完成
                    else if (pack.funcApi == "/raidBoss/saveRaidBossFinish")
                    {
                        return(ProcessRaidBossFinish(pack));
                    }
                    //个人BOSS战开始
                    else if (pack.funcApi == "/eventBoss/saveSummonBossStart")
                    {
                        return(ProcessSummonBossStart(pack));
                    }
                    //个人BOSS战完成
                    else if (pack.funcApi == "/eventBoss/saveSummonBossFinish")
                    {
                        return(ProcessSummonBossFinish(pack));
                    }
                    //进副本信息
                    else if (pack.funcApi == "/dungeon/saveStageStart" || pack.funcApi == "/dungeon/saveEventStageStart" || pack.funcApi == "/dungeon/saveEncounterStageStart" || pack.funcApi == "/dungeon/saveWhaleStageStart")
                    {
                        return(ProcessDungeonStageStart(pack));
                    }
                    //副本完成信息
                    else if (pack.funcApi == "/dungeon/saveStageSuccess" || pack.funcApi == "/dungeon/saveEventStageSuccess" || pack.funcApi == "/dungeon/saveEncounterStageSuccess" || pack.funcApi == "/dungeon/saveWhaleStageSuccess")
                    {
                        return(ProcessDungeonStageSuccess(pack));
                    }
                    //副本放弃信息
                    else if (pack.funcApi == "/dungeon/saveStageFailed" || pack.funcApi == "/dungeon/saveEventStageFailed" || pack.funcApi == "/dungeon/saveEncounterStageFailed" || pack.funcApi == "/dungeon/saveWhaleStageFailed")
                    {
                        return(ProcessDungeonStageFailed(pack));
                    }
                    //副本失败信息
                    else if (pack.funcApi == "/dungeon/saveStageDestroyed" || pack.funcApi == "/dungeon/saveEventStageDestroyed" || pack.funcApi == "/dungeon/saveEncounterStageDestroyed" || pack.funcApi == "/dungeon/saveWhaleStageDestroyed")
                    {
                        return(ProcessDungeonStageDestroyed(pack));
                    }
                    //获取主页BOSS列表(副本失败检查)
                    else if (pack.funcApi == "/raidBoss/getRaidBossList")
                    {
                        return(ProcessRaidBossList(pack));
                    }
                    //接受礼物盒子里的单件物品
                    else if (pack.funcApi == "/present/savePresentReceived")
                    {
                        return(ProcessPresentReceived(pack));
                    }
                    //接收礼物盒子里的全部物品
                    else if (pack.funcApi == "/present/savePresentAllReceived")
                    {
                        return(ProcessPresentReceivedAll(pack));
                    }
                    //角色合成
                    else if (pack.funcApi == "/character/saveSynthesis")
                    {
                        return(E_SUCCESS);
                    }
                    //角色进化
                    else if (pack.funcApi == "/character/saveEvolve")
                    {
                        return(E_SUCCESS);
                    }
                    //装备强化
                    else if (pack.funcApi == "/character/saveEquipmentSynthesis")
                    {
                        return(E_SUCCESS);
                    }
                    //出售角色和装备
                    else if (pack.funcApi == "/character/saveSale" || pack.funcApi == "/character/saveSaleEquipment")
                    {
                        return(ProcessSellSave(pack));
                    }
                    //扭蛋
                    else if (pack.funcApi == "/gacha/saveGacha")
                    {
                        return(ProcessGachaResult(pack));
                    }
                    //----- DEBUG处理包 -----
#if DEBUG
                    //处理蛋池卡角色名列表
                    else if (pack.funcApi == "/gacha/getPremiumGachaLineup")
                    {
                        return(ProcessGachaLineup(pack));
                    }
#endif
                    //其他不须解析的封包,只返回E_FAILED结果
                    else
                    {
                        return(E_FAILED);
                    }
                }
                //非游戏接口的封包,只返回E_FAILED结果
                else
                {
                    return(E_FAILED);
                }
            }
            //解析失败或者解析过程发生错误,返回E_FALT_ERROR
            catch
            {
                return(E_FALT_ERROR);
            }
        }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
 /// <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));
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 截图游戏并保存
        /// </summary>
        public static void ScreenShot()
        {
            if (!Directory.Exists("screenshot"))
            {
                Directory.CreateDirectory("screenshot");
            }
            string path = @"screenshot\" + LogsHelper.GetServerName() + "_" + LogsHelper.GetFilePlayerName() + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff") + "." + DataUtil.Config.sysConfig.capFormat.ToString().ToLower();

            var document = main.mainWeb.Document as HTMLDocument;

            if (document == null)
            {
                return;
            }

            if (document.url.Contains(".swf?"))
            {
                var viewObject = document.getElementsByTagName("embed").item(0, 0) as IViewObject;
                if (viewObject == null)
                {
                    return;
                }

                var width  = ((HTMLEmbed)viewObject).clientWidth;
                var height = ((HTMLEmbed)viewObject).clientHeight;
                TakeScreenshot(width, height, viewObject, path);
            }
            else
            {
                if (DataUtil.Game.gameServer == (int)GameInfo.ServersList.American || DataUtil.Game.gameServer == (int)GameInfo.ServersList.AmericanR18)
                {
                    var gameFrame = document.getElementById("externalContainer").document as HTMLDocument;
                    if (gameFrame == null)
                    {
                        return;
                    }

                    IViewObject viewObject = null;
                    int         width = 0, height = 0;
                    var         swf = gameFrame.getElementById("externalswf");
                    if (swf == null)
                    {
                        return;
                    }
                    Func <dynamic, bool> function = target =>
                    {
                        if (target == null)
                        {
                            return(false);
                        }
                        viewObject = target as IViewObject;
                        if (viewObject == null)
                        {
                            return(false);
                        }
                        width  = int.Parse(target.width);
                        height = int.Parse(target.height);
                        return(true);
                    };
                    if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement))
                    {
                        return;
                    }

                    TakeScreenshot(width, height, viewObject, path);
                }
                else
                {
                    var gameFrame = document.getElementById("game_frame").document as HTMLDocument;
                    if (gameFrame == null)
                    {
                        return;
                    }

                    var frames = document.frames;
                    for (var i = 0; i < frames.length; i++)
                    {
                        var item     = frames.item(i);
                        var provider = item as IServiceProvider;
                        if (provider == null)
                        {
                            continue;
                        }

                        object ppvObject;
                        provider.QueryService(typeof(IWebBrowserApp).GUID, typeof(IWebBrowser2).GUID, out ppvObject);
                        var webBrowser = ppvObject as IWebBrowser2;

                        var iframeDocument = webBrowser?.Document as HTMLDocument;
                        if (iframeDocument == null)
                        {
                            continue;
                        }

                        IViewObject viewObject = null;
                        int         width = 0, height = 0;
                        var         swf = iframeDocument.getElementById("externalswf");
                        if (swf == null)
                        {
                            continue;
                        }
                        Func <dynamic, bool> function = target =>
                        {
                            if (target == null)
                            {
                                return(false);
                            }
                            viewObject = target as IViewObject;
                            if (viewObject == null)
                            {
                                return(false);
                            }
                            width  = int.Parse(target.width);
                            height = int.Parse(target.height);
                            return(true);
                        };
                        if (!function(swf as HTMLEmbed) && !function(swf as HTMLObjectElement))
                        {
                            continue;
                        }

                        TakeScreenshot(width, height, viewObject, path);

                        break;
                    }
                }
            }
        }