質問編集履歴

1

修正

2018/07/18 07:57

投稿

GOTOken
GOTOken

スコア54

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  ---
32
32
 
33
- この加算されていく
33
+ この加算されていく現象を無くし、そのオブジェクトに与えられた数分だけ上昇するようにしたい。
34
34
 
35
35
  ```c#
36
36
 
@@ -40,8 +40,6 @@
40
40
 
41
41
  using UnityEngine;
42
42
 
43
- using System.Linq;
44
-
45
43
 
46
44
 
47
45
  public class Enemy : MonoBehaviour {
@@ -52,7 +50,7 @@
52
50
 
53
51
  public static int Enemy_HP;
54
52
 
55
- public int m_exp;
53
+
56
54
 
57
55
  public float speed;
58
56
 
@@ -60,17 +58,9 @@
60
58
 
61
59
  public static float ADDTIME;
62
60
 
63
- public float BulletInterval;
61
+
64
-
65
- public bool MoveFlg;
62
+
66
-
67
- public Star[] star;
63
+
68
-
69
- public float starSpeedMin;
70
-
71
- public float starSpeedMax;
72
-
73
-
74
64
 
75
65
  public static Enemy enemy_instance;
76
66
 
@@ -106,7 +96,7 @@
106
96
 
107
97
 
108
98
 
109
- if (HP <= 0 && !DeadFlg)
99
+ if (HP <= 0)
110
100
 
111
101
  {
112
102
 
@@ -122,56 +112,124 @@
122
112
 
123
113
  AddTime = 0;
124
114
 
115
+
116
+
117
+ Destroy(gameObject);
118
+
119
+
120
+
121
+
122
+
123
+ }
124
+
125
125
 
126
126
 
127
- var exp = m_exp;
128
-
129
-
130
-
131
- while (0 < exp)
132
-
133
- {
134
-
135
- var starPrefabs = star.Where(c => m_exp <= exp).ToArray();
136
-
137
- var starPrefab = star[Random.Range(0, starPrefabs.Length)];
138
-
139
- //var starPrefab = starPrefabs[Random.Range(0, starPrefabs.Length-1)];
140
-
141
- var stars = Instantiate(starPrefab, transform.position, Quaternion.identity);
142
-
143
- stars.Init(m_exp, starSpeedMin, starSpeedMax);
144
-
145
- exp -= stars.Exp;
146
-
147
- }
148
-
149
-
150
-
151
- Destroy(gameObject);
152
-
153
-
154
-
155
-
127
+    }
128
+
129
+
130
+
131
+
132
+
133
+ }
134
+
135
+
136
+
137
+ ```
138
+
139
+ ```c#
140
+
141
+ using System.Collections;
142
+
143
+ using System.Collections.Generic;
144
+
145
+ using UnityEngine;
146
+
147
+ using UnityEngine.UI;
148
+
149
+
150
+
151
+ public class GameManager : MonoBehaviour {
152
+
153
+
154
+
155
+ //遷移先誘導変数
156
+
157
+ public string gameover= "GameOver";
158
+
159
+
160
+
161
+ //ゲーム進行時間設定用変数
162
+
163
+ public static float GameTimerDelta;
164
+
165
+ public bool AddTimerFlg;
166
+
167
+ public float GameTimer;
168
+
169
+ public Text GameTimerText;
170
+
171
+ public float GameDecrementParametor;
172
+
173
+ public static bool GameTimerUPFlg;
174
+
175
+
176
+
177
+ private Text text;
178
+
179
+
180
+
181
+ // Use this for initialization
182
+
183
+ void Start () {
184
+
185
+
186
+
187
+ this.text= GetComponent<Text>();
188
+
189
+ }
190
+
191
+
192
+
193
+ // Update is called once per frame
194
+
195
+ void Update()
196
+
197
+ {
198
+
199
+ GameTimerText.text = GameTimer.ToString("0");
200
+
201
+
202
+
203
+ Main();
204
+
205
+ }
206
+
207
+ private void Main()
208
+
209
+ {
210
+
211
+ //ゲーム進行時間
212
+
213
+ GameTimer -= Time.deltaTime;
214
+
215
+ //敵撃破字時に時間を増加
216
+
217
+ if (GameTimerUPFlg)
218
+
219
+ {
220
+
221
+ GameTimerUPFlg = false;
222
+
223
+ GameTimer += GameTimerDelta;
156
224
 
157
225
  }
158
226
 
159
-
160
-
227
+
228
+
161
- }
229
+ }
162
-
163
-
164
-
165
-
166
230
 
167
231
  }
168
232
 
169
233
 
170
234
 
171
235
  ```
172
-
173
- ```c#
174
-
175
-
176
-
177
- ```