/// <summary> /// long type(64bit) 구간 난수 추출 /// </summary> /// <param name="section">구간, 1을 넣을 경우 무조건 최소값이나 최대값이 나오고, 0이하를 넣으면 무조건 최소값이 나온다. Max-Min 값보다 클 수 없다.</param> /// <returns></returns> public long Get(int section) { if (section < 1) { return(Min); } if (section > (Max - Min)) { throw new Exception("Sections cannot be larger than the Max-Min value."); } var r = new SmartRandom(); try { long val = (Max - Min) / section; return(Min + val * r.Next(section + 1)); } catch { return(0); } }
public DungeonWave(List <Monster> monsterList, int monsterCount) { var r = new SmartRandom(); Monsters = new List <Monster>(); for (int i = 0; i < monsterCount; i++) { Monsters.Add(MonsterDictionary.MakeMonster(monsterList[r.Next(monsterList.Count)].Name)); } }
/// <summary> /// 몬스터를 만든다. /// </summary> public Monster Make(Monster frame) { // 이름 Name = frame.Name; // 능력치 var basicAbility = new Ability(frame.TotalAbility.Power, frame.TotalAbility.Stamina, frame.TotalAbility.Intelli, frame.TotalAbility.Willpower, frame.TotalAbility.Concentration, frame.TotalAbility.Agility); // 경험치, 골드 var basicExp = frame.Exp; var basicGold = frame.Gold; // 드랍아이템 DropItemFormattedInfo = frame.DropItemFormattedInfo; /* 돌연변이 */ SmartRandom r = new SmartRandom(); // 편차 (+-3%) 구간 100 Bounds staminaBounds = new Bounds(Convert.ToInt64(basicAbility.Stamina * 0.97), Convert.ToInt64(basicAbility.Stamina * 1.03)); Bounds expBounds = new Bounds(Convert.ToInt64(basicExp * 0.97), Convert.ToInt64(basicExp * 1.03)); Bounds goldBounds = new Bounds(Convert.ToInt64(basicGold * 0.97), Convert.ToInt64(basicGold * 1.03)); int staminaSection = staminaBounds.Range > 100 ? 100 : staminaBounds.Range > 5 ? 5 : 0; int expSection = expBounds.Range > 100 ? 100 : expBounds.Range > 5 ? 5 : 0; int goldSection = goldBounds.Range > 100 ? 100 : goldBounds.Range > 5 ? 5 : 0; long convertedStamina = staminaBounds.Get(staminaSection); long convertedExp = expBounds.Get(expSection); long convertedGold = goldBounds.Get(goldSection); // 능력치 설정 TotalAbility = new Ability(basicAbility.Power, convertedStamina, basicAbility.Intelli, basicAbility.Willpower, basicAbility.Concentration, basicAbility.Agility); TotalAbility.Calculate(); // HP, MP TotalAbility.HP = TotalAbility.HPMax; TotalAbility.MP = TotalAbility.MPMax; // 경험치, 골드 Exp = convertedExp; Gold = convertedGold; // 드랍아이템 DropItems = new List <Item>(); string[] dropData = DropItemFormattedInfo.Split('/'); for (int i = 0; i < dropData.Length / 2; i++) { Item item = ItemDictionary.MakeItem(dropData[i * 2]); int dropNumber = int.Parse(dropData[i * 2 + 1]); // 몬스터가 아이템을 가지고 있다! if (r.Next(dropNumber) == 0) { DropItems.Add(item); } } return(this); }
/// <summary> /// int type(32bit) 난수 추출 /// </summary> /// <returns></returns> public int Get() { var r = new SmartRandom(); return(r.Next(Convert.ToInt32(Min), Convert.ToInt32(Max))); }