teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

書式の変更

2020/01/18 06:44

投稿

Mamida
Mamida

スコア17

title CHANGED
File without changes
body CHANGED
@@ -4,6 +4,7 @@
4
4
  使えるようにしたいです。
5
5
  public class CountDownScript : MonoBehaviour
6
6
  {
7
+
7
8
     '[SerializeField] GameObject CountObj;'
8
9
     'public Text Text;'
9
10
 
@@ -19,22 +20,26 @@
19
20
     'int count;'
20
21
     'public void setCount(int a) { count = a; }'
21
22
 
22
- // Start is called before the first frame update
23
+
23
24
  void Start()
24
25
  {
26
+
25
27
     'enter = false;'
26
28
     'Player = GameObject.Find("Player");'
27
29
     'py = Player.GetComponent<PlayerMoob>();'
28
30
     'count = 1;'
29
31
     'CountObj = GameObject.Find("CountObj");'
32
+
30
33
  }
31
34
 
32
35
  // Update is called once per frame
33
36
  void Update()
34
37
  {
38
+
35
39
  'START();'
36
40
  'if (enter == true)'
37
41
  '{
42
+
38
43
     'totalTime -= Time.deltaTime;'
39
44
     'seconds = (int)totalTime;'
40
45
     'Text.text = seconds.ToString();'
@@ -44,12 +49,14 @@
44
49
 
45
50
     'if (totalTime == 1)'
46
51
  '{
52
+
47
53
     'Text.text = "GO!!";'
48
54
     'py.setMoob(1);'
49
55
     'Invoke("FALSE",0.7f);'
50
56
 
51
57
  }'
52
58
  }'
59
+
53
60
  'enter = false;'
54
61
 
55
62
  }
@@ -59,12 +66,15 @@
59
66
 
60
67
  ' if (count == 0)
61
68
  '{
69
+
62
70
    'enter = true;'
71
+
63
72
  }'
64
73
  }'
65
74
 
66
75
  void FALSE()
67
76
  '{
77
+
68
78
    'CountObj.SetActive(false);'
69
79
     'totalTime = 4;'
70
80
     'START();'
@@ -106,6 +116,7 @@
106
116
 
107
117
  void FlipButton()
108
118
  {
119
+
109
120
     'smr = Scoreboard.GetComponent<ScoreManager>();'
110
121
     'smr.setWaza(2);'
111
122
     'cds = CountObj.GetComponent<CountDownScript>();'
@@ -119,8 +130,10 @@
119
130
 
120
131
  void flip()
121
132
  {
133
+
122
134
     'fsls = NomalStopLine.GetComponent<FrontStopLineScript>();'
123
135
     'fsls.setCom(2);'
136
+
124
137
  }
125
138
 
126
139
  }

2

書式の改善

2020/01/18 06:44

投稿

Mamida
Mamida

スコア17

title CHANGED
File without changes
body CHANGED
@@ -4,29 +4,29 @@
4
4
  使えるようにしたいです。
5
5
  public class CountDownScript : MonoBehaviour
6
6
  {
7
- '[SerializeField] GameObject CountObj;'
7
+    '[SerializeField] GameObject CountObj;'
8
- 'public Text Text;'
8
+    'public Text Text;'
9
9
 
10
- 'public float totalTime;'
10
+    'public float totalTime;'
11
- 'int seconds;'
11
+    'int seconds;'
12
12
 
13
- 'public float timer = 5.0f;'
13
+    'public float timer = 5.0f;'
14
- 'bool enter = false;//Enterキーが押されたときのフラグ'
14
+    'bool enter = false;//Enterキーが押されたときのフラグ'
15
15
 
16
- '[SerializeField] GameObject Player;'
16
+    '[SerializeField] GameObject Player;'
17
- 'PlayerMoob py;'
17
+    'PlayerMoob py;'
18
18
 
19
- 'int count;'
19
+    'int count;'
20
- 'public void setCount(int a) { count = a; }'
20
+    'public void setCount(int a) { count = a; }'
21
21
 
22
22
  // Start is called before the first frame update
23
23
  void Start()
24
24
  {
25
- 'enter = false;'
25
+    'enter = false;'
26
- 'Player = GameObject.Find("Player");'
26
+    'Player = GameObject.Find("Player");'
27
- 'py = Player.GetComponent<PlayerMoob>();'
27
+    'py = Player.GetComponent<PlayerMoob>();'
28
- 'count = 1;'
28
+    'count = 1;'
29
- 'CountObj = GameObject.Find("CountObj");'
29
+    'CountObj = GameObject.Find("CountObj");'
30
30
  }
31
31
 
32
32
  // Update is called once per frame
@@ -35,17 +35,18 @@
35
35
  'START();'
36
36
  'if (enter == true)'
37
37
  '{
38
- 'totalTime -= Time.deltaTime;'
38
+    'totalTime -= Time.deltaTime;'
39
- 'seconds = (int)totalTime;'
39
+    'seconds = (int)totalTime;'
40
- 'Text.text = seconds.ToString();'
40
+    'Text.text = seconds.ToString();'
41
- 'CountObj.SetActive(true);'
41
+    'CountObj.SetActive(true);'
42
- '//マイナス値にならないように'
42
+    '//マイナス値にならないように'
43
- 'totalTime = Mathf.Max(totalTime, 1);'
43
+    'totalTime = Mathf.Max(totalTime, 1);'
44
+
44
- 'if (totalTime == 1)'
45
+    'if (totalTime == 1)'
45
46
  '{
46
- 'Text.text = "GO!!";'
47
+    'Text.text = "GO!!";'
47
- 'py.setMoob(1);'
48
+    'py.setMoob(1);'
48
- 'Invoke("FALSE",0.7f);'
49
+    'Invoke("FALSE",0.7f);'
49
50
 
50
51
  }'
