当前位置:   article > 正文

原神抽卡模拟器,unity制作(由于没有获得作者的视频授权,不会发布软件,只展示算法与开发等,效果图在个人主页类有资源下载,不会上传视频)_原神抽卡模拟器怎么制作

原神抽卡模拟器怎么制作

      

五星效果图

以上为展示,没做优化

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.Video;
  6. public class OneGifi : Pond
  7. {
  8. public void OneGift()
  9. {
  10. //抽奖即加一
  11. wuFloor += 1;
  12. siFloor += 1;
  13. //五星出货区
  14. int wuI = 0;
  15. //默认出奖值
  16. if (wuFloor < 40)
  17. Random_rewards = Random.Range(10, 999);
  18. else if (wuFloor < 73) Random_rewards = Random.Range(8, 1000);
  19. R = (int)Random_rewards; Debug.Log(R);
  20. //判断五星是否出了
  21. if (Withdraw == true)
  22. {
  23. wuFloor = 0;
  24. Withdraw = false;
  25. }
  26. if (wuFloor < 73)
  27. {
  28. while (wuI < 6)
  29. {
  30. if (R == wuRewards[wuI])
  31. {
  32. Withdraw = true;
  33. wuFloor = 0;
  34. }
  35. wuI++;
  36. }
  37. }
  38. //当五星保底到73后用新算法
  39. else if (wuFloor < 90)
  40. {
  41. //从新定义wurewards的范围,将随机出来的数放入The_Current_Probability_wu数组中,依次判断出奖值是否与出奖区对应
  42. int[] Temp_Data_wu = new int[1000];
  43. int The_Current_Probability_wu = 6 + 53 * (wuFloor - 73);
  44. Random_rewards = Random.Range(0, 1000);
  45. R = (int)Random_rewards;
  46. int new_min = The_Current_Probability_wu / 2;
  47. int new_max = 1000 - The_Current_Probability_wu / 2;
  48. //创建集中池
  49. for (int i = 0, j = 1000; i < new_min && j > new_max; i++, j--)
  50. {
  51. Temp_Data_wu[i] = i + 1;
  52. Temp_Data_wu[j - 1] = j - 1;
  53. }
  54. int new_wu = 0;
  55. while (new_wu < 1000)
  56. {
  57. if (R == Temp_Data_wu[new_wu])
  58. {
  59. Withdraw = true;
  60. break;
  61. }
  62. new_wu++;
  63. }
  64. }
  65. else
  66. {
  67. Withdraw = true;
  68. }
  69. //判断四星
  70. if (The_Purple == true&&Withdraw!=true)
  71. {
  72. The_Purple = false;
  73. siFloor = 0;
  74. }
  75. //判断四星是否出了
  76. int[] Temp_Data_si = new int[1000];
  77. int The_Current_Probability_si = 561;
  78. //定义wurewards的范围,将出奖值出来的数放入The_Current_Probability_wu数组中,依次判断出奖值是否与出奖区对应
  79. if (siFloor < 9)
  80. {
  81. Random_rewards = Random.Range(15, 980);
  82. R = (int)Random_rewards;
  83. int new_min = 26;
  84. int new_max = 1000 - 25;
  85. //创建集中池
  86. for (int i = 0, j = 1000; i < new_min && j > new_max; i++, j--)
  87. {
  88. Temp_Data_si[i] = i + 1;
  89. Temp_Data_si[j - 1] = j - 1;
  90. }
  91. int new_si = 14;
  92. while (new_si < 26 || (new_si > 975 && new_si < 1000))
  93. {
  94. if (new_si > 26)
  95. new_si += 949;
  96. if (R == Temp_Data_si[new_si])
  97. {
  98. The_Purple = true;
  99. break;
  100. }
  101. new_si++;
  102. }
  103. }
  104. else if (siFloor < 10)
  105. {
  106. Random_rewards = Random.Range(0, 1000);
  107. R = (int)Random_rewards;
  108. int new_min = The_Current_Probability_si / 2;
  109. int new_max = 1000 - The_Current_Probability_si / 2;
  110. //创建集中池
  111. for (int i = 0, j = 1000; i < new_min && j > new_max; i++, j--)
  112. {
  113. Temp_Data_si[i] = i + 1;
  114. Temp_Data_si[j - 1] = j - 1;
  115. }
  116. int new_si = 0;
  117. while (new_si < new_min || (new_si > new_max && new_si < 1000))
  118. {
  119. if (new_si > new_min)
  120. new_si += 1000 - new_max;
  121. if (R == Temp_Data_si[new_si])
  122. {
  123. The_Purple = true;
  124. break;
  125. }
  126. new_si++;
  127. }
  128. }
  129. if(siFloor==9)
  130. {
  131. The_Purple = true;
  132. }
  133. //没有的话出三星
  134. //抽中后判定
  135. if(The_Purple==true)
  136. {
  137. //判定是否定轨,如果已经定轨成功则取消定轨
  138. /*if (Fix_The_Track_wu==true)
  139. {
  140. Fix_The_Track_wu = false;
  141. }*/
  142. Random_rewards = Random.Range(0, 11);
  143. R = (int)Random_rewards;
  144. if (R > 0 && R < 6)
  145. Out_wu = 1;
  146. else if (R == 6)
  147. Out_wu = 2;
  148. else if (R == 7)
  149. Out_wu = 3;
  150. else if (R == 8)
  151. Out_wu = 4;
  152. else if (R == 9)
  153. Out_wu = 5;
  154. else
  155. Out_wu = 6;
  156. }
  157. //
  158. if (Withdraw == true)
  159. {
  160. //判定是否定轨,如果已经定轨成功则取消定轨
  161. /* if (Fix_The_Track_si == true)
  162. {
  163. Fix_The_Track_si = false;
  164. }
  165. else Fix_The_Track_si = true;*/
  166. Random_rewards = Random.Range(0, 511);
  167. double R = Random_rewards;
  168. //角色池
  169. if(R<255)
  170. {
  171. double R_min = 12.75;
  172. Out_si = 1;
  173. while ((R_min + 12.75) <= R)
  174. {
  175. R_min += 12.75;
  176. Out_si++;
  177. }
  178. }
  179. //武器池
  180. else
  181. {
  182. double R_min=14.16;
  183. Out_si = 1;
  184. while((R_min + 14.16)<=R)
  185. {
  186. R_min += 14.16;
  187. Out_si++;
  188. }
  189. }
  190. }
  191. }
  192. }

以上为“简易(没有原本精细)"算法,我借鉴了b站一颗平衡树大佬对原神抽卡机制研究

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/125451
推荐阅读
相关标签
  

闽ICP备14008679号