void Jason() { if (!canSaveData) { heroS.hero = this.heros; string path = Application.dataPath + "/InitializeInfo/HerosChooosed.text"; JsonUti.ObjectToJsonStream <HeroChooseInfoS> (path, heroS); canSaveData = true; } }
public void ZhuceGame() { string path = Application.dataPath + "/InitializeInfo/"; path += "Login.text"; UserDataS userdata = JsonUti.JsonstreamToObject <UserDataS> (path); bool isContain = false; for (int i = 0; i < userdata.userdatas.Count; i++) { if (userName.text == userdata.userdatas[i].username) { isContain = true; break; } } if (!isContain) { data.username = userName.text; data.password = passWord.text; dataS.userdatas.Add(data); string path2 = Application.dataPath + "/InitializeInfo/Login.text"; dataofuser.username = userName.text; string pathUser = Application.dataPath + "/InitializeInfo/DataOfUser/"; pathUser += data.username + ".text"; JsonUti.ObjectToJsonStream <UserDataS> (path2, dataS); JsonUti.ObjectToJsonStream <DataOfUser> (pathUser, dataofuser); } else { tips.transform.Find("Text").GetComponent <Text> ().text = "用户名已\n存在"; tips.SetActive(true); Debug.Log("用户名已存在"); } ClearInput(); }
public void LoginGame() { string path = Application.dataPath + "/InitializeInfo/"; path += "Login.text"; UserDataS userdata = JsonUti.JsonstreamToObject <UserDataS> (path); bool canLod = false; Debug.Log("登陆时,所填写:" + userName.text + passWord.text); for (int i = 0; i < userdata.userdatas.Count; i++) { if (userName.text == userdata.userdatas [i].username) { if (passWord.text == userdata.userdatas [i].password) { canLod = true; break; } else { //密码错误 tips.SetActive(true); Debug.Log("密码错误"); break; } } else { continue; } } if (!canLod) { //用户不存在,请注册 tips.transform.Find("Text").GetComponent <Text> ().text = "用户不存在\n请注册"; tips.SetActive(true); } if (canLod) { string pathUser = Application.dataPath + "/InitializeInfo/DataOfUser/"; pathUser = pathUser + userName.text + ".text"; Debug.Log("登录的用户" + userName.text + pathUser); DataOfUser dataOfUser = JsonUti.JsonstreamToObject <DataOfUser> (pathUser); Debug.Log("登录的用户" + dataOfUser.username); string curLoadPlayer = Application.dataPath + "/InitializeInfo/CurLoadPlayer.text"; JsonUti.ObjectToJsonStream <DataOfUser> (curLoadPlayer, dataOfUser); Debug.Log("登录的用户" + dataOfUser.Level); Debug.Log("进入游戏"); // StartCoroutine (LoadScene ()); //异步加载场景 canvas03.SetActive(false); canvas01.SetActive(false); canvas02.SetActive(true); cameraShow.SetActive(false); Debug.Log(dataOfUser.Money); ClearInput(); // Debug.Log (dataOfUser.OwnHero); } ClearInput(); }
void SaveJsonData(Data_Rloe role, string name) { string path = Application.dataPath + "/InitializeInfo/HeroData/" + name + ".text"; JsonUti.ObjectToJsonStream <Data_Rloe> (path, role); }