51
52
  }'
@@ -58,15 +59,15 @@
58
59
 
59
60
  ' if (count == 0)
60
61
  '{
61
- 'enter = true;'
62
+   'enter = true;'
62
63
  }'
63
64
  }'
64
65
 
65
66
  void FALSE()
66
67
  '{
67
- 'CountObj.SetActive(false);'
68
+   'CountObj.SetActive(false);'
68
- 'totalTime = 4;'
69
+    'totalTime = 4;'
69
- 'START();'
70
+    'START();'
70
71
 
71
72
  }'
72
73
  }'
@@ -105,21 +106,21 @@
105
106
 
106
107
  void FlipButton()
107
108
  {
108
- 'smr = Scoreboard.GetComponent<ScoreManager>();'
109
+    'smr = Scoreboard.GetComponent<ScoreManager>();'
109
- 'smr.setWaza(2);'
110
+    'smr.setWaza(2);'
110
- 'cds = CountObj.GetComponent<CountDownScript>();'
111
+    'cds = CountObj.GetComponent<CountDownScript>();'
111
- 'cds.setCount(0);'
112
+    'cds.setCount(0);'
112
- 'flip();'
113
+    'flip();'
113
- 'Flip.SetActive(false);'
114
+    'Flip.SetActive(false);'
114
- 'FenderGulub.SetActive(false);'
115
+    'FenderGulub.SetActive(false);'
115
- 'KyanKyan.SetActive(false);'
116
+    'KyanKyan.SetActive(false);'
116
117
 
117
118
  }
118
119
 
119
120
  void flip()
120
121
  {
121
- 'fsls = NomalStopLine.GetComponent<FrontStopLineScript>();'
122
+    'fsls = NomalStopLine.GetComponent<FrontStopLineScript>();'
122
- 'fsls.setCom(2);'
123
+    'fsls.setCom(2);'
123
124
  }
124
125
 
125
126
  }

1

書式の改善

2020/01/15 03:01

投稿

Mamida
Mamida

スコア17

title CHANGED
File without changes
body CHANGED
@@ -1,88 +1,95 @@
1
+ 現在制作しているゲームでカウントダウンを使用しているのですが、技を選択した後にカウントダウンが始まる様にしていて
2
+ 合計四回技を選択する場面があります。
3
+ 一回目は普通にカウントダウンが始まるのですが、二回目以降がカウントダウンが始まらないので複数回カウントダウンを
4
+ 使えるようにしたいです。
1
5
  public class CountDownScript : MonoBehaviour
2
6
  {
3
- [SerializeField] GameObject CountObj;
7
+ '[SerializeField] GameObject CountObj;'
4
- public Text Text;
8
+ 'public Text Text;'
5
9
 
6
- public float totalTime;
10
+ 'public float totalTime;'
7
- int seconds;
11
+ 'int seconds;'
8
12
 
9
- public float timer = 5.0f;
13
+ 'public float timer = 5.0f;'
10
- bool enter = false;//Enterキーが押されたときのフラグ
14
+ 'bool enter = false;//Enterキーが押されたときのフラグ'
11
15
 
12
- [SerializeField] GameObject Player;
16
+ '[SerializeField] GameObject Player;'
13
- PlayerMoob py;
17
+ 'PlayerMoob py;'
14
18
 
15
- int count;
19
+ 'int count;'
16
- public void setCount(int a) { count = a; }
20
+ 'public void setCount(int a) { count = a; }'
17
21
 
18
22
  // Start is called before the first frame update
19
23
  void Start()
20
24
  {
21
- enter = false;
25
+ 'enter = false;'
22
- Player = GameObject.Find("Player");
26
+ 'Player = GameObject.Find("Player");'
23
- py = Player.GetComponent<PlayerMoob>();
27
+ 'py = Player.GetComponent<PlayerMoob>();'
24
- count = 1;
28
+ 'count = 1;'
25
- CountObj = GameObject.Find("CountObj");
29
+ 'CountObj = GameObject.Find("CountObj");'
26
30
  }
27
31
 
28
32
  // Update is called once per frame
29
33
  void Update()
30
34
  {
31
- START();
35
+ 'START();'
32
- if (enter == true)
36
+ 'if (enter == true)'
33
- {
37
+ '{
34
- totalTime -= Time.deltaTime;
38
+ 'totalTime -= Time.deltaTime;'
35
- seconds = (int)totalTime;
39
+ 'seconds = (int)totalTime;'
36
- Text.text = seconds.ToString();
40
+ 'Text.text = seconds.ToString();'
37
- CountObj.SetActive(true);
41
+ 'CountObj.SetActive(true);'
38
- //マイナス値にならないように
42
+ '//マイナス値にならないように'
39
- totalTime = Mathf.Max(totalTime, 1);
43
+ 'totalTime = Mathf.Max(totalTime, 1);'
40
- if (totalTime == 1)
44
+ 'if (totalTime == 1)'
41
- {
45
+ '{
42
- Text.text = "GO!!";
46
+ 'Text.text = "GO!!";'
43
- py.setMoob(1);
47
+ 'py.setMoob(1);'
44
- Invoke("FALSE",0.7f);
48
+ 'Invoke("FALSE",0.7f);'
45
49
 
46
- }
50
+ }'
47
- }
51
+ }'
48
- enter = false;
52
+ 'enter = false;'
49
53
 
