コード例 #1
0
ファイル: InitializeDungeon.cs プロジェクト: framg/Dungeon2D
    void Start()
    {
        stoneBlock =  UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Prefabs/Blocks/Stone.prefab", typeof(GameObject));
        background = GameObject.Find ("Background");
        player = GameObject.Find ("Player");
        mainCamera = GameObject.Find ("Main Camera").GetComponent<Camera> ();
        actVector = new List <GameObject> ();
        dungeon = new Matrix ();
        dungeon.createMatrix ();
        actualBlock = 0;
        lastBlock = 0;

        for (int i=0; i<15; i++) {
            List<int> l = dungeon.createNewRow ();
            dungeon.addRow(l);
        }

        for (int i=0; i< dungeon.size (); i++) {
            List<int> l = dungeon.getRow(i);
            for(int y=0; y<l.Count; y++){
                if(l[y] == 1){
                    GameObject block = GameObject.Instantiate( stoneBlock ) as GameObject;
                    block.transform.position = new Vector3(lastBlock, y, 0);
                }
            }
            lastBlock++;
        }
    }