public OtherSaveDate GetOtherSaveDateByName(string cGKDateName = "OTHER") { // _fileName = Application.persistentDataPath + "/" + _fileName; string str = Application.persistentDataPath + "/" + cGKDateName; Debug.Log("ot 取other数据路径 " + str); //if(Globals.isDebug)Debug.Log(str); try { string strTemp = LoadTextFile(str, false); //反序列化对象 OtherSaveDate userD = DeserializeObject(strTemp, typeof(OtherSaveDate)) as OtherSaveDate; if (Globals.isDebug) { Debug.Log(" ot 取到other数据 " + userD); } return(userD); } catch { if (Globals.isDebug) { Debug.Log("系统读取 地图 XML出现错误,请检查"); } } return(null); }
//public GameObject player; void InNewGame(string pos = "-120.47_-3.14", string scrName = "ng1_o-1") { if (CurrentUserDate == null) { CurrentUserDate = new UserDate(); } if (CurrentMapMsgDate == null) { CurrentMapMsgDate = new UserDate(); } playerPosition = pos; screenName = scrName; cameraPosition = ""; bagDate = ""; //背包数据 mapDate = ""; //小地图数据 xp_nums = 0; //血瓶数量 CurrentUserDate.screenName = SceneManager.GetActiveScene().name; CurrentUserDate.playerPosition = playerPosition; CurrentUserDate.cameraPosition = playerPosition; CurrentUserDate.mapDate = mapDate; CurrentUserDate.bagDate = bagDate; //血瓶数量 CurrentUserDate.xp_nums = xp_nums; CurrentUserDate.userName = "******"; CurrentUserDate.onlyId = 2; GameSaveDate.GetInstance().SaveDateByURLName(saveDateName, CurrentUserDate); GameSaveDate.GetInstance().SaveDateByURLName(saveDateName + "Map", CurrentUserDate); IsChangeScreening = false; //print("hi!!!!"); //清除 选择的 other数据 OtherDate = new OtherSaveDate(); GameSaveDate.GetInstance().SaveOtherDateByURLName(OtherDate); }
//这个是 用来 存取 自动地图的 数据 不要搞混了 //public GameMapDate gameMapDate; private void Awake() { //Debug.Log("Start"); if (Globals.isDebug) { print("全局数据GlobalSetDate 启动"); } PeiZhi(); if (CurrentUserDate == null) { CurrentUserDate = new UserDate(); } if (CurrentMapMsgDate == null) { CurrentMapMsgDate = new UserDate(); } if (OtherDate == null) { OtherDate = new OtherSaveDate(); } //if (gameMapDate == null) gameMapDate = new GameMapDate(); //CurrentUserDate = new UserDate(); //外部调用居然比启动更快 这里就不要new了 会导致数据消失 //GetGuanKaStr(); //Application.targetFrameRate = 60; //Time.fixedDeltaTime = 0.033f; }
//****************************************************************************************************************** //************************************ 选择数据 other 存储 ****************************************************************************** //记录 剧情 选择 改变的 数据 这数据可以改变游戏方向 public void SaveOtherDateByURLName(OtherSaveDate date, string URL = "OTHER") { string _fileURL2 = Application.persistentDataPath + "/" + URL; //if (Globals.isDebug) Debug.Log("_fileURL2> "+ _fileURL2); string s = SerializeObject(date, typeof(OtherSaveDate)); //创建XML文件且写入数据 CreateTextFile(_fileURL2, s, false); Debug.Log("ot 其他数据写入 " + s + " 路径> " + _fileURL2 + " date内容 " + date.GlobalOtherDate); }
//***********************************************other数据获取区************************************************************* public OtherSaveDate GetOtherDate() { if (OtherDate == null) { OtherDate = new OtherSaveDate(); } OtherDate = GameSaveDate.GetInstance().GetOtherSaveDateByName(); //print(" 获取了 otherdate!! "+OtherDate.GlobalOtherDate); return(OtherDate); }
void Start() { //LuaEnv luaenv = new LuaEnv(); //luaenv.DoString("require 'gameMain'"); //XLuaTest("lua test 测试"); ObjectEventDispatcher.dispatcher.addEventListener(EventTypeName.GAME_OVER, this.GameOver); OtherDate = GetOtherDate(); Application.targetFrameRate = 60; print("OtherDate " + OtherDate); }