質問編集履歴
8
画像の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
Scriptについてもですが、そもそもの構成要素などにも不安を抱えています。
|
6
6
|
まずは実装までの考え方を「文字で」理解したいです。
|
7
7
|
最終地点は、ゲーム内通貨を消費してアイテムを購入するシステムの構築です。
|
8
|
+
まさに以下の画像のようなイメージです。
|
9
|
+

|
8
10
|
|
9
11
|
### 現状
|
10
12
|
UIのButton機能を使って配置・装飾(画像の挿入など)止まり
|
@@ -25,10 +27,13 @@
|
|
25
27
|
http://yasuaki-ohama.hatenablog.com/entry/2015/05/16/092032
|
26
28
|
http://yasuaki-ohama.hatenablog.com/entry/2016/07/06/235528
|
27
29
|
|
30
|
+
|
31
|
+
|
32
|
+
|
28
33
|
```C#
|
29
34
|
|
30
35
|
using System.Collections;
|
31
|
-
using
|
36
|
+
using Syollections.Generic;
|
32
37
|
using UnityEngine;
|
33
38
|
using UnityEngine.UI;
|
34
39
|
using System;
|
7
コードブロックの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,13 +25,11 @@
|
|
25
25
|
http://yasuaki-ohama.hatenablog.com/entry/2015/05/16/092032
|
26
26
|
http://yasuaki-ohama.hatenablog.com/entry/2016/07/06/235528
|
27
27
|
|
28
|
-
#
|
28
|
+
```C#
|
29
29
|
|
30
|
-
```
|
31
30
|
using System.Collections;
|
32
31
|
using System.Collections.Generic;
|
33
32
|
using UnityEngine;
|
34
|
-
|
35
33
|
using UnityEngine.UI;
|
36
34
|
using System;
|
37
35
|
|
@@ -238,7 +236,7 @@
|
|
238
236
|
|
239
237
|
|
240
238
|
PlayerPrefs.Save();
|
239
|
+
}
|
241
|
-
|
240
|
+
```
|
242
241
|
|
243
|
-
|
244
242
|
有識者の方、どうぞよろしくお願い致します。
|
6
コードブロック作成
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
5
コードボックス作成
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,8 @@
|
|
26
26
|
http://yasuaki-ohama.hatenablog.com/entry/2016/07/06/235528
|
27
27
|
|
28
28
|
### 現在のScript
|
29
|
+
|
29
|
-
|
30
|
+
```
|
30
31
|
using System.Collections;
|
31
32
|
using System.Collections.Generic;
|
32
33
|
using UnityEngine;
|
@@ -237,7 +238,7 @@
|
|
237
238
|
|
238
239
|
|
239
240
|
PlayerPrefs.Save();
|
240
|
-
}
|
241
|
+
}```
|
241
|
-
'''
|
242
242
|
|
243
|
+
|
243
244
|
有識者の方、どうぞよろしくお願い致します。
|
4
コードブロック作成
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,8 @@
|
|
26
26
|
http://yasuaki-ohama.hatenablog.com/entry/2016/07/06/235528
|
27
27
|
|
28
28
|
### 現在のScript
|
29
|
+
'''
|
29
|
-
|
30
|
+
using System.Collections;
|
30
31
|
using System.Collections.Generic;
|
31
32
|
using UnityEngine;
|
32
33
|
|
@@ -187,13 +188,7 @@
|
|
187
188
|
imageKeeper.GetComponent<KeeperManager>().SetKeeperScale(score, nextScore);
|
188
189
|
SaveGameData();
|
189
190
|
|
190
|
-
|
191
|
+
|
191
|
-
if ((score == nextScore) && (keeperLevel == MAX_LEVEL))
|
192
|
-
{
|
193
|
-
//ClearEffect();
|
194
|
-
}
|
195
|
-
currentOrb--;
|
196
|
-
*/
|
197
192
|
|
198
193
|
}
|
199
194
|
|
@@ -231,13 +226,7 @@
|
|
231
226
|
|
232
227
|
Destroy(trophy, 0.5f);
|
233
228
|
}
|
234
|
-
|
229
|
+
|
235
|
-
/*void ClearEffect()
|
236
|
-
{
|
237
|
-
GameObject ??= (GameObject)Instantiate(??);
|
238
|
-
??.transform.SetParent(canvasGame.transform, false);
|
239
|
-
}*/
|
240
|
-
|
241
230
|
//ゲームデータをセーブ
|
242
231
|
void SaveGameData()
|
243
232
|
{
|
@@ -249,6 +238,6 @@
|
|
249
238
|
|
250
239
|
PlayerPrefs.Save();
|
251
240
|
}
|
241
|
+
'''
|
252
242
|
|
253
|
-
|
254
243
|
有識者の方、どうぞよろしくお願い致します。
|
3
Scriptの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,5 +25,230 @@
|
|
25
25
|
http://yasuaki-ohama.hatenablog.com/entry/2015/05/16/092032
|
26
26
|
http://yasuaki-ohama.hatenablog.com/entry/2016/07/06/235528
|
27
27
|
|
28
|
+
### 現在のScript
|
29
|
+
sing System.Collections;
|
30
|
+
using System.Collections.Generic;
|
31
|
+
using UnityEngine;
|
28
32
|
|
33
|
+
using UnityEngine.UI;
|
34
|
+
using System;
|
35
|
+
|
36
|
+
public class GameManager : MonoBehaviour {
|
37
|
+
|
38
|
+
//定数定義
|
39
|
+
private const int MAX_ORB = 5000; //オーブ最大数
|
40
|
+
private const int RESPAWN_TIME = 15; //オーブが発生する秒数
|
41
|
+
private const int MAX_LEVEL = 5; //最大キーパーレベル
|
42
|
+
|
43
|
+
//データセーブ用キー
|
44
|
+
private const string KEY_SCORE = "SCORE"; //スコア
|
45
|
+
private const string KEY_LEVEL = "LEVEL"; //レベル
|
46
|
+
private const string KEY_ORB = "ORB"; //オーブ数
|
47
|
+
private const string KEY_TIME = "TIME"; //時間
|
48
|
+
|
49
|
+
//オブジェクト参照
|
50
|
+
public GameObject orbPrefab; //オーブプレハブ
|
51
|
+
public GameObject trophyPrefab; //トロフィープレハブ
|
52
|
+
public GameObject canvasGame; //ゲームキャンバス
|
53
|
+
public GameObject textScore; //スコアテキスト
|
54
|
+
public GameObject imageKeeper; //キーパー
|
55
|
+
public float clickrate = 0.5f;
|
56
|
+
public GameObject ball;
|
57
|
+
|
58
|
+
//メンバ変数
|
59
|
+
private int score = 0; //現在のスコア
|
60
|
+
private int nextScore = 400; //レベルアップまでに必要なスコア
|
61
|
+
|
62
|
+
private int currentOrb = 0; //現在のオーブ数
|
63
|
+
|
64
|
+
private int keeperLevel = 0; //キーパーのレベル
|
65
|
+
|
66
|
+
private DateTime lastDateTime; //前回オーブを生成した瞬間
|
67
|
+
|
68
|
+
private int[] nextScoreTable = new int[] { 100,200,300,400,500 }; //レベルアップ値
|
69
|
+
|
70
|
+
private int numOfOrb; //まとめて生成するオーブの数
|
71
|
+
|
72
|
+
// Use this for initialization
|
73
|
+
void Start () {
|
74
|
+
|
75
|
+
//データ削除メソッド
|
76
|
+
//PlayerPrefs.DeleteAll();
|
77
|
+
|
78
|
+
//初期設定
|
79
|
+
score = PlayerPrefs.GetInt(KEY_SCORE, 0);
|
80
|
+
keeperLevel = PlayerPrefs.GetInt(KEY_LEVEL, 0);
|
81
|
+
|
82
|
+
nextScore = nextScoreTable[keeperLevel];
|
83
|
+
imageKeeper.GetComponent<KeeperManager>().SetKeeperPicture(keeperLevel);
|
84
|
+
imageKeeper.GetComponent<KeeperManager>().SetKeeperScale(score, nextScore);
|
85
|
+
|
86
|
+
RefreshScoreText();
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
// Update is called once per frame
|
91
|
+
void Update () {
|
92
|
+
//まとめて生成するオーブがあれば生成
|
93
|
+
while (numOfOrb > 0)
|
94
|
+
{
|
95
|
+
Invoke("CreateNewOrb",0.1f*numOfOrb);
|
96
|
+
numOfOrb--;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
//バックグラウンドへの移行時と復帰時(アプリ起動時も含む)に呼び出される
|
101
|
+
|
102
|
+
private void OnApplicationPause(bool pauseStatus)
|
103
|
+
{
|
104
|
+
if (pauseStatus)
|
105
|
+
{
|
106
|
+
//アプリがバックグラウンドへ移行
|
107
|
+
}
|
108
|
+
else
|
109
|
+
{
|
110
|
+
//バックグラウンドから復帰
|
111
|
+
//時間の復元
|
112
|
+
string time = PlayerPrefs.GetString(KEY_TIME, "");
|
113
|
+
if (time == "")
|
114
|
+
{
|
115
|
+
lastDateTime = DateTime.UtcNow;
|
116
|
+
}
|
117
|
+
else
|
118
|
+
{
|
119
|
+
long temp = Convert.ToInt64(time);
|
120
|
+
lastDateTime = DateTime.FromBinary(temp);
|
121
|
+
}
|
122
|
+
|
123
|
+
numOfOrb = 0;
|
124
|
+
//時間によるオーブ自動生成
|
125
|
+
TimeSpan timeSpan = DateTime.UtcNow - lastDateTime;
|
126
|
+
if (timeSpan >= TimeSpan.FromSeconds(RESPAWN_TIME))
|
127
|
+
{
|
128
|
+
while (timeSpan >= TimeSpan.FromSeconds(RESPAWN_TIME))
|
129
|
+
{
|
130
|
+
if (numOfOrb < MAX_ORB)
|
131
|
+
{
|
132
|
+
numOfOrb++;
|
133
|
+
}
|
134
|
+
timeSpan -= TimeSpan.FromSeconds(RESPAWN_TIME);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
//新しいオーブの生成
|
141
|
+
public void CreateNewOrb()
|
142
|
+
{
|
143
|
+
lastDateTime = DateTime.UtcNow;
|
144
|
+
if (currentOrb >= MAX_ORB)
|
145
|
+
{
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
CreateOrb();
|
149
|
+
currentOrb++;
|
150
|
+
|
151
|
+
SaveGameData();
|
152
|
+
}
|
153
|
+
|
154
|
+
//オーブ生成
|
155
|
+
public void CreateOrb()
|
156
|
+
{
|
157
|
+
GameObject orb = (GameObject)Instantiate(orbPrefab);
|
158
|
+
orb.transform.SetParent(canvasGame.transform, false);
|
159
|
+
orb.transform.localPosition = new Vector3(
|
160
|
+
UnityEngine.Random.Range (-100.0f, 100.0f),
|
161
|
+
UnityEngine.Random.Range (-300.0f, -450.0f),
|
162
|
+
0f);
|
163
|
+
|
164
|
+
orb.GetComponent<OrbManager>().Flyorb();
|
165
|
+
|
166
|
+
//ボールアニメーション
|
167
|
+
StartCoroutine("ClickAnim");//"ClickAnim"のコルーチンを呼ぶ.
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
//オーブ入手
|
174
|
+
public void GetOrb()
|
175
|
+
{
|
176
|
+
score += 1;
|
177
|
+
//キーパー画像切り替えメソッド挿入予定
|
178
|
+
|
179
|
+
//レベルアップ値を超えないように制限
|
180
|
+
if (score > nextScore)
|
181
|
+
{
|
182
|
+
score = nextScore;
|
183
|
+
}
|
184
|
+
|
185
|
+
KeeperLevelUp();
|
186
|
+
RefreshScoreText();
|
187
|
+
imageKeeper.GetComponent<KeeperManager>().SetKeeperScale(score, nextScore);
|
188
|
+
SaveGameData();
|
189
|
+
|
190
|
+
/*//ゲームクリア判定
|
191
|
+
if ((score == nextScore) && (keeperLevel == MAX_LEVEL))
|
192
|
+
{
|
193
|
+
//ClearEffect();
|
194
|
+
}
|
195
|
+
currentOrb--;
|
196
|
+
*/
|
197
|
+
|
198
|
+
}
|
199
|
+
|
200
|
+
//スコアテキスト更新
|
201
|
+
void RefreshScoreText()
|
202
|
+
{
|
203
|
+
textScore.GetComponent<Text>().text =
|
204
|
+
score + "GOAL";
|
205
|
+
}
|
206
|
+
|
207
|
+
//キーパーのレベル管理
|
208
|
+
void KeeperLevelUp()
|
209
|
+
{
|
210
|
+
if (score >= nextScore)
|
211
|
+
{
|
212
|
+
if (keeperLevel < MAX_LEVEL)
|
213
|
+
{
|
214
|
+
keeperLevel++;
|
215
|
+
score = 0;
|
216
|
+
|
217
|
+
KeeperLevelUpEffect();
|
218
|
+
|
219
|
+
nextScore = nextScoreTable[keeperLevel];
|
220
|
+
imageKeeper.GetComponent<KeeperManager>().SetKeeperPicture(keeperLevel);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
//レベルアップ時の演出
|
226
|
+
void KeeperLevelUpEffect()
|
227
|
+
{
|
228
|
+
GameObject trophy = (GameObject)Instantiate(trophyPrefab);
|
229
|
+
trophy.transform.SetParent(canvasGame.transform, false);
|
230
|
+
trophy.transform.SetSiblingIndex(5);
|
231
|
+
|
232
|
+
Destroy(trophy, 0.5f);
|
233
|
+
}
|
234
|
+
//寺が最高レベル
|
235
|
+
/*void ClearEffect()
|
236
|
+
{
|
237
|
+
GameObject ??= (GameObject)Instantiate(??);
|
238
|
+
??.transform.SetParent(canvasGame.transform, false);
|
239
|
+
}*/
|
240
|
+
|
241
|
+
//ゲームデータをセーブ
|
242
|
+
void SaveGameData()
|
243
|
+
{
|
244
|
+
PlayerPrefs.SetInt(KEY_SCORE, score);
|
245
|
+
PlayerPrefs.SetInt(KEY_LEVEL,keeperLevel);
|
246
|
+
PlayerPrefs.SetInt(KEY_ORB,currentOrb);
|
247
|
+
PlayerPrefs.SetString(KEY_TIME,lastDateTime.ToBinary().ToString());
|
248
|
+
|
249
|
+
|
250
|
+
PlayerPrefs.Save();
|
251
|
+
}
|
252
|
+
|
253
|
+
|
29
254
|
有識者の方、どうぞよろしくお願い致します。
|
2
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
クリックによるスコアの上昇などの機能は出来たのですが、アイテムショップの機能を追加することに苦戦しています。
|
5
5
|
Scriptについてもですが、そもそもの構成要素などにも不安を抱えています。
|
6
6
|
まずは実装までの考え方を「文字で」理解したいです。
|
7
|
+
最終地点は、ゲーム内通貨を消費してアイテムを購入するシステムの構築です。
|
7
8
|
|
8
9
|
### 現状
|
9
10
|
UIのButton機能を使って配置・装飾(画像の挿入など)止まり
|
@@ -15,6 +16,7 @@
|
|
15
16
|
|
16
17
|
### 仕様
|
17
18
|
・アイテムは大きく分けて2種類(1クリック当たりの生産を増やす物、自動生成ぺースを高める物)
|
19
|
+
・ゲーム内で生産したゲーム内通貨を消費してアイテムを購入
|
18
20
|
・レベルマックス、アンロックはグレーアウト
|
19
21
|
・アイテム購入の際は「購入しますか?はいorいいえ」のようなシーンは設けず、クリック後すぐに購入・実装
|
20
22
|
|
1
初心者マークの追加
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|