//改变金钱和等级 //change = 0 人物等级提升 =1 城堡提升 =2 防御塔提升 =3 道具1数加1 =4 道具2数加1 = 5道具3数加1 public void changeMoney(string user, float m, int change) { string mode = PlayerPrefs.GetString("temp"); switch (change) { case 0: local.level += 1; changeCharater(local.level); break; case 1: local.castle += 1; changeCasetle(local.castle); break; case 2: local.defence += 1; changeDefence(local.defence); break; case 3: local.propone += 1; changeOne(local.propone); break; case 4: local.proptwo += 1; changeTwo(local.proptwo); break; case 5: local.propthree += 1; changeThree(local.propthree); break; } local.money += m; money.text = local.money.ToString(); xml.changePlayer(local); if (mode.Equals("land")) { string parameter = ""; string score = local.score.ToString(); string mon = local.money.ToString(); string level = local.level.ToString(); string castle = local.castle.ToString(); string defence = local.defence.ToString(); string propone = local.propone.ToString(); string proptwo = local.proptwo.ToString(); string propthree = local.propthree.ToString(); parameter += "UserName="******"&"; parameter += "Score=" + score + "&"; parameter += "Money=" + mon + "&"; parameter += "Level=" + level + "&"; parameter += "Castle=" + castle + "&"; parameter += "Defence=" + defence + "&"; parameter += "Propone=" + propone + "&"; parameter += "Proptwo=" + proptwo + "&"; parameter += "Propthree=" + propthree; StartCoroutine(subData(subUrl + parameter)); } }
void Start() { string score = PlayerPrefs.GetString("score"); string money = PlayerPrefs.GetString("money"); Score.text = score; Money.text = money; xml = new XmlPlayerInformation(); string mode = PlayerPrefs.GetString("temp"); if (mode.Equals("default")) { local = xml.selectUser("default"); if (local == null) { local = new PlayerInfromation(); local.name = "default"; local.id = "default"; local.money = 0.0; local.score = 0.0; local.level = 0; local.castle = 0; local.defence = 0; local.propone = 0; local.proptwo = 0; local.propthree = 0; xml.addUser(local); } //当前分数 double curscore = System.Convert.ToDouble(PlayerPrefs.GetString("score")); //当前钱数 double curmoney = System.Convert.ToDouble(PlayerPrefs.GetString("money")); local.score += curscore; local.money += curmoney; xml.changePlayer(local); } else { string player = PlayerPrefs.GetString("player"); string id = player + "id"; local = xml.selectUser(id); string parameter = ""; if (local == null) { parameter += "UserName="******"score")); //当前钱数 double curmoney = System.Convert.ToDouble(PlayerPrefs.GetString("money")); local.score += curscore; local.money += curmoney; xml.changePlayer(local); string s = local.score.ToString(); string m = local.money.ToString(); string level = local.level.ToString(); string castle = local.castle.ToString(); string defence = local.defence.ToString(); string propone = local.propone.ToString(); string proptwo = local.proptwo.ToString(); string propthree = local.propthree.ToString(); parameter += "UserName="******"&"; parameter += "Score=" + s + "&"; parameter += "Money=" + m + "&"; parameter += "Level=" + level + "&"; parameter += "Castle=" + castle + "&"; parameter += "Defence=" + defence + "&"; parameter += "Propone=" + propone + "&"; parameter += "Proptwo=" + proptwo + "&"; parameter += "Propthree=" + propthree; StartCoroutine(subData(subUrl + parameter)); } }