unityでゲームを作っていますが、このコードでGManager.instance~~が増えません。
どうしたら増えるのか教えて頂きたいです
c#
1using System; 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using UnityEngine.UI; 6using System.Linq; 7 8class Data 9{ 10 public string name; 11 public int rarity; 12 public int id; 13 public int numbers; 14} 15 16public class gacha : MonoBehaviour 17{ 18 public void itiren() 19 { 20 List<Data> myData = new List<Data> 21 { 22 new Data 23 { 24 name = "kaze", 25 rarity = 1, 26 id = 1001, 27 numbers = GManager.instance.kazeint 28 }, 29 30 new Data 31 { 32 name = "bomu", 33 rarity = 1, 34 id = 1002, 35 numbers = GManager.instance.bomuint 36 }, 37 38 new Data 39 { 40 name = "speeddown", 41 rarity = 1, 42 id = 1003, 43 numbers = GManager.instance.speeddownint 44 }, 45 46 new Data 47 { 48 name = "mpkotei", 49 rarity = 1, 50 id = 1004, 51 numbers = GManager.instance.mpkoteiint 52 }, 53 54 new Data 55 { 56 name = "mpzouka", 57 rarity = 1, 58 id = 1005, 59 numbers = GManager.instance.mpzoukaint 60 }, 61 62 new Data 63 { 64 name = "mpkyuushuu", 65 rarity = 1, 66 id = 1006, 67 numbers = GManager.instance.mpkyuushuuint 68 }, 69 70 new Data 71 { 72 name = "hpkaifuku", 73 rarity = 1, 74 id = 1007, 75 numbers = GManager.instance.hpkaifukuint 76 }, 77 78 new Data 79 { 80 name = "hpzouka", 81 rarity = 1, 82 id = 1008, 83 numbers = GManager.instance.hpzoukaint 84 } 85 }; 86 87 int gachane = 50; 88 if (GManager.instance.coin >= gachane) 89 { 90 GManager.instance.coin = GManager.instance.coin - gachane; 91 92 93 float gint = UnityEngine.Random.Range(0f, 100f); 94 if (gint < 50f) 95 { 96 var iti = 97 from x in myData 98 where x.rarity == 1 99 orderby x.id ascending 100 select x; 101 102 System.Random r1 = new System.Random(); 103 int r2 = r1.Next(0, 8); 104 105 Debug.Log(myData[r2].numbers); 106 107 foreach (Data a in iti) 108 { 109 ++ myData[r2].numbers; 110 Debug.Log(r2 + "+1"); 111 } 112 } 113 114 else if (gint < 90f) 115 { 116 Debug.Log("2"); 117 } 118 119 else if (gint < 97f) 120 { 121 Debug.Log("3"); 122 } 123 124 else 125 { 126 Debug.Log("4"); 127 } 128 } 129 } 130} 131 132using System.Collections; 133using System.Collections.Generic; 134using UnityEngine; 135 136public class GManager : MonoBehaviour 137{ 138 public static GManager instance = null; 139 140 //hosiiti 141 public int kazeint; 142 public int bomuint; 143 public int speeddownint; 144 public int mpkoteiint; 145 public int mpzoukaint; 146 public int mpkyuushuuint; 147 public int hpkaifukuint; 148 public int hpzoukaint; 149 //hosiitiowari 150 151 152 private void Awake() 153 { 154 if (instance == null) 155 { 156 instance = this; 157 DontDestroyOnLoad(this.gameObject); 158 } 159 else 160 { 161 Destroy(this.gameObject); 162 } 163 } 164}
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/01/20 14:41
2021/07/26 13:23 編集
2021/07/26 13:23
2021/07/27 08:27 編集
2021/07/26 13:26
2021/07/26 13:39 編集
2021/07/26 13:30
2021/07/26 13:33
2021/07/26 13:34
2021/07/26 13:36 編集
2021/07/26 13:37
2021/07/26 13:39
2021/07/26 13:40
2021/07/26 13:41
2021/07/26 13:42
2021/07/26 13:42
2021/07/26 13:44
2021/07/26 13:45
2021/07/26 13:48 編集
2021/07/26 13:47
2021/07/26 13:49
2021/07/26 13:49
2021/07/27 08:42 編集
2021/07/26 13:56
2021/07/26 13:57
2021/07/26 13:58
2021/07/26 13:59
2021/07/26 17:58 編集
2021/07/26 14:01