public MazeItem(int id, int level) { mlevel = level; this.Id = id; MazeItemConfig = ConfigData.GetMazeItemConfig(id); type = MazeItemConfig.Type; infos = new int[MazeItemConfig.Info.Length]; Array.Copy(MazeItemConfig.Info, infos, infos.Length); if (type == "ritem") { type = "item"; infos[0] = HItemBook.GetRandRareItemId(HItemRandomGroups.Fight, infos[0]); } else if (type == "rmon") { type = "mon"; infos[0] = infos[NarlonLib.Math.MathTool.GetRandom(0, infos.Length)]; infos[1] = 0; } else if (type == "rresource") { type = "resource"; infos[0] = NarlonLib.Math.MathTool.GetRandom(2, 8); } }
private NpcPieceData CreatePieceMethod(int index) { NpcPieceData piece = new NpcPieceData(); int rare = MathTool.GetRandom(Math.Max(index / 2, 1), index / 2 + 3); piece.Id = HItemBook.GetRandRareItemId(HItemRandomGroups.Fight, rare); piece.Count = MathTool.GetRandom((8 - rare) / 2, 8 - rare); return(piece); }
public DbMergeData CreateMergeMethod(int mid) { EquipConfig equipConfig = ConfigData.GetEquipConfig(mid); DbMergeData mthds = new DbMergeData(); mthds.Target = mid; { List <IntPair> mthd = new List <IntPair>(); int icount = GetItemCount(equipConfig.Level); int itrare = MathTool.GetRandom(Math.Max(1, equipConfig.Quality * 2 - 1), equipConfig.Quality * 2 + 1);//第一个素材品质和装备品质挂钩 Dictionary <int, bool> existFormula = new Dictionary <int, bool>(); for (int j = 0; j < icount; j++) { IntPair pv = new IntPair(); if (j == 0) { pv.Type = HItemBook.GetRandRareItemId(HItemRandomGroups.Gather, itrare); pv.Value = GetItemCountByEquipLevel(equipConfig.Level, itrare) + 1; } else { int nrare = MathTool.GetRandom(Math.Max(1, itrare - 3), itrare); pv.Type = HItemBook.GetRandRareItemId(HItemRandomGroups.Fight, nrare); pv.Value = Math.Max(1, GetItemCountByEquipLevel(equipConfig.Level, nrare)); } if (existFormula.ContainsKey(pv.Type)) { j--;//相当于做redo } else { existFormula.Add(pv.Type, true); mthd.Add(pv); } } mthds.Set(mthd); } return(mthds); }
private static void DropLevelItems(int[] itemLevelRate, List <int> items) { int sum = 0; foreach (var r in itemLevelRate) { sum += r; } int roll = MathTool.GetRandom(sum); int rare = 0; sum = 0; for (int j = 0; j < itemLevelRate.Length; j++) { sum += itemLevelRate[j]; if (roll < sum) { rare = j + 1; break; } } items.Add(HItemBook.GetRandRareItemId(HItemRandomGroups.Fight, rare)); }