public void CaluculateResult_Button_Click() { int leftBorderParameter = mainCamera.GetComponent <ParameterParser> ().GetLeftBorderParameter(); int rightBorderParameter = mainCamera.GetComponent <ParameterParser> ().GetRightBorderParameter(); int parameterValue = mainCamera.GetComponent <ParameterParser> ().GetParameterValue(); int minimumDiceValue = mainCamera.GetComponent <DiceValueParser> ().GetMinimumDiceValue(); int maximumDiceValue = mainCamera.GetComponent <DiceValueParser> ().GetMaximumDiceValue(); double significanceParameter = mainCamera.GetComponent <SignificanceParameterController> ().GetSignificanceParameter(); dice = new Dice.Dice(minimumDiceValue, maximumDiceValue, leftBorderParameter, rightBorderParameter, significanceParameter); string result; if (!(leftBorderParameter < rightBorderParameter)) { result = "Левая граница параметра должна быть меньше правой."; } else if (!((parameterValue >= leftBorderParameter) && (parameterValue <= rightBorderParameter))) { result = "Значение параметра должно находиться между границами."; } else if (!(minimumDiceValue < maximumDiceValue)) { result = "Минимальное значение дайса должно быть меньше максимального."; } else { result = "Выпавшее значение:\n" + dice.ThrowDise(parameterValue).ToString(); } resultPanel.GetChild(1).GetComponent <Text> ().text = result.ToString(); dice = null; }
/// <summary> /// Initializes a new instance of the <see cref="Casino"/> class. /// </summary> /// <param name="chances"> /// The chances. /// </param> /// <param name="switchToFairChance"> /// The switch to fair chance. /// </param> /// <param name="swicthToUnfairChance"> /// The swicth to unfair chance. /// </param> public Casino(List <DiceSideChance> chances, double switchToFairChance, double swicthToUnfairChance) { this.fairDice = new FairDice(chances); this.unfairDice = new UnfairDice(chances); this.switchToFairChance = switchToFairChance; this.swicthToUnfairChance = swicthToUnfairChance; this.currentDice = this.SetStartDice(chances); }
static void Main(string[] args) { Dice d = new Dice(); d.rolls = new List<float> {8, 12, 7, 9, 7, 9, 7, 8, 11, 10, 9, 7, 6, 10, 6, 7, 4, 8, 11, 10 }; float total = d.rolls.Sum(); float average = total / d.rolls.Count; Console.WriteLine("Total: " + total); Console.WriteLine("Average: " + average); Console.ReadLine(); }
/// <summary> /// The maybe switch dice. /// </summary> private void MaybeSwitchDice() { var randomNumber = this.random.NextDouble(); if (this.currentDice is UnfairDice && randomNumber <= this.switchToFairChance) { this.currentDice = this.fairDice; return; } if (this.currentDice is FairDice && randomNumber <= this.swicthToUnfairChance) { this.currentDice = this.unfairDice; } }
static void Main(string[] args) { Dice[] dice = new Dice[3]; var player = new Player(); for (int i = 0; i < dice.Length; i++) { dice[i] = new Dice(); } while (true) { string input = Console.ReadLine(); string msg = ""; if (input == "h") { for (int i = 0; i < dice.Length; i++) { msg += dice[i].getHistory(); msg += dice[i].getStats(); } } else { var allResults = new int[dice.Length]; for (int i = 0; i < dice.Length; i++) { int result = dice[i].Roll(); msg += " " + result.ToString(); allResults[i] = result; } int score = player.calcPoint(allResults); msg += " 結果:" + score + "ポイント" + " 残高:" + player.point +"ポイント"; } Console.Write(msg); } }