Esempio n. 1
0
        public static void ParseCommand(string cmd)
        {
            string[] data = cmd.Split(' ');
            if (data.Length == 0)
            {
                return;
            }
            try
            {
                switch (data[0])
                {
                case "exp": if (data.Length == 2)
                    {
                        UserProfile.InfoBasic.AddExp(int.Parse(data[1]));
                    }
                    break;

                case "itm": if (data.Length == 3)
                    {
                        UserProfile.InfoBag.AddItem(int.Parse(data[1]), int.Parse(data[2]));
                    }
                    break;

                case "gold": if (data.Length == 2)
                    {
                        UserProfile.InfoBag.AddResource(GameResourceType.Gold, uint.Parse(data[1]));
                    }
                    break;

                case "res": if (data.Length == 2)
                    {
                        var v = uint.Parse(data[1]);
                        UserProfile.InfoBag.AddResource(new uint[] { 0, v, v, v, v, v, v });
                    }
                    break;

                case "dmd": if (data.Length == 2)
                    {
                        UserProfile.InfoBag.AddDiamond(int.Parse(data[1]));
                    }
                    break;

                case "acv": if (data.Length == 2)
                    {
                        UserProfile.Profile.InfoGismo.AddGismo(int.Parse(data[1]));
                    }
                    break;

                case "sceq":
                    NpcTalkForm sw = new NpcTalkForm();
                    sw.EventId = SceneQuestBook.GetSceneQuestByName(data[1]);
                    PanelManager.DealPanel(sw); break;

                case "cure": UserProfile.InfoBasic.MentalPoint = 100; UserProfile.InfoBasic.HealthPoint = 100;
                    UserProfile.InfoBasic.FoodPoint            = 100; break;
                }
            }
            catch (FormatException) { }
            catch (IndexOutOfRangeException) { }
        }
Esempio n. 2
0
        public void Generate(List <int> randQuestList, int questCellCount)
        {
            foreach (var questData in SceneQuestBook.GetQuestConfigData(mapId))
            {
                for (int j = 0; j < questData.Value; j++)
                {
                    randQuestList.Add(questData.Id);
                }
            }

            int offset = UserProfile.InfoRecord.GetRecordById((int)MemPlayerRecordTypes.DungeonQuestOffside);

            while (randQuestList.Count < questCellCount)
            {
                if (offset < UserProfile.InfoWorld.SavedDungeonQuests.Count - 1)
                {
                    randQuestList.Add(UserProfile.InfoWorld.SavedDungeonQuests[offset]);
                    offset++;
                }
                else
                {
                    ListTool.RandomShuffle(UserProfile.InfoWorld.SavedDungeonQuests);
                    offset = 0;
                    randQuestList.Add(UserProfile.InfoWorld.SavedDungeonQuests[offset]);
                }
            }
            UserProfile.InfoRecord.SetRecordById((int)MemPlayerRecordTypes.DungeonQuestOffside, offset);
            ListTool.RandomShuffle(randQuestList);
        }
