private void RewardMental(ref int index) { var mentalGet = (uint)(GameResourceBook.InMentalSceneQuest(config.RewardMental) * (10 - hardness) / 10); if (mentalGet > 0) { UserProfile.Profile.InfoBasic.AddMental(mentalGet); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Mental, (int)mentalGet); vRegion.AddRegion(pictureRegion); index++; } }
private void DoTrade() { int multi = int.Parse(evt.ParamList[0]); string type = "all"; if (evt.ParamList.Count >= 2) { type = evt.ParamList[1]; } double multiNeed = multi * MathTool.Clamp(1, 0.2f, 5); double multiGet = multi * MathTool.Clamp(1, 0.2f, 5); int index = 1; if (config.TradeGold > 0 && (type == "all" || type == "gold")) { var goldGet = GameResourceBook.InGoldSceneQuest(level, (int)(config.TradeGold * multiGet), true); if (goldGet > 0) { UserProfile.Profile.InfoBag.AddResource(GameResourceType.Gold, goldGet); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Gold, (int)goldGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeGold < 0) { var goldLoss = GameResourceBook.OutGoldSceneQuest(level, (int)(-config.TradeGold * multiNeed), true); if (goldLoss > 0) { UserProfile.Profile.InfoBag.SubResource(GameResourceType.Gold, goldLoss); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Gold, (int)-goldLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeFood > 0 && (type == "all" || type == "food")) { var foodGet = Math.Min(100, GameResourceBook.InFoodSceneQuest((int)(config.TradeFood * multiGet), true)); if (foodGet > 0) { UserProfile.Profile.InfoBasic.AddFood(foodGet); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Food, (int)foodGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeFood < 0) { var foodLoss = Math.Min(100, GameResourceBook.OutFoodSceneQuest((int)(-config.TradeFood * multiNeed), true)); if (foodLoss > 0) { UserProfile.Profile.InfoBasic.SubFood(foodLoss); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Food, (int)-foodLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeHealth > 0 && (type == "all" || type == "health")) { var healthGet = Math.Min(100, GameResourceBook.InHealthSceneQuest((int)(config.TradeHealth * multiGet), true)); if (healthGet > 0) { UserProfile.Profile.InfoBasic.AddHealth(healthGet); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Health, (int)healthGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeHealth < 0) { var healthLoss = Math.Min(100, GameResourceBook.OutHealthSceneQuest((int)(-config.TradeHealth * multiNeed), true)); if (healthLoss > 0) { UserProfile.Profile.InfoBasic.SubHealth(healthLoss); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Health, (int)-healthLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeMental > 0 && (type == "all" || type == "mental")) { var mentalGet = Math.Min(100, GameResourceBook.InMentalSceneQuest((int)(config.TradeMental * multiGet), true)); if (mentalGet > 0) { UserProfile.Profile.InfoBasic.AddMental(mentalGet); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Mental, (int)mentalGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeMental < 0) { var mentalLoss = Math.Min(100, GameResourceBook.OutMentalSceneQuest((int)(-config.TradeMental * multiNeed), true)); if (mentalLoss > 0) { UserProfile.Profile.InfoBasic.SubMental(mentalLoss); var pictureRegion = ComplexRegion.GetResShowRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Mental, (int)-mentalLoss); vRegion.AddRegion(pictureRegion); index++; } } if (!string.IsNullOrEmpty(config.TradeDropItem)) { var itemList = DropBook.GetDropItemList(config.TradeDropItem); foreach (var itemId in itemList) { UserProfile.InfoBag.AddItem(itemId, 1); vRegion.AddRegion(new PictureRegion(index, pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25, 60, 60, PictureRegionCellType.Item, itemId)); index++; } } }
private void DoTrade() { int multi = int.Parse(evt.ParamList[0]); int index = 1; if (config.TradeGold > 0) { var goldGet = GameResourceBook.InGoldSceneQuest(level, config.TradeGold * multi, true); if (goldGet > 0) { UserProfile.Profile.InfoBag.AddResource(GameResourceType.Gold, goldGet); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Gold, (int)goldGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeGold < 0) { var goldLoss = GameResourceBook.OutGoldSceneQuest(level, -config.TradeGold * multi, true); if (goldLoss > 0) { UserProfile.Profile.InfoBag.SubResource(GameResourceType.Gold, goldLoss); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Gold, (int)-goldLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeFood > 0) { var foodGet = Math.Min(100, GameResourceBook.InFoodSceneQuest(config.TradeFood * multi, true)); if (foodGet > 0) { UserProfile.Profile.InfoBasic.AddFood(foodGet); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Food, (int)foodGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeFood < 0) { var foodLoss = Math.Min(100, GameResourceBook.OutFoodSceneQuest(-config.TradeFood * multi, true)); if (foodLoss > 0) { UserProfile.Profile.InfoBasic.SubFood(foodLoss); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Food, (int)-foodLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeHealth > 0) { var healthGet = Math.Min(100, GameResourceBook.InHealthSceneQuest(config.TradeHealth * multi, true)); if (healthGet > 0) { UserProfile.Profile.InfoBasic.AddHealth(healthGet); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Health, (int)healthGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeHealth < 0) { var healthLoss = Math.Min(100, GameResourceBook.OutHealthSceneQuest(-config.TradeHealth * multi, true)); if (healthLoss > 0) { UserProfile.Profile.InfoBasic.SubHealth(healthLoss); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Health, (int)-healthLoss); vRegion.AddRegion(pictureRegion); index++; } } if (config.TradeMental > 0) { var mentalGet = Math.Min(100, GameResourceBook.InMentalSceneQuest(config.TradeMental * multi, true)); if (mentalGet > 0) { UserProfile.Profile.InfoBasic.AddMental(mentalGet); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Mental, (int)mentalGet); vRegion.AddRegion(pictureRegion); index++; } } else if (config.TradeMental < 0) { var mentalLoss = Math.Min(100, GameResourceBook.OutMentalSceneQuest(-config.TradeMental * multi, true)); if (mentalLoss > 0) { UserProfile.Profile.InfoBasic.SubMental(mentalLoss); var pictureRegion = ComplexRegion.GetSceneDataRegion(index, new Point(pos.X + 3 + 20 + (index - 1) * 70, pos.Y + 3 + 25), 60, ImageRegionCellType.Mental, (int)-mentalLoss); vRegion.AddRegion(pictureRegion); index++; } } }
private void CheckCondition(string info) { string[] parms = info.Split('-'); var config = ConfigData.GetSceneQuestConfig(eventId); if (parms[0] == "flagno") { Disabled = UserProfile.InfoRecord.CheckFlag( (uint)(MemPlayerFlagTypes)Enum.Parse(typeof(MemPlayerFlagTypes), parms[1])); } else if (parms[0] == "flag") { Disabled = !UserProfile.InfoRecord.CheckFlag( (uint)(MemPlayerFlagTypes)Enum.Parse(typeof(MemPlayerFlagTypes), parms[1])); } else if (parms[0] == "questno") { Disabled = UserProfile.InfoQuest.IsQuestFinish(config.QuestNeed); } else if (parms[0] == "quest") { Disabled = !UserProfile.InfoQuest.IsQuestFinish(config.QuestNeed); } else if (parms[0] == "questeq") { Disabled = UserProfile.InfoQuest.QuestId != config.QuestNeed; } else if (parms[0] == "rivalavail") { Disabled = !UserProfile.InfoRival.GetRivalState(config.EnemyId).Avail; } else if (parms[0] == "rivalavailno") { Disabled = UserProfile.InfoRival.GetRivalState(config.EnemyId).Avail; } else if (parms[0] == "sceneno") { Disabled = Scene.Instance.HasSceneItemWithName(parms[1]); } else if (parms[0] == "questfin") { Disabled = !Scene.Instance.IsSceneAllQuestOpened(); } else if (parms[0] == "cantrade") { int multi = int.Parse(parms[1]); uint goldNeed = 0; if (config.TradeGold < 0) { goldNeed = GameResourceBook.OutGoldSceneQuest(level, -config.TradeGold * multi, true); } uint foodNeed = 0; if (config.TradeFood < 0) { foodNeed = Math.Min(100, GameResourceBook.OutFoodSceneQuest(-config.TradeFood * multi, true)); } uint healthNeed = 0; if (config.TradeHealth < 0) { healthNeed = Math.Min(100, GameResourceBook.OutHealthSceneQuest(-config.TradeHealth * multi, true)); } uint mentalNeed = 0; if (config.TradeMental < 0) { mentalNeed = Math.Min(100, GameResourceBook.OutMentalSceneQuest(-config.TradeMental * multi, true)); } Disabled = !UserProfile.Profile.InfoBag.HasResource(GameResourceType.Gold, goldNeed) || UserProfile.Profile.InfoBasic.FoodPoint < foodNeed || UserProfile.Profile.InfoBasic.HealthPoint < healthNeed || UserProfile.Profile.InfoBasic.MentalPoint < mentalNeed; uint goldAdd = 0; if (config.TradeGold > 0) { goldAdd = GameResourceBook.InGoldSceneQuest(level, config.TradeGold * multi, true); } uint foodAdd = 0; if (config.TradeFood > 0) { foodAdd = Math.Min(100, GameResourceBook.InFoodSceneQuest(config.TradeFood * multi, true)); } uint healthAdd = 0; if (config.TradeHealth > 0) { healthAdd = Math.Min(100, GameResourceBook.InHealthSceneQuest(config.TradeHealth * multi, true)); } uint mentalAdd = 0; if (config.TradeMental > 0) { mentalAdd = Math.Min(100, GameResourceBook.InMentalSceneQuest(config.TradeMental * multi, true)); } Script = string.Format("增加{0}(消耗{1})", GetTradeStr(goldAdd, foodAdd, healthAdd, mentalAdd), GetTradeStr(goldNeed, foodNeed, healthNeed, mentalNeed)); } else if (parms[0] == "hasrival") { int pid = PeopleBook.GetRandomPeopleId(level - 3, level + 3); Disabled = UserProfile.InfoRival.GetRivalState(pid).Avail; UserProfile.InfoRecord.SetRecordById((int)MemPlayerRecordTypes.SceneQuestRandPeopleId, pid); Script = string.Format("偶遇了{0},我们来切磋一下吧", ConfigData.GetPeopleConfig(pid).Name); } }
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); } } }