示例#1
0
        public void LoadGame()
        {
            using (ES2Reader reader = ES2Reader.Create("player"))
            {
                PlayerInfo.Instance.Data.Level.Value      = reader.Read <int>("dengji");
                PlayerInfo.Instance.Data.Gold.Value       = reader.Read <int>("jinbi");
                PlayerInfo.Instance.Data.Experience.Value = reader.Read <int>("jingyan");
                PlayerInfo.Instance.Data.Life.Value       = reader.Read <int>("shengming");
                PlayerInfo.Instance.Data.Attack.Value     = reader.Read <int>("gongji");
                PlayerInfo.Instance.Data.Defence.Value    = reader.Read <int>("fangyu");
                PlayerInfo.Instance.Data.KeyYellow.Value  = reader.Read <int>("key_yellow");
                PlayerInfo.Instance.Data.KeyBlue.Value    = reader.Read <int>("key_blue");
                PlayerInfo.Instance.Data.KeyRed.Value     = reader.Read <int>("key_red");
                PlayerInfo.Instance.Data.HandBook.Value   = reader.Read <bool>("daoju_tujian");
                PlayerInfo.Instance.Data.Fly.Value        = reader.Read <bool>("daoju_feixing");
                GM.MaxFloor.Value = reader.Read <int>("maxFloor");
                Dialoguer.SetGlobalBoolean(0, reader.Read <bool>("hasJinglingTalked"));
                Dialoguer.SetGlobalBoolean(1, reader.Read <bool>("hasDaozeiTalked"));
                Dialoguer.SetGlobalBoolean(2, reader.Read <bool>("hasGoodJian"));
                Dialoguer.SetGlobalBoolean(3, reader.Read <bool>("hasGoodDun"));
                Dialoguer.SetGlobalBoolean(4, reader.Read <bool>("hasGangJian"));
                Dialoguer.SetGlobalBoolean(5, reader.Read <bool>("hasGangDun"));
            }
#if UNITY_WP8
            for (int i = 0; i < GM.MaxFloor + 1; i++)
            {
                GM.floorGO[i].SetActive(true);
                using (ES2Reader reader = ES2Reader.Create("floor" + i))
                {
                    TileSystem ts_object = GameObject.Find("Floor" + i).gameObject.GetComponent <TileSystem>();
                    for (int x = 0; x < 11; x++)
                    {
                        for (int y = 0; y < 11; y++)
                        {
                            int hasTile = reader.Read <int>(x + "v" + y);
                            if (sceneData[i] == null)
                            {
                                sceneData[i] = new int[11, 11];
                            }
                            sceneData[i][x, y] = hasTile;
                            if (sceneData[i][x, y] != null && sceneData[i][x, y] == 1)
                            {
                                TileData tile = ts_object.GetTile(x, y);
                                if (tile != null)
                                {
                                    GameObject.Destroy(tile.gameObject);
                                    tile.Clear();
                                }
                            }
                        }
                    }
                }
                GM.floorGO[i].SetActive(false);
            }
#else
            for (int i = 0; i < GM.MaxFloor.Value + 1; i++)
            {
                GM.floorGO[i].SetActive(true);
                sceneData[i] = ES2.Load2DArray <int>("floor" + i);
                TileSystem ts_object = GameObject.Find("Floor" + i).gameObject.GetComponent <TileSystem>();
                for (int x = 0; x < 11; x++)
                {
                    for (int y = 0; y < 11; y++)
                    {
                        if (sceneData[i][x, y] == 1)
                        {
                            TileData tile = ts_object.GetTile(x, y);
                            if (tile != null)
                            {
                                GameObject.Destroy(tile.gameObject);
                                tile.Clear();
                            }
                        }
                    }
                }
                GM.floorGO[i].SetActive(false);
            }
#endif
            GM.floorGO[0].SetActive(true);
            DM.state = "";
            PlayerPrefs.DeleteKey("loadgame");
            DM.tipContent = "读取成功";
            DM.tipTime    = 3;
        }