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

回答編集履歴

3

書式の改善

2016/10/29 11:20

投稿

退会済みユーザー
answer CHANGED
@@ -27,12 +27,12 @@
27
27
 
28
28
  void LocalInstantate() {
29
29
  // ランダムでインデックスを選択
30
- var _customerIndex = Random.Range(0, nonExistence.Count);
30
+ int _customerIndex = Random.Range(0, nonExistence.Count);
31
31
 
32
32
  // 存在しないキャラクターのリストのインデックスから
33
33
  // キャラクターの種類を選択してインスタンス化
34
- var _customerNum = nonExistence[_customerIndex];
34
+ int _customerNum = nonExistence[_customerIndex];
35
- var obj = (GameObject) Instantiate(characters[_customerNum]);
35
+ GameObject obj = (GameObject) Instantiate(characters[_customerNum]);
36
36
  obj.transform.parent = transform;
37
37
  obj.transform.localPosition = new Vector3(-3.35f, -1.44f, 0);
38
38
 
@@ -71,7 +71,7 @@
71
71
  public int customerNum;
72
72
 
73
73
  void LeaveStore(){
74
- var _customerInStore = transform.parent.GetComponent<CustomerInStore>();
74
+ CustomerInStore _customerInStore = transform.parent.GetComponent<CustomerInStore>();
75
75
  _customerInStore.AddNonExistenceList(customerNum);
76
76
  Destroy(gameObject);
77
77
  }

2

修正が反映されてないため、再送信

2016/10/29 11:20

投稿

退会済みユーザー
answer CHANGED
File without changes

1

文法の修正

2016/10/29 10:48

投稿

退会済みユーザー
answer CHANGED
@@ -58,7 +58,8 @@
58
58
  // キャラクターの生成までの時間
59
59
  if (nextSpawnTime < Time.timeSinceLevelLoad && isCanComeCustomer == true) {
60
60
  nextSpawnTime = Time.timeSinceLevelLoad + interval;
61
+ // リストの要素数が0より大きいときにのみ実行する
61
- LocalInstantate();
62
+ if(0 < nonExistence.Count) LocalInstantate();
62
63
  }
63
64
  }
64
65
  }