ガチャを作ってみたのですが、10連ガチャの排出がとても偏ってしまいます。
10連ガチャの1回目は確率はおかしくなく、2回目以降が同じものばかりでたり10連のはずが、15個デバッグがでたりしました。
itiren()は問題なくできてます。
教えて下さるとありがたいです。
c#
1using System; 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using UnityEngine.UI; 6using System.Linq; 7 8public class gacha : MonoBehaviour 9{ 10 private int kai = 0; 11 public void itiren() 12 { 13 int gachane = 50; 14 if (GManager.Getinstance().coin >= gachane) 15 { 16 GManager.Getinstance().coin = GManager.Getinstance().coin - gachane; 17 18 19 float gint = UnityEngine.Random.Range(0f, 100f); 20 if (gint < 50f) 21 { 22 string[] itistr = new string[] 23 { 24 "kaze", 25 "bomu", 26 "speeddown", 27 "mpkotei", 28 "mpzouka", 29 "mpkyushuu", 30 "hpkaifuku", 31 "hpzouka", 32 }; 33 34 System.Random r1 = new System.Random(); 35 int r2 = r1.Next(0, 8); 36 37 var hosiiti = GManager.Getinstance().dict.Keys.ToList(); 38 foreach(var key in hosiiti) 39 { 40 if (itistr[r2] == key) 41 { 42 ++GManager.Getinstance().dict[key]; 43 Debug.Log(itistr[r2]); 44 GManager.Getinstance().hst = itistr[r2]; 45 } 46 } 47 } 48 49 else if (gint < 90f) 50 { 51 Debug.Log("2"); 52 } 53 54 else if (gint < 97f) 55 { 56 Debug.Log("3"); 57 } 58 59 else 60 { 61 Debug.Log("4"); 62 } 63 } 64 } 65 public void juuren() 66 { 67 int gachane10 = 480; 68 if (GManager.Getinstance().coin >= gachane10) 69 { 70 GManager.Getinstance().coin = GManager.Getinstance().coin - gachane10; 71 72 for (int r = 1; r <= 10; r++) 73 { 74 float gint = UnityEngine.Random.Range(0f, 100f); 75 if (gint < 50f) 76 { 77 string[] itistr = new string[] 78 { 79 "kaze", 80 "bomu", 81 "speeddown", 82 "mpkotei", 83 "mpzouka", 84 "mpkyushuu", 85 "hpkaifuku", 86 "hpzouka", 87 }; 88 89 System.Random r1 = new System.Random(); 90 int r2 = r1.Next(0, 8); 91 92 var hosiiti = GManager.Getinstance().dict.Keys.ToList(); 93 foreach (var key in hosiiti) 94 { 95 if (itistr[r2] == key) 96 { 97 ++GManager.Getinstance().dict[key]; 98 99 if (kai == 0) 100 { 101 GManager.Getinstance().hst1 = itistr[r2]; 102 ++kai; 103 Debug.Log(GManager.Getinstance().hst1); 104 } 105 if (kai == 1) 106 { 107 GManager.Getinstance().hst2 = itistr[r2]; 108 ++kai; 109 Debug.Log(GManager.Getinstance().hst2); 110 } 111 if (kai == 2) 112 { 113 GManager.Getinstance().hst3 = itistr[r2]; 114 ++kai; 115 Debug.Log(GManager.Getinstance().hst3); 116 } 117 if (kai == 3) 118 { 119 GManager.Getinstance().hst4 = itistr[r2]; 120 ++kai; 121 Debug.Log(GManager.Getinstance().hst4); 122 } 123 if (kai == 4) 124 { 125 GManager.Getinstance().hst5 = itistr[r2]; 126 ++kai; 127 Debug.Log(GManager.Getinstance().hst5); 128 } 129 if (kai == 5) 130 { 131 GManager.Getinstance().hst6 = itistr[r2]; 132 ++kai; 133 Debug.Log(GManager.Getinstance().hst6); 134 } 135 if (kai == 6) 136 { 137 GManager.Getinstance().hst7 = itistr[r2]; 138 ++kai; 139 Debug.Log(GManager.Getinstance().hst7); 140 } 141 if (kai == 7) 142 { 143 GManager.Getinstance().hst8 = itistr[r2]; 144 ++kai; 145 Debug.Log(GManager.Getinstance().hst8); 146 } 147 if (kai == 8) 148 { 149 GManager.Getinstance().hst9 = itistr[r2]; 150 ++kai; 151 Debug.Log(GManager.Getinstance().hst9); 152 } 153 if (kai == 9) 154 { 155 GManager.Getinstance().hst10 = itistr[r2]; 156 ++kai; 157 Debug.Log(GManager.Getinstance().hst10); 158 } 159 } 160 } 161 } 162 163 else if (gint < 90f) 164 { 165 Debug.Log("2"); 166 } 167 168 else if (gint < 97f) 169 { 170 Debug.Log("3"); 171 } 172 173 else 174 { 175 Debug.Log("4"); 176 } 177 } 178 } 179 } 180} 181 182using System; 183using System.Collections; 184using System.Collections.Generic; 185using UnityEngine; 186using UnityEngine.UI; 187using System.Linq; 188using System.Runtime.Serialization.Formatters.Binary; 189using System.IO; 190 191[System.Serializable] 192public class GManager : ISerializationCallbackReceiver 193{ 194 static GManager instance = null; 195 196 public static GManager Getinstance() 197 { 198 if(instance == null) 199 { 200 instance = new GManager(); 201 } 202 return instance; 203 } 204 public int coin = 10000; 205 public string hst = "?"; 206 public string hst1 = "?"; 207 public string hst2 = "?"; 208 public string hst3 = "?"; 209 public string hst4 = "?"; 210 public string hst5 = "?"; 211 public string hst6 = "?"; 212 public string hst7 = "?"; 213 public string hst8 = "?"; 214 public string hst9 = "?"; 215 public string hst10 = "?"; 216 217 //waza 218 public Dictionary<string, int> dict = new Dictionary<string, int>() 219 { 220 {"kaze",0}, 221 {"bomu",0}, 222 {"speeddown",0}, 223 {"mpkotei",0}, 224 {"mpzouka",1}, 225 {"mpkyushuu",0}, 226 {"hpkaifuku",1}, 227 {"hpzouka",1}, 228 {"mpkaifuku",0}, 229 {"fire",1}, 230 {"doku",1} 231 }; 232 //wazaowari 233}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/10 01:04