public Vector3 downVec = new Vector3(0, 0, -1); // Height public void Init() { try { string content = string.Empty; if (readMapFromPath) { content = ConfigParser.GetFileContent(configFilePath); } else { content = mapContent; } int[,] map = ConfigParser.GetIntArrayFromString(content, mapLength, mapHeight); if (originPoint == null) { GameObject originObject = new GameObject("origin"); originPoint = originObject.transform; originPoint.position = Vector3.zero; } if (createFloorByProgram) { SpaceCreate(); } for (int i = 0; i < mapHeight; i++) { for (int j = 0; j < mapLength; j++) { if (map[i, j] == 0) { continue; } GameObject obj = Instantiate(prefabIndexCorrespond[map[i, j]]); obj.transform.position = originPoint.position + eachLength * rightVec * (j + 0.5f) + eachHeight * downVec * (i + 0.5f); switch (map[i, j]) { case 2: obj.transform.localScale = new Vector3(eachLength, 3.0f, eachHeight); break; case 3: //obj.GetComponent<Oil>().Init(eachLength, eachHeight); break; case 7: //SceneManager.Instance().playerObject = obj; SceneManager.Instance().player = obj.GetComponent <Player>(); break; case 8: SceneManager.Instance().exitPoint = obj; break; default: break; } } } } catch (System.Exception e) { print("地图文件读取错误: " + e); } }