public void TestDDStatRollerAllValuesCheck() { IRollable d = new DiceSet(); IRollable dd1 = DiceFactory.CreateDDStatRoller(); ((DiceSet)d).Add(dd1); // populate "not yet found" list List <int> notFound = new List <int>(); notFound.AddRange(new int[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }); // attempt to find each value for (int i = 1; i < 1000; i++) // arbitrary limit of 10000 maximum tries { int result = d.Roll(); // 3 to 18 notFound.Remove(result); if (notFound.Count <= 0) { break; // all found } } // test Assert.AreEqual <int>(0, notFound.Count, "Some values were not rolled on 3 d6."); }
// Start is called before the first frame update void Start() { rollableTarget = transform.GetComponentInChildren <IRollable>(); rollableTarget.State .Where(x => x != State.Value) .Subscribe(x => State.Value = x); for (var i = 0; i < eyeNum; i++) { var eyeObj = Instantiate((GameObject)Resources.Load(EYE_RESOURCE_PATH)); eyeObj.transform.parent = transform; var eye = eyeObj.GetComponent <Eye>(); eye.Initialize( number: (i + 1) * 10, angle: CIRCLE_ANGLE / eyeNum * i ); eyeList.Add(eye); } rollableTarget.Position .Subscribe(x => { ClosestNumber.Value = eyeList .OrderBy(y => (x - y.Position).sqrMagnitude) .First() .Number.Value; }); Debug.Log("Wheel Start End"); }
private int CompareDistance(IRollable a, IRollable b) { if (a.Distance() < b.Distance()) { return(1); } else { return(-1); } }
public void RollTest() { List <int> rollResults = new List <int>(); IRollable d = DiceFactory.CreateD10(); for (int i = 0; i < 100000000; i++) { rollResults.Add(d.Roll()); } Assert.AreEqual(rollResults.Count, 100000000, "Count is " + rollResults.Count.ToString()); }
private int CompareByDistance(IRollable a, IRollable b) //使用List 內定的 Sort時, 回傳型態是整數 { if (a.Distance() > b.Distance()) { return(-1); } else { return(1); } }
public void AddRollable(IRollable toAdd) { if (toAdd.MaxValue > maxValue ) { maxValue = toAdd.MaxValue; } if (toAdd.MinValue < minValue) { minValue = toAdd.MinValue; } rollables.Add(toAdd); }
public static List <int> SetUp1000000Results(this IRollable rollable) { var rollableResults = new List <int>(); for (int i = 0; i < 1000000; i++) { int result = rollable.Roll(); rollableResults.Add(result); } return(rollableResults); }
//以下為滾球大賽的程式碼 private void btn_RollContest_Click(object sender, EventArgs e) { IRollable rollShape = null; _mRollShapeList.Clear(); //從 shapeArr 中尋找屬於 IRollable 的物件並加入 _mRollShapeList foreach (var shape in shapeArr) { rollShape = shape as IRollable; if (null != rollShape) { _mRollShapeList.Add(rollShape); } } _mRollShapeList.Sort(CompareByDistance); //使用 List 的內建Sort函式 ShowRollShapeInfo(txt_RollContest); }
public ItemDatabase( IObjectIconHandler objectIconHandler, IMaterialHandler materialHandler, IAbilityHandler abilityHandler, ICraftingRecipeHandler craftingRecipeHandler, IRollable roller = null) { this.ValueExtractor = new JSONValueExtractor(); this.ObjectIcons = objectIconHandler; this.MaterialHandler = materialHandler; this.AbilityHandler = abilityHandler; this.CraftingRecipeHandler = craftingRecipeHandler; this.Roller = roller ?? new RNG(); this.m_ItemDatabase = new List <BaseItemType>(this.LoadComponents()); this.m_ItemDatabase.AddRange(this.Load()); }
private void button3_Click(object sender, EventArgs e) { string info = ""; IRollable Roll = null; List <IRollable> RollableShape = new List <IRollable>(); foreach (var obj in shapeArr) { Roll = obj as IRollable; if (Roll != null) { RollableShape.Add(Roll); } } RollableShape.Sort(CompareDistance); foreach (var rollshpae in RollableShape) { info += (rollshpae.RollableShapeProperty() + string.Format("{0,8:F2}", rollshpae.Distance()) + "\r\n"); } textBox11.Text = info; }
/// <summary> /// Method used to add a single "die" (IRollable) object. /// </summary> /// <param name="die">IRollable object.</param> public void Add(IRollable die) { mDiceBag.Add(die); }
public Player(IRollable d20) { myD20 = d20; }
public static List<IRollable> And(this IEnumerable<IRollable> original, IRollable toAdd) { var rollables = new List<IRollable> {toAdd}; rollables.AddRange(original); return rollables; }
public static List<IRollable> And(this IRollable original, IRollable toAdd) { return new List<IRollable> {original, toAdd}; }
public CombatEngine(IRollable roller = null) { this.Roller = roller ?? new RNG(); }