コード例 #1
0
    IEnumerator ReadConfigFile(string filename)
    {
        //GameConst.GetStoryLevelFilePath(mapid+".lmd")
        string filepath;//= GameConst.GetConfigFilePath(filename);

        filepath = GameConst.GetLevelDataFilePath2(filename);
        Debug.Log(filepath);

        filepath += ".lmd";
        WWW www = new WWW(filepath);

        yield return(www);

        while (www.isDone == false)
        {
            yield return(null);
        }
        if (www.error == null)
        {
            byte[]     gzipdata   = www.bytes;
            byte[]     levelData  = GameCommon.UnGZip(gzipdata);
            DataStream datastream = new DataStream(levelData, true);
            md.Deserialize(datastream);
            InitGame();
        }
        else
        {
            //GameLogTools.SetText("wwwError<<" + www.error + "<<" + filepath);
            Debug.Log("wwwError<<" + www.error + "<<" + filepath);
            (new EventChangeScene(GameSceneManager.SceneTag.Menu)).Send();
        }
    }
コード例 #2
0
ファイル: GameCommon.cs プロジェクト: LiuFeng1011/DotaDiablo
    public static void GZipTest()
    {
        string testdata = "aaaa11233GZip压缩和解压";

        byte[] gzipdata = GameCommon.CompressGZip(Encoding.UTF8.GetBytes(testdata));
        byte[] undata   = GameCommon.UnGZip(gzipdata);

        Debuger.Log("[GZipTest]  : data" + Encoding.UTF8.GetString(undata));
    }
コード例 #3
0
ファイル: MELoadLevelData.cs プロジェクト: LiuFeng1011/DragOn
    public void LoadLevel(string fileName)
    {
        byte[]     levelGzipData = GameCommon.ReadByteToFile(GameConst.GetLevelDataFilePath(fileName + ".lmd"));
        byte[]     levelData     = GameCommon.UnGZip(levelGzipData);
        DataStream datastream    = new DataStream(levelData, true);

        ReloadScene(datastream);
        Closeed();
    }
コード例 #4
0
ファイル: UserDataManager.cs プロジェクト: LiuFeng1011/Diablo
    //======================================================

    public void LoadData(BaseUserData userdata, UserDataType type)
    {
        string dataname = type + "";
        string filepath = GameConst.GetPersistentDataPath(dataname);

        byte[] gzipdata = GameCommon.ReadByteToFile(filepath);

        if (gzipdata == null)
        {
        }
        else
        {
            byte[]     data       = GameCommon.UnGZip(gzipdata);
            DataStream datastream = new DataStream(data, true);

            userdata.Deserialize(datastream);
        }
    }
コード例 #5
0
ファイル: ConfigManager.cs プロジェクト: LiuFeng1011/Diablo
    public static List <T> Load <T>() where T : new()
    {
        string[] names = (typeof(T)).ToString().Split('.');

        string filename = names[names.Length - 1];

        TextAsset text = Resources.Load(GameConst.GetConfigPath() + filename) as TextAsset;

        byte[] data = GameCommon.UnGZip(text.bytes);

        List <object> datalist = (List <object>)GameCommon.DeserializeObject(data);

        List <T> list = new List <T>();

        for (int i = 0; i < datalist.Count; i++)
        {
            list.Add((T)datalist[i]);
        }

        return(list);
    }
コード例 #6
0
    //======================================================

    public void LoadData()
    {
        string filepath = GameConst.GetPersistentDataPath(GameConst.userDataFileName);

        byte[] gzipdata = GameCommon.ReadByteToFile(filepath);

        UserDataMode userdata;

        if (gzipdata == null)
        {
            userdata = new UserDataMode();

            CopyData(userdata);
            SaveData();
        }
        else
        {
            byte[] data = GameCommon.UnGZip(gzipdata);
            userdata = (UserDataMode)GameCommon.DeserializeObject(data);

            CopyData(userdata);
        }
    }
コード例 #7
0
ファイル: MazeMapManager.cs プロジェクト: LiuFeng1011/Diablo
    protected void InsertGroup(Vector2 pos, int groupid)
    {
        Debug.Log(groupid);
        int          x = (int)pos.x, y = (int)pos.y;
        MapGroupConf conf = ConfigManager.mapGroupConfManager.dataMap[groupid];

        if (conf == null)
        {
            return;
        }
        TextAsset text = Resources.Load(conf.path) as TextAsset;

        byte[]     data       = GameCommon.UnGZip(text.bytes);
        DataStream datastream = new DataStream(data, true);

        //配置LevelOption
        GameObject logo = new GameObject(conf.path);

        //logo.transform.parent = this.mapObj.transform;
        logo.transform.position = GameCommon.GetWorldPos(pos);
        LevelOption me = logo.AddComponent <LevelOption>();

        me.deserialize(datastream);

        //生成物体
        int objcount = datastream.ReadSInt32();

        for (int i = 0; i < objcount; i++)
        {
            //MSBaseObject.CreateObj(datastream);
            //从字节流中获取id
            //int confid = datastream.ReadSInt32();
            //float objx = datastream.ReadSInt32() / 1000f;
            //float objy = datastream.ReadSInt32() / 1000f;
            int        confid = 0;
            float      objx = 0, objy = 0, objsx = 0, objsy = 0;
            MapObjConf objconf = null;
            GameObject column  = null;
            int        dataid  = datastream.ReadByte();
            string     goname  = "";
            while (dataid != 0)
            {
                switch (dataid)
                {
                case 1:
                    confid  = datastream.ReadSInt32();
                    objconf = ConfigManager.mapObjConfManager.map[confid];
                    break;

                case 2: objx = datastream.ReadSInt32() / 1000f; break;

                case 3: objy = datastream.ReadSInt32() / 1000f; break;

                case 4:
                    int parentid = datastream.ReadSInt32();
                    break;

                case 5:
                    int instanceid = datastream.ReadSInt32();
                    break;

                case 7: goname = datastream.ReadString16(); break;

                case 8:
                    objsx = datastream.ReadSInt32() / 1000f;
                    break;

                case 9:
                    objsy = datastream.ReadSInt32() / 1000f;
                    break;

                case 6:
                    if (objconf.isstatic == 1)
                    {
                        column = (GameObject)Resources.Load(objconf.path);
                        column = MonoBehaviour.Instantiate(column);
                        column.transform.parent   = mapObj.transform;
                        column.transform.position = GameCommon.GetWorldPos(pos) + new Vector2(objx, objy);
                        InGameBaseObj point = column.GetComponent <InGameBaseObj>();
                        point.Deserialize(datastream);
                        GameCommon.SetObjZIndex(column, objconf.depth);
                    }

                    break;
                }
                dataid = datastream.ReadByte();
            }

            if (confid == 4000002)
            {
                startPointList.Add(pos + GameCommon.GetMapPos(new Vector2(objx, objy)));
                continue;
            }
            if (objconf.isstatic == 1)
            {
                SetWayProperty(pos + GameCommon.GetMapPos(new Vector2(objx, objy)), objconf);
                column.transform.localScale = new Vector3(objsx, objsy, 1);
                continue;
            }

            SetGroupPoint(pos + GameCommon.GetMapPos(new Vector2(objx, objy)), objconf, new Vector3(objsx, objsy, 1));
        }
    }