50
54
  }
51
55
 
52
56
  void START()
53
57
  {
54
58
 
55
- if (count == 0)
59
+ ' if (count == 0)
56
- {
60
+ '{
57
- enter = true;
61
+ 'enter = true;'
58
- }
62
+ }'
59
- }
63
+ }'
60
64
 
61
65
  void FALSE()
62
- {
66
+ '{
63
- CountObj.SetActive(false);
67
+ 'CountObj.SetActive(false);'
64
- totalTime = 4;
68
+ 'totalTime = 4;'
65
- START();
69
+ 'START();'
66
70
 
67
- }
71
+ }'
68
- }
72
+ }'
69
73
 
74
+ 上記はカウントダウンに用いるスクリプトです。
75
+ CountObjには適用しています。
70
- 現在作成中ゲームで技を四回披露しようと思っているんですけど、一回目普通にカウントダウンが進むんです
76
+ 上記変数の値0でカウントダウンが始まり、1カウントダウンの表示をoffにしていま
71
- 二回目以降がうまいこと進まいのご教授をお願ます。
77
+ 1から0に変更どはきています。
78
+
72
79
  public class FlipScript : MonoBehaviour
73
80
  {
74
- [SerializeField] GameObject Scoreboard;
81
+ '[SerializeField] GameObject Scoreboard;'
75
- ScoreManager smr;
82
+ 'ScoreManager smr;'
76
83
 
77
- [SerializeField] GameObject CountObj;
84
+ '[SerializeField] GameObject CountObj;'
78
- CountDownScript cds;
85
+ 'CountDownScript cds;'
79
86
 
80
- [SerializeField] GameObject Flip;
87
+ '[SerializeField] GameObject Flip;'
81
- [SerializeField] GameObject FenderGulub;
88
+ '[SerializeField] GameObject FenderGulub;'
82
- [SerializeField] GameObject KyanKyan;
89
+ '[SerializeField] GameObject KyanKyan;'
83
90
 
84
- [SerializeField] GameObject NomalStopLine;
91
+ '[SerializeField] GameObject NomalStopLine;'
85
- FrontStopLineScript fsls;
92
+ 'FrontStopLineScript fsls;'
86
93
 
87
94
  // Start is called before the first frame update
88
95
  void Start()
@@ -98,23 +105,24 @@
98
105
 
99
106
  void FlipButton()
100
107
  {
101
- smr = Scoreboard.GetComponent<ScoreManager>();
108
+ 'smr = Scoreboard.GetComponent<ScoreManager>();'
102
- smr.setWaza(2);
109
+ 'smr.setWaza(2);'
103
- cds = CountObj.GetComponent<CountDownScript>();
110
+ 'cds = CountObj.GetComponent<CountDownScript>();'
104
- cds.setCount(0);
111
+ 'cds.setCount(0);'
105
- flip();
112
+ 'flip();'
106
- Flip.SetActive(false);
113
+ 'Flip.SetActive(false);'
107
- FenderGulub.SetActive(false);
114
+ 'FenderGulub.SetActive(false);'
108
- KyanKyan.SetActive(false);
115
+ 'KyanKyan.SetActive(false);'
109
116
 
110
117
  }
111
118
 
112
119
  void flip()
113
120
  {
114
- fsls = NomalStopLine.GetComponent<FrontStopLineScript>();
121
+ 'fsls = NomalStopLine.GetComponent<FrontStopLineScript>();'
115
- fsls.setCom(2);
122
+ 'fsls.setCom(2);'
116
123
  }
117
124
 
118
125
  }
119
126
 
120
- 値を渡して、カウンダウンを再びようとしるスクリプトが上記です。
127
+ 上記のスクリプはボタンをEnterキーを押して選択す技のスクリプトです。
128
+ setCount(0)がカウントダウンに使う変数の値です。