Esempio n. 3
0
        public override void Init(int width, int height)
        {
            base.Init(width, height);
            showImage = true;
            config    = ConfigData.GetSceneQuestConfig(EventId);
            if (config.Level > 0)
            {
                eventLevel = config.Level;
            }
            else
            {
                eventLevel = ConfigData.GetSceneConfig(UserProfile.InfoBasic.MapId).Level;
            }

            int regionIndex = 1;

            if (config.TriggerDNAHard != null && config.TriggerDNAHard.Length > 0)
            {
                for (int i = 0; i < config.TriggerDNAHard.Length; i++)
                {
                    var dnaId = DnaBook.GetDnaId(config.TriggerDNAHard[i]);
                    if (UserProfile.InfoBasic.HasDna(dnaId))
                    {
                        vRegion.AddRegion(new ImageRegion(dnaId, 28 * regionIndex, 55, 24, 24, ImageRegionCellType.None, HSIcons.GetImage("Dna", dnaId)));
                        dnaChangeDict[dnaId] = "事件难度 " + config.TriggerDNAHard[i].Substring(3);
                        //dnaChangeDict[dnaId] += "$经验资源 " + GetDnaStr(-int.Parse(config.TriggerDNAHard[i + 1]));
                        regionIndex++;
                    }
                }
            }
            if (config.TriggerDNARate != null && config.TriggerDNARate.Length > 0)
            {
                for (int i = 0; i < config.TriggerDNARate.Length; i++)
                {
                    var dnaId = DnaBook.GetDnaId(config.TriggerDNARate[i]);
                    if (UserProfile.InfoBasic.HasDna(dnaId))
                    {
                        var dataStr = "出现几率 " + config.TriggerDNARate[i].Substring(3);
                        if (dnaChangeDict.ContainsKey(dnaId))
                        {
                            dnaChangeDict[dnaId] += "$" + dataStr;
                        }
                        else
                        {
                            vRegion.AddRegion(new ImageRegion(dnaId, 28 * regionIndex, 55, 24, 24, ImageRegionCellType.None, HSIcons.GetImage("Dna", dnaId)));
                            dnaChangeDict[dnaId] = dataStr;
                        }
                        regionIndex++;
                    }
                }
            }
            interactBlock = SceneQuestBook.GetQuestData(this, EventId, eventLevel, config.Script);
            answerList    = new List <SceneQuestBlock>();
            SetupQuestItem();
        }
