Esempio n. 1
0
    // サブウィンドウの初期化
    public void init()
    {
        mapSize  = parent.MapSize;
        gridSize = parent.GridSize;

        // マップデータを初期化
        terramap = new Terra[mapSize, mapSize];
        objmap   = new MovingObject[mapSize, mapSize];
        for (int i = 0; i < mapSize; i++)
        {
            for (int j = 0; j < mapSize; j++)
            {
                terramap[i, j] = Terra.NONE;
                objmap[i, j]   = MovingObject.NONE;
            }
        }
        // グリッドデータを生成
        gridRect = CreateGrid(mapSize);
        if (parent.LoadTerra != null)
        {
            string path = AssetDatabase.GetAssetPath(parent.LoadTerra);
            path     = path.Remove(0, 6);
            terramap = CSVDataReader.DataToTerra(CSVDataReader.readCSVData(path));
        }
        if (parent.LoadObj != null)
        {
            string path = AssetDatabase.GetAssetPath(parent.LoadObj);
            path   = path.Remove(0, 6);
            objmap = CSVDataReader.DataToObj(CSVDataReader.readCSVData(path));
        }
    }
Esempio n. 2
0
    void generate(int stagenumber)
    {
        GameObject tile;

        Terra[,] terramap      = CSVDataReader.DataToTerra(CSVDataReader.readCSVData("/Map/" + mapname + stagenumber + "_terra.csv"));
        MovingObject[,] objmap = CSVDataReader.DataToObj(CSVDataReader.readCSVData("/Map/" + mapname + stagenumber + "_obj.csv"));
        Debug.Log(terramap[0, 0]);
        for (int i = 0; i < terramap.GetLength(0); i++)
        {
            for (int j = 0; j < terramap.GetLength(1); j++)
            {
                if (terraTile[(int)terramap[i, j]] != null)
                {
                    tile = (GameObject)Instantiate(terraTile[(int)terramap[i, j]], new Vector3(j, -i, 0), Quaternion.identity);
                    tile.transform.parent = tileParent.transform;
                }
            }
        }
        for (int i = 0; i < objmap.GetLength(0); i++)
        {
            for (int j = 0; j < objmap.GetLength(1); j++)
            {
                if (terraTile[(int)objmap[i, j]] != null)
                {
                    tile = (GameObject)Instantiate(objTile[(int)objmap[i, j]], new Vector3(j, -i, 0), Quaternion.identity);
                    tile.transform.parent = tileParent.transform;
                }
            }
        }
    }