Guest User

Untitled

a guest
Apr 30th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. protected int _sceneTask;
  2. public GameObject prefab = null;
  3. public GameObject[,] mass = new GameObject[15,15];
  4. int isk;
  5. int jsk;
  6. // Use this for initialization
  7. void Start () {
  8. // 配置元のオブジェクト指定
  9. GameObject stageObject = GameObject.FindWithTag("Stage");
  10. //// タイル配置
  11. for(int i = 0; i < 15 ; i ++) {
  12. for(int j = 0; j < 15 ; j ++) {
  13.  
  14.  
  15. Vector3 tile_pos = new Vector3(
  16. 0 + prefab.transform.localScale.x * i,
  17. 0,
  18. 0 + prefab.transform.localScale.z * j
  19.  
  20. );
  21.  
  22. if(prefab != null){
  23. // プレハブの複製
  24. GameObject instant_object = Instantiate(prefab,tile_pos, Quaternion.identity) as GameObject;
  25. // 生成元の下に複製したプレハブをくっつける
  26. instant_object.transform.parent = stageObject.transform;
  27. mass[i,j] = instant_object;
  28. }
  29. }
  30. }
  31. int Ivent = Random.Range(4, 7);//ランダムにイベントマスの設置
  32. for(int p = 0; p < Ivent;p++){
  33. int iRandNum = Random.Range(0, 14);
  34. int jRandNum = Random.Range(0, 14);
  35. mass[iRandNum,jRandNum].GetComponent<Renderer>().material.color = new Color(0.2f, 0.8f, 0.9f, 0.5f);
  36. }
  37. }
  38.  
  39.  
  40. // Update is called once per frame
  41.  
  42. void Update(){
  43.  
  44. mass[5,5].GetComponent<Renderer>().material.color = new Color(0.0f, 0.0f, 0.0f, 0.0f);
  45. Debug.Log ("黒くなるはずのマス[5,5]の色は"+mass [5, 5].GetComponent<Renderer> ().material.color);
  46. mass[1,5].GetComponent<Renderer> ().material.color = new Color (0.2f, 0.8f, 0.9f, 0.5f);
  47. Debug.Log ("青になるはずのマス[1,5]の色は"+mass [1, 5].GetComponent<Renderer> ().material.color);
  48. }
Add Comment
Please, Sign In to add comment