コード例 #1
0
    public bool LoadWM3(TextAsset level)
    {
        Debug.Log("Wm3Loader: Loading <" + level.name + "> ...");

        bool ret = false;

        if (level)
        {
            m_data = new Wm3Data();
            Stream stream = new MemoryStream(level.bytes);
            m_br = new BinaryReader(stream);

            ret = ReadHeader();
            if (ret)
            {
                ret = ReadBitmaps();
            }
            if (ret)
            {
                ret = ReadModels();
            }
            if (ret)
            {
                ret = ReadTextures();
            }
            if (ret)
            {
                ret = ReadMeshes();
            }
            if (ret)
            {
                ret = ReadObjects();
            }

            m_br.Close();

            if (ret)
            {
                ret = m_data.Link();
            }
        }
        Debug.Log("Wm3Loader: Finished.");

        return(ret);
    }
コード例 #2
0
ファイル: LevelBuilder.cs プロジェクト: firoball/Wm3Util
    public bool Construct(Wm3Data data)
    {
        Initialize();
        if (data == null)
        {
            return(false);
        }

        //TODO: move somewhere to Wm3Import
        if (!CreateAndClearFolder())
        {
            return(false);
        }

        //MESHES
        GameObject level = new GameObject("Wm3Level");

        foreach (Wm3Mesh wm3Mesh in data.Meshes)
        {
            GameObject obj;
            if (MeshBuilder.Build(wm3Mesh, m_textureManager, out obj))
            {
                obj.transform.SetParent(level.transform);
            }
        }

        //OBJECTS
        GameObject objects = new GameObject("Wm3Objects");

        foreach (Wm3Object wm3Object in data.Objects)
        {
            GameObject obj;
            if (ObjectBuilder.Build(wm3Object, m_textureManager, out obj))
            {
                obj.transform.SetParent(objects.transform);
            }
        }

        m_textureManager.Report();

        return(true);
    }