コード例 #1
0
ファイル: MainWindow.cs プロジェクト: tlos142857/MKHXPedia
 private void mapImage_MouseMove(object sender, MouseEventArgs e)
 {
     Image stageframe = Properties.Resources.image829;
     bool flag = false;
     foreach (var s in map.MapStageDetails)
     {
         if (e.X > s.X + 8 && e.Y > s.Y + 8 && e.X < s.X + stageframe.Width - 8 && e.Y < s.Y + stageframe.Height - 8)
         {
             stage = s;
             flag = true;
             mapImage.Cursor = Cursors.Hand;
         }
     }
     if (!flag)
     {
         stage = null;
         mapImage.Cursor = Cursors.Default;
     }
 }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: tlos142857/MKHXPedia
        private void stage_tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var node = e.Node;
            int mapId = int.Parse(node.Text.Split('-')[0]);
            map = GameData.Stage.Find(m => m.MapStageId == mapId);
            switch (node.Level)
            {
                case 0:
                    {
                        StageData prev = GameData.Stage.Find(m => m.MapStageId == map.Prev);
                        StageData next = GameData.Stage.Find(m => m.MapStageId == map.Next);

                        MapStageName.Text = "地图名称:" + map.Name + "";
                        MapStageId.Text = "地图编号:" + map.MapStageId + "";
                        MapStageCount.Text = "关卡数量:" + map.MapStageDetails.Length + "";
                        EverydayReward.Text = "地图收益:" + map.EverydayReward + "";
                        MapTotalStar.Text = "总星数:" + (map.Count * 3) + "";
                        PrevMap.Text = "前一地图:" + (prev == null ? "无" : "" + prev.MapStageId + "-" + prev.Name + "") + "";
                        NextMap.Text = "后一地图:" + (next == null ? "无" : "" + next.MapStageId + "-" + next.Name + "") + "";

                        try
                        {
                            panel_stage.Visible = false;
                            mapImage.Image = new Bitmap(960, 640);

                            Image imgbackground = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\map\" + mapId + ".jpg");
                            Image imgname = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\map\ZH_CN\map\" + mapId + ".png");
                            Image stageframe = Properties.Resources.image829;

                            g = Graphics.FromImage(mapImage.Image);

                            g.DrawImage(imgbackground, 0, 0, imgbackground.Width, imgbackground.Height);
                            g.DrawImage(imgname, 16, 16, imgname.Width, imgname.Height);

                            foreach (var stage in map.MapStageDetails)
                            {
                                g.DrawImage(stageframe, stage.X, stage.Y, stageframe.Width, stageframe.Height);
                                switch (stage.Type)
                                {
                                    case 0:
                                        {
                                            g.DrawImage(Properties.Resources.image841, stage.X + 63, stage.Y + 68, Properties.Resources.image841.Width, Properties.Resources.image841.Height);
                                            break;
                                        }
                                    case 2:
                                        {
                                            g.DrawImage(Properties.Resources.image834, stage.X + 60, stage.Y + 70, Properties.Resources.image834.Width, Properties.Resources.image834.Height);
                                            break;
                                        }
                                    case 3:
                                        {
                                            g.DrawImage(Properties.Resources.image837, stage.X + 68, stage.Y + 67, Properties.Resources.image837.Width, Properties.Resources.image837.Height);
                                            break;
                                        }
                                    case 4:
                                        {
                                            g.DrawImage(Properties.Resources.image820, stage.X + 70, stage.Y + 61, Properties.Resources.image820.Width, Properties.Resources.image820.Height);
                                            break;
                                        }
                                }
                            }
                            foreach (var stage in map.MapStageDetails)
                            {
                                Image stagename = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\map\ZH_CN\stage\" + mapId + "_" + (stage.Rank + 1) + ".png");
                                g.DrawImage(stagename, stage.X + (stageframe.Width - stagename.Width / 2) / 2 + 1, stage.Y + 9, stagename.Width / 2, stagename.Height / 2);
                            }
                            panel_mapImage.Visible = true;
                        }
                        catch
                        {
                            MessageBox.Show("图片载入失败,请耐心等待关卡图片下载完成或重新运行本程序来再次启动下载", "缺少图片");
                        }
                        break;
                    }
                case 1:
                    {
                        panel_mapImage.Visible = false;

                        map = GameData.Stage.Find(m => m.MapStageId == int.Parse(node.Parent.Text.Split('-')[0]));
                        stage = map.MapStageDetails.ToList().Find(m => m.Rank + 1 == int.Parse(node.Text.Split('-')[0]));

                        StageData prev = GameData.Stage.Find(m => m.MapStageId == map.Prev);
                        StageData next = GameData.Stage.Find(m => m.MapStageId == map.Next);

                        MapStageName.Text = "地图名称:" + map.Name + "";
                        MapStageId.Text = "地图编号:" + map.MapStageId + "";
                        MapStageCount.Text = "关卡数量:" + map.MapStageDetails.Length + "";
                        EverydayReward.Text = "地图收益:" + map.EverydayReward + "";
                        MapTotalStar.Text = "总星数:" + (map.Count * 3) + "";
                        PrevMap.Text = "前一地图:" + (prev == null ? "无" : "" + prev.MapStageId + "-" + prev.Name + "") + "";
                        NextMap.Text = "后一地图:" + (next == null ? "无" : "" + next.MapStageId + "-" + next.Name + "") + "";

                        if (stage.Type == 0 || stage.Type == 1 || stage.Type == 2)
                        {
                            try
                            {
                                string location = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\card\110_110\img_photoCard_" + stage.FightImg + ".jpg";
                                if (File.Exists(location))
                                {
                                    MapStageDetail_FightImg.ImageLocation = location;
                                }
                                else
                                {
                                    throw new Exception();
                                }
                            }
                            catch
                            {
                                MapStageDetail_FightImg.ImageLocation = "";
                                MessageBox.Show("图片载入失败,请耐心等待关卡图片下载完成或重新运行本程序来再次启动下载", "缺少图片");
                            }

                            var prevStage = MapStageDetail.List.Find(m => m.MapStageDetailId == stage.Prev);
                            var nextStage = MapStageDetail.List.Find(m => m.MapStageDetailId == stage.Next);

                            MapStageDetail_FightName.Text = "英雄名称:" + stage.FightName + " ";
                            MapStageDetail_Prev.Text = "前置关卡:" + (prevStage == null ? "无" : prevStage.MapStageId + "-" + (prevStage.Rank + 1) + " " + prevStage.Name) + (stage.Type == 0 ? "(困难)" : "");
                            MapStageDetail_Next.Text = "后置关卡:" + (nextStage == null ? "无" : nextStage.MapStageId + "-" + (nextStage.Rank + 1) + " " + nextStage.Name) + "";
                            MazeCount.Text = "";

                            {
                                Level0_Color.Text = "星级:" + stage.Levels[0].Color + "";
                                Level0_EnergyExpend.Text = "过关消耗行动力:" + stage.Levels[0].EnergyExpend + "";
                                Level0_EnergyExplore.Text = "探索消耗行动力:" + stage.Levels[0].EnergyExplore + "";
                                Level0_AchievementText.Text = "过关条件:" + stage.Levels[0].AchievementText + "";
                                Level0_BonusWin.Text = "过关奖励:" + parseBonus(stage.Levels[0].BonusWin + (stage.Levels[0].FirstBonusWin == null || stage.Levels[0].FirstBonusWin == "" ? "" : "," + stage.Levels[0].FirstBonusWin) + "");
                                Level0_BonusLose.Text = "失败奖励:" + parseBonus(stage.Levels[0].BonusLose + "");
                                Level0_BonusExplore.Text = "探索奖励:" + parseBonus(stage.Levels[0].BonusExplore + "");
                                Level0_HeroLevel.Text = "英雄等级:" + stage.Levels[0].HeroLevel + "";
                                Level0_HeroHP.Text = "英雄血量:" + GameData.Hero.Find(m => m.Level == stage.Levels[0].HeroLevel).Hp + "";

                                Level0_CardList.DataSource = null;
                                Level0_RuneList.DataSource = null;

                                var Level0_CardList_table = new DataTable("Level0_CardList");
                                Level0_CardList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("卡牌",typeObject),
                                new DataColumn("等级",typeInt32),
                                new DataColumn("15级技能",typeObject),
                            });
                                string[] Level0_cardlist_stringArray = stage.Levels[0].CardList.Split(',');
                                foreach (var i in Level0_cardlist_stringArray)
                                {
                                    string[] cardStringArray = i.Split('_');
                                    switch (cardStringArray.Length)
                                    {
                                        case 2:
                                            {
                                                Level0_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                        });
                                                break;
                                            }
                                        case 3:
                                            {
                                                Level0_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                          int.Parse(cardStringArray[1])<15?null:  GameData.Skill.Find(m=>m.SkillId==int.Parse(cardStringArray[2])).Name,
                                        });
                                                break;
                                            }
                                    }
                                }

                                var Level0_RuneList_table = new DataTable("Level0_RuneList");
                                Level0_RuneList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("符文",typeObject),
                                new DataColumn("等级",typeInt32),
                            });
                                if (stage.Levels[0].RuneList != "")
                                {
                                    string[] Level0_runelist_stringArray = stage.Levels[0].RuneList.Split(',');
                                    foreach (var i in Level0_runelist_stringArray)
                                    {
                                        string[] runeStringArray = i.Split('_');
                                        Level0_RuneList_table.Rows.Add(new object[] {
                                        GameData.Rune.Find(m=>m.RuneId==int.Parse(runeStringArray[0])).RuneName,
                                        int.Parse(runeStringArray[1]),
                                    });
                                    }
                                }

                                Level0_CardList.DataSource = Level0_CardList_table;
                                Level0_RuneList.DataSource = Level0_RuneList_table;
                            }

                            {
                                Level1_Color.Text = "星级:" + stage.Levels[1].Color + "";
                                Level1_EnergyExpend.Text = "过关消耗行动力:" + stage.Levels[1].EnergyExpend + "";
                                Level1_EnergyExplore.Text = "探索消耗行动力:" + stage.Levels[1].EnergyExplore + "";
                                Level1_AchievementText.Text = "过关条件:" + stage.Levels[1].AchievementText + "";
                                Level1_BonusWin.Text = "过关奖励:" + parseBonus(stage.Levels[1].BonusWin + (stage.Levels[1].FirstBonusWin == null || stage.Levels[1].FirstBonusWin == "" ? "" : "," + stage.Levels[1].FirstBonusWin) + "");
                                Level1_BonusLose.Text = "失败奖励:" + parseBonus(stage.Levels[1].BonusLose + "");
                                Level1_BonusExplore.Text = "探索奖励:" + parseBonus(stage.Levels[1].BonusExplore + "");
                                Level1_HeroLevel.Text = "英雄等级:" + stage.Levels[1].HeroLevel + "";
                                Level1_HeroHP.Text = "英雄血量:" + GameData.Hero.Find(m => m.Level == stage.Levels[1].HeroLevel).Hp + "";

                                Level1_CardList.DataSource = null;
                                Level1_RuneList.DataSource = null;

                                var Level1_CardList_table = new DataTable("Level1_CardList");
                                Level1_CardList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("卡牌",typeObject),
                                new DataColumn("等级",typeInt32),
                                new DataColumn("15级技能",typeObject),
                            });
                                string[] Level1_cardlist_stringArray = stage.Levels[1].CardList.Split(',');
                                foreach (var i in Level1_cardlist_stringArray)
                                {
                                    string[] cardStringArray = i.Split('_');
                                    switch (cardStringArray.Length)
                                    {
                                        case 2:
                                            {
                                                Level1_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                        });
                                                break;
                                            }
                                        case 3:
                                            {
                                                Level1_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                          int.Parse(cardStringArray[1])<15?null:  GameData.Skill.Find(m=>m.SkillId==int.Parse(cardStringArray[2])).Name,
                                        });
                                                break;
                                            }
                                    }
                                }

                                var Level1_RuneList_table = new DataTable("Level1_RuneList");
                                Level1_RuneList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("符文",typeObject),
                                new DataColumn("等级",typeInt32),
                            });
                                if (stage.Levels[1].RuneList != "")
                                {
                                    string[] Level1_runelist_stringArray = stage.Levels[1].RuneList.Split(',');
                                    foreach (var i in Level1_runelist_stringArray)
                                    {
                                        string[] runeStringArray = i.Split('_');
                                        Level1_RuneList_table.Rows.Add(new object[] {
                                        GameData.Rune.Find(m=>m.RuneId==int.Parse(runeStringArray[0])).RuneName,
                                        int.Parse(runeStringArray[1]),
                                    });
                                    }
                                }

                                Level1_CardList.DataSource = Level1_CardList_table;
                                Level1_RuneList.DataSource = Level1_RuneList_table;
                            }

                            {
                                Level2_Color.Text = "星级:" + stage.Levels[2].Color + "";
                                Level2_EnergyExpend.Text = "过关消耗行动力:" + stage.Levels[2].EnergyExpend + "";
                                Level2_EnergyExplore.Text = "探索消耗行动力:" + stage.Levels[2].EnergyExplore + "";
                                Level2_AchievementText.Text = "过关条件:" + stage.Levels[2].AchievementText + "";
                                Level2_BonusWin.Text = "过关奖励:" + parseBonus(stage.Levels[2].BonusWin + (stage.Levels[2].FirstBonusWin == null || stage.Levels[2].FirstBonusWin == "" ? "" : "," + stage.Levels[2].FirstBonusWin) + "");
                                Level2_BonusLose.Text = "失败奖励:" + parseBonus(stage.Levels[2].BonusLose + "");
                                Level2_BonusExplore.Text = "探索奖励:" + parseBonus(stage.Levels[2].BonusExplore + "");
                                Level2_HeroLevel.Text = "英雄等级:" + stage.Levels[2].HeroLevel + "";
                                Level2_HeroHP.Text = "英雄血量:" + GameData.Hero.Find(m => m.Level == stage.Levels[2].HeroLevel).Hp + "";

                                Level2_CardList.DataSource = null;
                                Level2_RuneList.DataSource = null;

                                var Level2_CardList_table = new DataTable("Level2_CardList");
                                Level2_CardList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("卡牌",typeObject),
                                new DataColumn("等级",typeInt32),
                                new DataColumn("15级技能",typeObject),
                            });
                                string[] Level2_cardlist_stringArray = stage.Levels[2].CardList.Split(',');
                                foreach (var i in Level2_cardlist_stringArray)
                                {
                                    string[] cardStringArray = i.Split('_');
                                    switch (cardStringArray.Length)
                                    {
                                        case 2:
                                            {
                                                Level2_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                        });
                                                break;
                                            }
                                        case 3:
                                            {
                                                Level2_CardList_table.Rows.Add(new object[] {
                                            GameData.Card.Find(m=>m.CardId==int.Parse(cardStringArray[0])).CardName,
                                            int.Parse(cardStringArray[1]),
                                          int.Parse(cardStringArray[1])<15?null:  GameData.Skill.Find(m=>m.SkillId==int.Parse(cardStringArray[2])).Name,
                                        });
                                                break;
                                            }
                                    }
                                }

                                var Level2_RuneList_table = new DataTable("Level2_RuneList");
                                Level2_RuneList_table.Columns.AddRange(new DataColumn[]{
                                new DataColumn("符文",typeObject),
                                new DataColumn("等级",typeInt32),
                            });
                                if (stage.Levels[2].RuneList != "")
                                {
                                    string[] Level2_runelist_stringArray = stage.Levels[2].RuneList.Split(',');
                                    foreach (var i in Level2_runelist_stringArray)
                                    {
                                        string[] runeStringArray = i.Split('_');
                                        Level2_RuneList_table.Rows.Add(new object[] {
                                        GameData.Rune.Find(m=>m.RuneId==int.Parse(runeStringArray[0])).RuneName,
                                        int.Parse(runeStringArray[1]),
                                    });
                                    }
                                }

                                Level2_CardList.DataSource = Level2_CardList_table;
                                Level2_RuneList.DataSource = Level2_RuneList_table;
                            }

                            string htmlcss = "<style>" + Properties.Resources.htmlcss + "</style>";
                            string noselect = "<script>" + Properties.Resources.noselect + "</script>";

                            string dialogue = "";
                            dialogue += "<hr style=\"clear:both;margin:0;padding:0;border:none;\"/>";
                            foreach (var i in stage.Dialogue)
                            {
                                dialogue += "<div class=\"dialogue\">";
                                if (i.Orientations == 1)
                                {
                                    dialogue += "<img style=\"float:left;margin-right:1em;\" src=\"" + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\story\" + (i.Icon[0] == '0' ? "m_" + i.Icon : i.Icon) + ".png" + "\"/>";
                                }
                                else
                                {
                                    dialogue += "<img style=\"float:right;margin-left:1em;\" src=\"" + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\story\" + (i.Icon[0] == '0' ? "m_" + i.Icon : i.Icon) + ".png" + "\"/>";
                                }
                                dialogue += "<h3 class=\"npc\">" + (i.NPC == "player_name" ? "[玩家]" : i.NPC) + "</h3>";
                                dialogue += "<p class=\"dialogueContent\">" + i.Content + "</p>";
                                dialogue += "</div>";
                                dialogue += "<hr/>";
                            }
                            Dialogue.DocumentText = noselect + htmlcss + dialogue;

                            string dialogueAfter = "";
                            dialogueAfter += "<hr style=\"clear:both;margin:0;padding:0;border:none;\"/>";
                            foreach (var i in stage.DialogueAfter)
                            {
                                dialogueAfter += "<div class=\"dialogue\">";
                                if (i.Orientations == 1)
                                {
                                    dialogueAfter += "<img style=\"float:left;margin-right:1em;\" src=\"" + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\story\" + (i.Icon[0] == '0' ? "m_" + i.Icon : i.Icon) + ".png" + "\"/>";
                                }
                                else
                                {
                                    dialogueAfter += "<img style=\"float:right;margin-left:1em;\" src=\"" + Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\魔卡幻想\story\" + (i.Icon[0] == '0' ? "m_" + i.Icon : i.Icon) + ".png" + "\"/>";
                                }
                                dialogueAfter += "<h3 class=\"npc\">" + (i.NPC == "player_name" ? "[玩家]" : i.NPC) + "</h3>";
                                dialogueAfter += "<p class=\"dialogueContent\">" + i.Content + "</p>";
                                dialogueAfter += "</div>";
                                dialogueAfter += "<hr/>";
                            }
                            DialogueAfter.DocumentText = noselect + htmlcss + dialogueAfter;

                            MapStageDetial.Show();
                        }
                        else
                        {
                            MapStageDetail_FightImg.ImageLocation = "";
                            MapStageDetail_FightName.Text = "";
                            MapStageDetail_Prev.Text = "";
                            MapStageDetail_Next.Text = "";
                            if (stage.Type == 3)
                            {
                                MazeCount.Text = "迷宫层数:" + map.MazeCount + "";
                            }
                            MapStageDetial.Hide();
                        }

                        MapStageDetail_Name.Text = "关卡名称:" + stage.Name + "";
                        MapStageDetail_Type.Text = "关卡类型:" + (stage.Type == 0 ? "隐藏关卡" : stage.Type == 1 ? "一般关卡" : stage.Type == 2 ? "BOSS 关卡" : stage.Type == 3 ? "迷宫" : stage.Type == 4 ? "预留" : stage.Type + "") + "";
                        MapStageDetail_MapStageDetailId.Text = "关卡编号:" + stage.MapStageDetailId + "";
                        MapStageDetail_Rank.Text = "关卡顺序:" + stage.Rank + "";
                        MapStageDetail_X_Y.Text = "关卡坐标:" + stage.X + "," + stage.Y + "";

                        panel_stage.Visible = true;
                        break;
                    }
            }
        }