質問編集履歴
1
修正したスクリプトを記載、タイトルを変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
1減るはずが
|
1
|
+
1減るはずが0または-1になる
|
body
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
public Text Lifetext;
|
26
26
|
public Text Text;
|
27
27
|
public int heart = 100;
|
28
|
-
public int heart2;
|
28
|
+
public int heart2 = 900;
|
29
29
|
public AudioClip damageSE;
|
30
30
|
public AudioClip AttackSE;
|
31
31
|
AudioSource aud;
|
@@ -37,7 +37,8 @@
|
|
37
37
|
// Start is called before the first frame update
|
38
38
|
void Start()
|
39
39
|
{
|
40
|
+
Text.text = "HP: " + 900;
|
40
|
-
|
41
|
+
heart2 = PlayerPrefs.GetInt("level");
|
41
42
|
aud = GetComponent<AudioSource>();
|
42
43
|
i = Random.Range(1, 6);
|
43
44
|
if (i == 1)
|
@@ -91,7 +92,8 @@
|
|
91
92
|
{
|
92
93
|
SceneManager.LoadScene("GameOverScene");
|
93
94
|
}
|
94
|
-
if (Input.GetMouseButtonDown(0))
|
95
|
+
if (Input.GetMouseButtonDown(0) || Input.GetTouch(0).phase == TouchPhase.Began)
|
96
|
+
|
95
97
|
{
|
96
98
|
// クリック・タップした瞬間の座標
|
97
99
|
var pos = Camera.main.ScreenToWorldPoint(Input.mousePosition + Camera.main.transform.forward);
|
@@ -155,22 +157,19 @@
|
|
155
157
|
public void Attack()
|
156
158
|
{
|
157
159
|
aud.PlayOneShot(damageSE);
|
158
|
-
heart -= PlayerPrefs.GetInt("level")*2;
|
160
|
+
heart -= PlayerPrefs.GetInt("level")*2;
|
159
161
|
Lifetext.text = "HP: " + heart;
|
160
162
|
}
|
161
163
|
public void clickd()
|
162
164
|
{
|
163
165
|
if(color==color2)
|
164
166
|
{
|
165
|
-
|
167
|
+
Debug.Log("Attack");
|
166
|
-
if (seikai)
|
167
|
-
{
|
168
|
-
|
168
|
+
seikai = false;
|
169
|
-
|
169
|
+
aud.PlayOneShot(AttackSE);
|
170
|
-
|
170
|
+
heart2 = heart2 - PlayerPrefs.GetInt("level");
|
171
|
-
|
171
|
+
Text.text = "HP: " + heart2;
|
172
|
-
|
173
|
-
|
172
|
+
|
174
173
|
}
|
175
174
|
}
|
176
175
|
}
|