質問編集履歴
3
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
1
|
-
### 前提・実現したいこと
|
5
|
+
```### 前提・実現したいこと
|
2
6
|
|
3
7
|
|
4
8
|
|
@@ -26,190 +30,192 @@
|
|
26
30
|
|
27
31
|
|
28
32
|
|
33
|
+
``````
|
34
|
+
|
35
|
+
using System.Collections;
|
36
|
+
|
37
|
+
using System.Collections.Generic;
|
38
|
+
|
39
|
+
using UnityEngine;
|
40
|
+
|
41
|
+
using UnityEngine.UI;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
public class MainSystem : MonoBehaviour
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
public int Ratp;
|
50
|
+
|
51
|
+
public Player player;
|
52
|
+
|
53
|
+
public Enemy enemy;
|
54
|
+
|
55
|
+
public GameObject ResultPanel;
|
56
|
+
|
57
|
+
public GameObject NextStagePanel;
|
58
|
+
|
59
|
+
//PlayerTurnのTF
|
60
|
+
|
61
|
+
bool IsPlayerTurn;
|
62
|
+
|
63
|
+
//GameOverのTF
|
64
|
+
|
65
|
+
bool IsGameOver;
|
66
|
+
|
67
|
+
//次enemy出現タイムのTF
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
float second = 0f;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
void Start()
|
76
|
+
|
77
|
+
{
|
78
|
+
|
79
|
+
//PlayerTurnをT、GameOverをF、GameOver画面を隠す
|
80
|
+
|
81
|
+
IsPlayerTurn = true;
|
82
|
+
|
83
|
+
IsGameOver = false;
|
84
|
+
|
85
|
+
ResultPanel.SetActive(false);
|
86
|
+
|
87
|
+
NextStagePanel.SetActive(false);
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
//GameOver画面を出す処理
|
94
|
+
|
95
|
+
void ViewResult()
|
96
|
+
|
97
|
+
{
|
98
|
+
|
99
|
+
ResultPanel.SetActive(true);
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
//NextStage画面を出す処理
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
void Update()
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
//Playerのターン終了後の処理
|
112
|
+
|
113
|
+
if (!IsPlayerTurn)
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
//enemyのターン、playerターンの1秒後に開始
|
118
|
+
|
119
|
+
second += Time.deltaTime;
|
120
|
+
|
121
|
+
if (second >= 1f)
|
122
|
+
|
123
|
+
{
|
124
|
+
|
125
|
+
//playerはenemyの攻撃力分のダメージを受け、enemyターン終了
|
126
|
+
|
127
|
+
player.Damage(enemy.atp);
|
128
|
+
|
129
|
+
IsPlayerTurn = true;
|
130
|
+
|
131
|
+
second = 0f;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
if(enemy.hp <= 0)
|
140
|
+
|
141
|
+
{
|
142
|
+
|
143
|
+
Destroy(this.gameObject);
|
144
|
+
|
145
|
+
Debug.Log("Trueに変更");
|
146
|
+
|
147
|
+
StartCoroutine(ShowImageSecond(NextStagePanel, 2f));
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
//playerが負けた際の処理
|
152
|
+
|
153
|
+
if(player.hp <= 0)
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
IsGameOver = true;
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
//GameOverになった時の処理
|
162
|
+
|
163
|
+
if(IsGameOver)
|
164
|
+
|
165
|
+
{
|
166
|
+
|
167
|
+
ViewResult();
|
168
|
+
|
169
|
+
return;
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
IEnumerator ShowImageSecond(GameObject targetObj,float sec)
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
targetObj.SetActive(true);
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
yield return new WaitForSeconds(sec);
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
targetObj.SetActive(false);
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
//攻撃ボタンを押した時の処理
|
198
|
+
|
199
|
+
public void PushAttackButton()
|
200
|
+
|
201
|
+
{
|
202
|
+
|
203
|
+
//player攻撃力の抽選、Ratpに代入、攻撃、playerターンの終了
|
204
|
+
|
205
|
+
Ratp = Random.Range(1, 1000);
|
206
|
+
|
207
|
+
Debug.Log(Ratp);
|
208
|
+
|
209
|
+
enemy.Damage(Ratp);
|
210
|
+
|
211
|
+
IsPlayerTurn = false;
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
}
|
216
|
+
|
29
217
|
```
|
30
218
|
|
31
|
-
using System.Collections;
|
32
|
-
|
33
|
-
using System.Collections.Generic;
|
34
|
-
|
35
|
-
using UnityEngine;
|
36
|
-
|
37
|
-
using UnityEngine.UI;
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
public class MainSystem : MonoBehaviour
|
42
|
-
|
43
|
-
{
|
44
|
-
|
45
|
-
public int Ratp;
|
46
|
-
|
47
|
-
public Player player;
|
48
|
-
|
49
|
-
public Enemy enemy;
|
50
|
-
|
51
|
-
public GameObject ResultPanel;
|
52
|
-
|
53
|
-
public GameObject NextStagePanel;
|
54
|
-
|
55
|
-
//PlayerTurnのTF
|
56
|
-
|
57
|
-
bool IsPlayerTurn;
|
58
|
-
|
59
|
-
//GameOverのTF
|
60
|
-
|
61
|
-
bool IsGameOver;
|
62
|
-
|
63
|
-
//次enemy出現タイムのTF
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
float second = 0f;
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
void Start()
|
72
|
-
|
73
|
-
{
|
74
|
-
|
75
|
-
//PlayerTurnをT、GameOverをF、GameOver画面を隠す
|
76
|
-
|
77
|
-
IsPlayerTurn = true;
|
78
|
-
|
79
|
-
IsGameOver = false;
|
80
|
-
|
81
|
-
ResultPanel.SetActive(false);
|
82
|
-
|
83
|
-
NextStagePanel.SetActive(false);
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
//GameOver画面を出す処理
|
90
|
-
|
91
|
-
void ViewResult()
|
92
|
-
|
93
|
-
{
|
94
|
-
|
95
|
-
ResultPanel.SetActive(true);
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
//NextStage画面を出す処理
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
void Update()
|
104
|
-
|
105
|
-
{
|
106
|
-
|
107
|
-
//Playerのターン終了後の処理
|
108
|
-
|
109
|
-
if (!IsPlayerTurn)
|
110
|
-
|
111
|
-
{
|
112
|
-
|
113
|
-
//enemyのターン、playerターンの1秒後に開始
|
114
|
-
|
115
|
-
second += Time.deltaTime;
|
116
|
-
|
117
|
-
if (second >= 1f)
|
118
|
-
|
119
|
-
{
|
120
|
-
|
121
|
-
//playerはenemyの攻撃力分のダメージを受け、enemyターン終了
|
122
|
-
|
123
|
-
player.Damage(enemy.atp);
|
124
|
-
|
125
|
-
IsPlayerTurn = true;
|
126
|
-
|
127
|
-
second = 0f;
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
if(enemy.hp <= 0)
|
136
|
-
|
137
|
-
{
|
138
|
-
|
139
|
-
Destroy(this.gameObject);
|
140
|
-
|
141
|
-
Debug.Log("Trueに変更");
|
142
|
-
|
143
|
-
StartCoroutine(ShowImageSecond(NextStagePanel, 2f));
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
//playerが負けた際の処理
|
148
|
-
|
149
|
-
if(player.hp <= 0)
|
150
|
-
|
151
|
-
{
|
152
|
-
|
153
|
-
IsGameOver = true;
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
//GameOverになった時の処理
|
158
|
-
|
159
|
-
if(IsGameOver)
|
160
|
-
|
161
|
-
{
|
162
|
-
|
163
|
-
ViewResult();
|
164
|
-
|
165
|
-
return;
|
166
|
-
|
167
|
-
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
IEnumerator ShowImageSecond(GameObject targetObj,float sec)
|
176
|
-
|
177
|
-
{
|
178
|
-
|
179
|
-
targetObj.SetActive(true);
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
yield return new WaitForSeconds(sec);
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
targetObj.SetActive(false);
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
//攻撃ボタンを押した時の処理
|
194
|
-
|
195
|
-
public void PushAttackButton()
|
196
|
-
|
197
|
-
{
|
198
|
-
|
199
|
-
//player攻撃力の抽選、Ratpに代入、攻撃、playerターンの終了
|
200
|
-
|
201
|
-
Ratp = Random.Range(1, 1000);
|
202
|
-
|
203
|
-
Debug.Log(Ratp);
|
204
|
-
|
205
|
-
enemy.Damage(Ratp);
|
206
|
-
|
207
|
-
IsPlayerTurn = false;
|
208
|
-
|
209
|
-
}
|
210
|
-
|
211
|
-
}```
|
212
|
-
|
213
219
|
### 試したこと
|
214
220
|
|
215
221
|
|
2
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,41 +26,189 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
29
|
+
```
|
30
|
+
|
31
|
+
using System.Collections;
|
32
|
+
|
33
|
+
using System.Collections.Generic;
|
34
|
+
|
35
|
+
using UnityEngine;
|
36
|
+
|
37
|
+
using UnityEngine.UI;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
public class MainSystem : MonoBehaviour
|
42
|
+
|
43
|
+
{
|
44
|
+
|
45
|
+
public int Ratp;
|
46
|
+
|
47
|
+
public Player player;
|
48
|
+
|
49
|
+
public Enemy enemy;
|
50
|
+
|
51
|
+
public GameObject ResultPanel;
|
52
|
+
|
53
|
+
public GameObject NextStagePanel;
|
54
|
+
|
55
|
+
//PlayerTurnのTF
|
56
|
+
|
57
|
+
bool IsPlayerTurn;
|
58
|
+
|
59
|
+
//GameOverのTF
|
60
|
+
|
61
|
+
bool IsGameOver;
|
62
|
+
|
63
|
+
//次enemy出現タイムのTF
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
float second = 0f;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
void Start()
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
//PlayerTurnをT、GameOverをF、GameOver画面を隠す
|
76
|
+
|
77
|
+
IsPlayerTurn = true;
|
78
|
+
|
79
|
+
IsGameOver = false;
|
80
|
+
|
81
|
+
ResultPanel.SetActive(false);
|
82
|
+
|
83
|
+
NextStagePanel.SetActive(false);
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
//GameOver画面を出す処理
|
90
|
+
|
91
|
+
void ViewResult()
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
ResultPanel.SetActive(true);
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
//NextStage画面を出す処理
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
void Update()
|
104
|
+
|
105
|
+
{
|
106
|
+
|
107
|
+
//Playerのターン終了後の処理
|
108
|
+
|
109
|
+
if (!IsPlayerTurn)
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
//enemyのターン、playerターンの1秒後に開始
|
114
|
+
|
115
|
+
second += Time.deltaTime;
|
116
|
+
|
117
|
+
if (second >= 1f)
|
118
|
+
|
119
|
+
{
|
120
|
+
|
121
|
+
//playerはenemyの攻撃力分のダメージを受け、enemyターン終了
|
122
|
+
|
123
|
+
player.Damage(enemy.atp);
|
124
|
+
|
125
|
+
IsPlayerTurn = true;
|
126
|
+
|
127
|
+
second = 0f;
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
if(enemy.hp <= 0)
|
136
|
+
|
137
|
+
{
|
138
|
+
|
139
|
+
Destroy(this.gameObject);
|
140
|
+
|
141
|
+
Debug.Log("Trueに変更");
|
142
|
+
|
143
|
+
StartCoroutine(ShowImageSecond(NextStagePanel, 2f));
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
//playerが負けた際の処理
|
148
|
+
|
149
|
+
if(player.hp <= 0)
|
150
|
+
|
151
|
+
{
|
152
|
+
|
153
|
+
IsGameOver = true;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
//GameOverになった時の処理
|
158
|
+
|
159
|
+
if(IsGameOver)
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
ViewResult();
|
164
|
+
|
165
|
+
return;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
IEnumerator ShowImageSecond(GameObject targetObj,float sec)
|
176
|
+
|
177
|
+
{
|
178
|
+
|
179
|
+
targetObj.SetActive(true);
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
yield return new WaitForSeconds(sec);
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
targetObj.SetActive(false);
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
//攻撃ボタンを押した時の処理
|
194
|
+
|
195
|
+
public void PushAttackButton()
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
//player攻撃力の抽選、Ratpに代入、攻撃、playerターンの終了
|
200
|
+
|
201
|
+
Ratp = Random.Range(1, 1000);
|
202
|
+
|
203
|
+
Debug.Log(Ratp);
|
204
|
+
|
205
|
+
enemy.Damage(Ratp);
|
206
|
+
|
207
|
+
IsPlayerTurn = false;
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
}```
|
64
212
|
|
65
213
|
### 試したこと
|
66
214
|
|
1
タグの追加
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|