示例#1
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();
        }
示例#2
0
 public TalkEventItem(int evtId, int l, Rectangle r, SceneQuestEvent e)
 {
     level  = l;
     pos    = r;
     evt    = e;
     config = ConfigData.GetSceneQuestConfig(evtId);
     if (config.TriggerDNAHard != null && config.TriggerDNAHard.Length > 0)
     {
         for (int i = 0; i < config.TriggerDNAHard.Length; i++)
         {
             if (UserProfile.InfoBasic.HasDna(DnaBook.GetDnaId(config.TriggerDNAHard[i])))
             {
                 hardness += DnaBook.GetDnaEffect(config.TriggerDNAHard[i]);
             }
         }
     }
     RunningState = TalkEventState.Running;
 }
示例#3
0
        private static bool IsQuestRateAvail(SceneQuestConfig questConfig)
        {
            if (questConfig.TriggerRate == 0)
            {
                return(true);
            }
            int rateBase = questConfig.TriggerRate;

            if (questConfig.TriggerDNARate != null && questConfig.TriggerDNARate.Length > 0)
            {
                for (int i = 0; i < questConfig.TriggerDNARate.Length; i++)
                {
                    var dnaName = questConfig.TriggerDNARate[i].Substring(0, 3);
                    if (UserProfile.InfoBasic.HasDna(DnaBook.GetDnaId(dnaName)))
                    {
                        rateBase *= (10 + DnaBook.GetDnaEffect(questConfig.TriggerDNARate[i])) / 10;
                    }
                }
            }
            return(MathTool.GetRandom(100) < rateBase);
        }
示例#4
0
        private void CheckCondition(string info)
        {
            string[] parms  = info.Split('-');
            var      config = ConfigData.GetSceneQuestConfig(eventId);

            if (parms[0] == "cantrade")
            {
                int    multi = int.Parse(parms[1]);
                string type  = "all";
                if (parms.Length > 2)
                {
                    type = parms[2];
                }
                double multiNeed = multi * MathTool.Clamp(1, 0.2, 5);
                double multiGet  = multi * MathTool.Clamp(1, 0.2, 5);
                uint   goldNeed  = 0;
                if (config.TradeGold < 0)
                {
                    goldNeed = GameResourceBook.OutGoldSceneQuest(level, (int)(-config.TradeGold * multiNeed), true);
                }
                uint foodNeed = 0;
                if (config.TradeFood < 0)
                {
                    foodNeed = Math.Min(100, GameResourceBook.OutFoodSceneQuest((int)(-config.TradeFood * multiNeed), true));
                }
                uint healthNeed = 0;
                if (config.TradeHealth < 0)
                {
                    healthNeed = Math.Min(100, GameResourceBook.OutHealthSceneQuest((int)(-config.TradeHealth * multiNeed), true));
                }
                uint mentalNeed = 0;
                if (config.TradeMental < 0)
                {
                    mentalNeed = Math.Min(100, GameResourceBook.OutMentalSceneQuest((int)(-config.TradeMental * multiNeed), true));
                }
                Disabled = !UserProfile.Profile.InfoBag.HasResource(GameResourceType.Gold, goldNeed) ||
                           UserProfile.Profile.InfoBasic.FoodPoint < foodNeed ||
                           UserProfile.Profile.InfoBasic.HealthPoint < healthNeed ||
                           UserProfile.Profile.InfoBasic.MentalPoint < mentalNeed;

                if (string.IsNullOrEmpty(config.TradeDropItem))
                {
                    uint goldAdd = 0;
                    if (config.TradeGold > 0 && (type == "all" || type == "gold"))
                    {
                        goldAdd = GameResourceBook.InGoldSceneQuest(level, (int)(config.TradeGold * multiGet), true);
                    }
                    uint foodAdd = 0;
                    if (config.TradeFood > 0 && (type == "all" || type == "food"))
                    {
                        foodAdd = Math.Min(100, GameResourceBook.InFoodSceneQuest((int)(config.TradeFood * multiGet), true));
                    }
                    uint healthAdd = 0;
                    if (config.TradeHealth > 0 && (type == "all" || type == "health"))
                    {
                        healthAdd = Math.Min(100, GameResourceBook.InHealthSceneQuest((int)(config.TradeHealth * multiGet), true));
                    }
                    uint mentalAdd = 0;
                    if (config.TradeMental > 0 && (type == "all" || type == "mental"))
                    {
                        mentalAdd = Math.Min(100, GameResourceBook.InMentalSceneQuest((int)(config.TradeMental * multiGet), true));
                    }
                    Script = string.Format("获得{0}(消耗{1})",
                                           GetTradeStr(goldAdd, foodAdd, healthAdd, mentalAdd),
                                           GetTradeStr(goldNeed, foodNeed, healthNeed, mentalNeed));
                }
                else
                {
                    var dropId = DropBook.GetDropId(config.TradeDropItem);
                    Script = string.Format("获得{0}(消耗{1})",
                                           ConfigData.GetDropConfig(dropId).Name,
                                           GetTradeStr(goldNeed, foodNeed, healthNeed, mentalNeed));
                }
            }
            else if (parms[0] == "cantest")
            {
                int  type       = int.Parse(parms[1]);
                bool canConvert = type == 1; //是否允许转换成幸运检测

                var testType  = type == 1 ? config.TestType1 : config.TestType2;
                int sourceVal = UserProfile.InfoDungeon.GetAttrByStr(testType);
                Disabled = UserProfile.InfoDungeon.DungeonId <= 0 || sourceVal < 0;
                if (Disabled && canConvert)
                {
                    Disabled = false;
                }

                if (!Disabled)
                {
                    var biasData = type == 1 ? config.TestBias1 : config.TestBias2;
                    if (UserProfile.InfoDungeon.DungeonId > 0 && UserProfile.InfoDungeon.GetAttrByStr(testType) >= 0)
                    {
                        var attrNeed = UserProfile.InfoDungeon.GetRequireAttrByStr(testType, biasData);
                        Script = string.Format("|icon.oth1||进行{0}考验|lime|(判定{1} {2:0.0}%胜率)", GetTestAttrStr(testType), attrNeed,
                                               GetWinRate(UserProfile.InfoDungeon.GetAttrByStr(testType) + 0.5f, attrNeed));
                    }
                    else //因为convert了
                    {
                        Script = string.Format("|icon.oth1||进行运气考验|lime|(判定{0} {1:0.0}%胜率)", 3 + biasData,
                                               GetWinRate(3.5f, 3 + biasData));
                    }
                }
            }
            else if (parms[0] == "hasditem")
            {
                var itemId = DungeonBook.GetDungeonItemId(config.NeedDungeonItemId);
                Disabled = UserProfile.InfoDungeon.GetDungeonItemCount(itemId) < config.NeedDungeonItemCount;
            }
            else if (parms[0] == "hasdna")
            {
                if (config.DnaInfo != null && config.DnaInfo.Length > 0)
                {
                    string dnaStr = "";
                    int    dnaId  = 0;
                    foreach (var dnaName in config.DnaInfo)
                    {
                        var nowId = DnaBook.GetDnaId(dnaName);
                        dnaId  |= (int)Math.Pow(2, nowId);
                        dnaStr += ConfigData.GetPlayerDnaConfig(nowId).Name + " ";
                    }
                    Script   = string.Format("|icon.oth14||{0}|lime|(DNA限定{1})", Script, dnaStr);
                    Disabled = !UserProfile.InfoBasic.HasDna(dnaId);
                }
            }
        }