Esempio n. 4
0
        public void CheckEventList()
        {
            if (CheckState())
            {
                foreach (var gismoId in gismoList)
                {
                    if (GetGismo(gismoId)) //已经有了
                    {
                        continue;
                    }

                    var gismoConfig = ConfigData.GetDungeonGismoConfig(gismoId);
                    if (!CheckEnvironmentState(gismoConfig))
                    {
                        return;
                    }

                    if (!string.IsNullOrEmpty(gismoConfig.FinishSceneQuest))
                    {
                        var questId = SceneQuestBook.GetSceneQuestByName(gismoConfig.FinishSceneQuest);
                        if (gismoConfig.FinishContinueCount > 0)
                        {
                            if (UserProfile.InfoDungeon.CheckQuestCount(questId, gismoConfig.FinishState, gismoConfig.FinishContinueCount, true))
                            {
                                AddGismo(gismoId);
                            }
                        }
                        else if (gismoConfig.FinishCount > 0)
                        {
                            if (UserProfile.InfoDungeon.CheckQuestCount(questId, gismoConfig.FinishState, gismoConfig.FinishCount, false))
                            {
                                AddGismo(gismoId);
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(gismoConfig.FinishSceneQuestTag))
                    {
                        if (gismoConfig.FinishContinueCount > 0)
                        {
                            if (UserProfile.InfoDungeon.CheckQuestTagCount(gismoConfig.FinishSceneQuestTag, gismoConfig.FinishState, gismoConfig.FinishContinueCount, true))
                            {
                                AddGismo(gismoId);
                            }
                        }
                        else if (gismoConfig.FinishCount > 0)
                        {
                            if (UserProfile.InfoDungeon.CheckQuestTagCount(gismoConfig.FinishSceneQuestTag, gismoConfig.FinishState, gismoConfig.FinishCount, false))
                            {
                                AddGismo(gismoId);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 private static void FilterSpecialData(List <DbSceneSpecialPosData> specialDataList,
                                       Dictionary <int, DbSceneSpecialPosData> cachedSpecialData)
 {
     foreach (var specialPosData in specialDataList)
     {
         if (specialPosData.Type == "Quest")
         {
             if (!SceneQuestBook.IsQuestAvail(specialPosData.Info))
             {
                 continue;
             }
         }
         cachedSpecialData[specialPosData.Id] = specialPosData;
     }
 }
Esempio n. 6
0
 public void Init(int id, int minute)
 {
     mapId = id;
     if (UserProfile.InfoWorld.SavedDungeonQuests.Count == 0)
     {
         UserProfile.InfoRecord.SetRecordById((int)MemPlayerRecordTypes.DungeonQuestOffside, 0);
         foreach (var questData in SceneQuestBook.GetDungeonQuestConfigData(mapId))
         {
             for (int j = 0; j < questData.Value; j++)
             {
                 UserProfile.InfoWorld.SavedDungeonQuests.Add(questData.Id);
             }
         }
         ListTool.RandomShuffle(UserProfile.InfoWorld.SavedDungeonQuests);
     }
 }
Esempio n. 7
0
 public override void Init(int width, int height)
 {
     base.Init(width, height);
     showImage = true;
     config    = ConfigData.GetSceneQuestConfig(EventId);
     if (config.Level > 0)
     {
         eventLevel = config.Level;
     }
     else
     {
         eventLevel = ConfigData.GetSceneConfig(UserProfile.InfoBasic.MapId).Level;
     }
     interactBlock = SceneQuestBook.GetQuestData(EventId, eventLevel, config.Script);
     answerList    = new List <SceneQuestBlock>();
     SetupQuestItem();
 }
Esempio n. 8
0
        public void Generate(List <int> randQuestList, int questCellCount)
        {
            foreach (var questData in SceneQuestBook.GetQuestConfigData(mapId))
            {
                for (int j = 0; j < questData.Value; j++)
                {
                    randQuestList.Add(questData.Id);
                }
            }

            if (randQuestList.Count > questCellCount)
            {
                randQuestList.RemoveRange(questCellCount, randQuestList.Count - questCellCount);
                NLog.Warn(string.Format("Generate id={0} size too big {1}", mapId, randQuestList.Count));
            }
            else
            {
                ListTool.Fill(randQuestList, 0, questCellCount);
            }
            ListTool.RandomShuffle(randQuestList);
        }
Esempio n. 9
0
        private Image GetSceneImage()
        {
            var config = ConfigData.GetSceneConfig(UserProfile.InfoBasic.MapId);

            ControlPlus.TipImage tipData = new ControlPlus.TipImage();
            tipData.AddTextNewLine(string.Format("{0}(Lv{1})", sceneName, config.Level), "LightBlue", 20);
            tipData.AddLine(2);
            tipData.AddTextNewLine(string.Format("格子:{0}", sceneItems.Count), "White");
            foreach (var questData in SceneQuestBook.GetQuestConfigData(UserProfile.InfoBasic.MapId))
            {
                var questConfig = ConfigData.GetSceneQuestConfig(questData.Id);
                if (questConfig.Type == SceneQuestTypes.Hidden)
                {
                    continue;
                }
                var happend  = GetDisableEventCount(questData.Id);
                var evtLevel = questConfig.Level == 0 ? config.Level : questConfig.Level;
                tipData.AddTextNewLine(string.Format(" {0}Lv{3}({1}/{2})", questConfig.Name,
                                                     happend, questData.Value, evtLevel), happend == questData.Value ? "DimGray" : HSTypes.I2QuestDangerColor(questConfig.Danger));
            }
            return(tipData.Image);
        }
Esempio n. 10
0
        private void SetupQuestItem()
        {
            Graphics g = this.CreateGraphics();

            colorWord.UpdateText(interactBlock.Script, g);
            g.Dispose();
            answerList.Clear();
            foreach (var sceneQuestBlock in interactBlock.Children)
            {
                if (sceneQuestBlock.Disabled)
                {
                    continue;
                }
                AddBlockAnswer(sceneQuestBlock);

                if (sceneQuestBlock.Children != null)
                {
                    var childScript = sceneQuestBlock.Children[0].Script;
                    if (childScript.StartsWith("fight")) //如果是战斗
                    {
                        sceneQuestBlock.SetScript(string.Format("|icon.abl1||{0}", sceneQuestBlock.Script));
                        if (config.CanBribe)//判断战斗贿赂
                        {
                            int fightLevel = Math.Max(1, eventLevel);
                            var cost       = GameResourceBook.OutCarbuncleBribe(UserProfile.InfoBasic.Level, fightLevel);
                            if (UserProfile.InfoBag.HasResource(GameResourceType.Carbuncle, cost))
                            {
                                var questBlock = SceneQuestBook.GetQuestData(this, EventId, eventLevel, "blockbribe");
                                questBlock.SetScript(string.Format("|icon.res5||{0}|lime|(消耗{1})", questBlock.Script, cost));
                                questBlock.Children[0].Children[0].Children[0] = sceneQuestBlock.Children[0].Children[1].Children[0].Children[0];//找到成功的结果
                                AddBlockAnswer(questBlock);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public static List <SceneObject> RefreshSceneObjects(int id, int mapWidth, int mapHeight, SceneFreshReason reason)
        {
            List <ScenePosData> cachedMapData = new List <ScenePosData>();
            var cachedSpecialData             = new Dictionary <int, DbSceneSpecialPosData>();
            var filePath = ConfigData.GetSceneConfig(id).TilePath;

            List <DbSceneSpecialPosData> specialDataList = new List <DbSceneSpecialPosData>();

            if (reason != SceneFreshReason.Load || UserProfile.Profile.InfoWorld.PosInfos == null || UserProfile.Profile.InfoWorld.PosInfos.Count <= 0)
            {//重新生成
                UserProfile.InfoBasic.DungeonRandomSeed = MathTool.GetRandom(int.MaxValue);
                Random r = new Random(UserProfile.InfoBasic.DungeonRandomSeed);
                SceneQuestBook.LoadSceneFile(mapWidth, mapHeight, filePath, r, cachedMapData, specialDataList);
                FilterSpecialData(specialDataList, cachedSpecialData);
                var questCellCount = cachedMapData.Count - cachedSpecialData.Count;
                GenerateSceneRandomInfo(id, questCellCount, cachedMapData, cachedSpecialData);
            }
            else
            {//从存档加载
                Random r = new Random(UserProfile.InfoBasic.DungeonRandomSeed);
                SceneQuestBook.LoadSceneFile(mapWidth, mapHeight, filePath, r, cachedMapData, specialDataList);
                foreach (var posData in UserProfile.Profile.InfoWorld.PosInfos)
                {
                    cachedSpecialData[posData.Id] = posData;
                }
            }

            List <SceneObject> sceneObjects = new List <SceneObject>();

            foreach (var scenePosData in cachedMapData)
            {
                DbSceneSpecialPosData cachedData;
                cachedSpecialData.TryGetValue(scenePosData.Id, out cachedData);

                SceneObject so;
                if (cachedData != null)
                {
                    switch (cachedData.Type)
                    {
                    case "Quest":
                        so          = new SceneQuest(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height, cachedData.Info);
                        so.Disabled = cachedData.Disabled; break;

                    case "Warp":
                        so          = new SceneWarp(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height, cachedData.Info);
                        so.Disabled = cachedData.Disabled;
                        if (ConfigData.GetSceneConfig(id).Type == SceneTypes.Common && reason == SceneFreshReason.Warp)
                        {
                            cachedData.Disabled = true;
                            so.Disabled         = true;//如果是切场景,切到战斗场景,所有传送门自动关闭
                        }
                        break;

                    default:
                        so = new SceneTile(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height); break;
                    }
                    so.Flag       = cachedData.Flag;
                    so.MapSetting = cachedData.MapSetting;
                }
                else
                {
                    so          = new SceneTile(scenePosData.Id, scenePosData.X, scenePosData.Y, scenePosData.Width, scenePosData.Height); break;
                    so.Disabled = true;
                    //throw new Exception("RefreshSceneObjects error");
                }
                sceneObjects.Add(so);
            }

            return(sceneObjects);
        }
Esempio n. 12
0
        private void NpcTalkForm_Paint(object sender, PaintEventArgs e)
        {
            BorderPainter.Draw(e.Graphics, "", Width, Height);

            if (showImage)
            {
                Font font2 = new Font("黑体", 12 * 1.33f, FontStyle.Bold, GraphicsUnit.Pixel);
                e.Graphics.DrawString(string.Format("{0}(Lv{1})({2})", config.Name, eventLevel, config.Script), font2, Brushes.White, Width / 2 - 40, 8);
                font2.Dispose();

                e.Graphics.DrawImage(SceneQuestBook.GetSceneQuestImageBig(config.Id), 20, 60, 300, 300);
                Image border = PicLoader.Read("Border", "scenequestbg.png"); //边框
                e.Graphics.DrawImage(border, 20, 60, 300, 300);
                border.Dispose();

                if (config.TriggerRate > 0 && config.TriggerRate <= 30)
                {//稀有
                    Image rareImg = PicLoader.Read("System", "sqrare2.png");
                    e.Graphics.DrawImage(rareImg, 20 + 16, 60 + 16, 64, 32);
                    rareImg.Dispose();
                }
                else if (config.TriggerRate > 0 && config.TriggerRate <= 60)
                {//罕见
                    Image rareImg = PicLoader.Read("System", "sqrare1.png");
                    e.Graphics.DrawImage(rareImg, 20 + 16, 60 + 16, 64, 32);
                    rareImg.Dispose();
                }

                if (evtItem != null)
                {
                    evtItem.Draw(e.Graphics);
                }

                colorWord.Draw(e.Graphics);
                if (vRegion != null)
                {
                    vRegion.Draw(e.Graphics);
                }

                if (answerList != null && (evtItem == null || evtItem.RunningState != TalkEventItem.TalkEventState.Running))
                {
                    int id       = 0;
                    var bgTarget = PicLoader.Read("System", "WordBack1.png");
                    var bgCommon = PicLoader.Read("System", "WordBack2.png");
                    foreach (var word in answerList)
                    {
                        var rect   = word.Rect;
                        var bgRect = new Rectangle(rect.X, rect.Y, rect.Width - 20, 24);
                        if (id == tar)
                        {
                            e.Graphics.DrawImage(bgTarget, bgRect);
                        }
                        else
                        {
                            e.Graphics.DrawImage(bgCommon, bgRect);
                        }

                        word.Draw(e.Graphics);
                        id++;
                    }
                    bgTarget.Dispose();
                    bgCommon.Dispose();
                }
            }
        }
Esempio n. 13
0
        public override void Draw(Graphics g)
        {
            if (nid > 0)
            {
                Image            img       = null;
                HsActionCallback preAction = null;
                HsActionCallback action    = null;
                if (type == PictureRegionCellType.Item)
                {
                    img    = HItemBook.GetHItemImage(nid);
                    action = () =>
                    {
                        var itemConfig = ConfigData.GetHItemConfig(nid);
                        var pen        = new Pen(Color.FromName(HSTypes.I2RareColor(itemConfig.Rare)), 2);
                        g.DrawRectangle(pen, X, Y, Width, Height);
                        pen.Dispose();
                    };
                }
                else if (type == PictureRegionCellType.Gismo)
                {
                    img = DungeonBook.GetGismoImage(nid);
                }
                else if (type == PictureRegionCellType.People)
                {
                    img       = HSIcons.GetImage("Samurai", nid);
                    preAction = () =>
                    {
                        var peopleConfig = ConfigData.GetSamuraiConfig(nid);
                        var brush        = new SolidBrush(Color.FromName(HSTypes.I2QualityColorD(peopleConfig.Quality)));
                        g.FillRectangle(brush, X + 3, Y + 3, Width - 6, Height - 6);
                        brush.Dispose();
                    };
                }
                else if (type == PictureRegionCellType.SceneQuest)
                {
                    img = SceneQuestBook.GetSceneQuestImageScene(nid);
                }
                else if (type == PictureRegionCellType.DungeonItem)
                {
                    img = DungeonBook.GetDungeonItemImage(nid);
                }

                if (preAction != null)
                {
                    preAction();
                }
                if (img != null)
                {
                    if (Scale == 1)
                    {
                        if (Enabled)
                        {
                            g.DrawImage(img, X, Y, Width, Height);
                        }
                        else
                        {
                            g.DrawImage(img, new Rectangle(X, Y, Width, Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, HSImageAttributes.ToGray);
                        }
                    }
                    else
                    {
                        int realWidth  = (int)(Width * Scale);
                        int realHeight = (int)(Height * Scale);
                        g.DrawImage(img, X + (Width - realWidth) / 2, Y + (Height - realHeight) / 2, realWidth, realHeight);
                    }
                }
                if (action != null)
                {
                    action();
                }
            }

            foreach (IRegionDecorator decorator in decorators)
            {
                decorator.Draw(g, X, Y, Width, Height);
            }
        }