//网络版结算 IEnumerator Results() { UIMiniMap uiMiniMap = UIManager.Instance.GetUI <UIMiniMap>(UIName.UIMiniMap); string resultsurl = "http://172.164.0.10:800/SaveData.ashx?Ver=1&CharacterID=" + CharacterTemplate.Instance.characterId + "&RemainTime=" + uiMiniMap.battleTime + "&Scene=11"; WWW www = new WWW(resultsurl); yield return(www); if (www.error == null) { Debug.Log(www.text); JsonData json = JsonMapper.ToObject(www.text); star = int.Parse(json[0].ToString()); exp = int.Parse(json[1].ToString()); CharacterTemplate.Instance.characterId = int.Parse(json[2]["CharacterID"].ToString()); CharacterTemplate.Instance.jobId = int.Parse(json[2]["JobID"].ToString()); CharacterTemplate.Instance.lv = int.Parse(json[2]["Lv"].ToString()); CharacterTemplate.Instance.expCur = int.Parse(json[2]["ExpCur"].ToString()); CharacterTemplate.Instance.force = int.Parse(json[2]["Force"].ToString()); CharacterTemplate.Instance.intellect = int.Parse(json[2]["Intellect"].ToString()); // CharacterTemplate.Instance.speed = int.Parse(json[2]["Speed"].ToString()); CharacterTemplate.Instance.maxHp = int.Parse(json[2]["MaxHP"].ToString()); CharacterTemplate.Instance.maxMp = int.Parse(json[2]["MaxMP"].ToString()); CharacterTemplate.Instance.damageMax = int.Parse(json[2]["DamageMax"].ToString()); UIManager.Instance.SetVisible(UIName.UIVictory, true); UIVictory uiVictory = UIManager.Instance.GetUI <UIVictory>(UIName.UIVictory); uiVictory.SetExp(exp); uiVictory.SetStar(star); } else { Debug.Log(www.error); } }
//结算 public void GetResultsDB(int sceneId, int star) { CreateDataBase(); SqliteDataReader scene = db.SelectWhere("T_Scene", new string[] { "SceneExp" + star, "Gold" + star }, new string[] { "SceneName" }, new string[] { "=" }, new string[] { sceneId.ToString() }); while (scene.Read()) { exp = int.Parse(scene[0].ToString()); gold = int.Parse(scene[1].ToString()); } // Debug.Log("exp:" + exp); // Debug.Log("gold:" + gold); UIManager.Instance.SetVisible(UIName.UIVictory, true); UIVictory uivictory = UIManager.Instance.GetUI <UIVictory>(UIName.UIVictory); uivictory.SetExp(exp); uivictory.SetStar(star); //读取角色表 SqliteDataReader sqReader = db.Select("T_Character", "CharacterID", "1"); while (sqReader.Read()) { int i = 0; CharacterTemplate.Instance.characterId = int.Parse(sqReader[i].ToString()); CharacterTemplate.Instance.jobId = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.lv = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.expCur = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.force = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.intellect = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.attackSpeed = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.maxHp = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.maxMp = int.Parse(sqReader[++i].ToString()); CharacterTemplate.Instance.damageMax = int.Parse(sqReader[++i].ToString()); } //读取经验表,获取当前等级最大经验 SqliteDataReader lvExp = db.Select("T_Exp", "Lv", CharacterTemplate.Instance.lv.ToString()); int maxExp = 0; while (lvExp.Read()) { maxExp = int.Parse(lvExp[2].ToString()); } //经验累加 CharacterTemplate.Instance.expCur += exp; if (CharacterTemplate.Instance.expCur > maxExp) //升级 { CharacterTemplate.Instance.lv += 1; CharacterTemplate.Instance.force += 5; CharacterTemplate.Instance.intellect += 5; CharacterTemplate.Instance.maxHp += 1000; CharacterTemplate.Instance.maxMp += 500; CharacterTemplate.Instance.damageMax += 10; //更新数据库 db.UpdateInto("T_Character", new string[] { "Lv", "ExpCur", "Force", "Intellect", "MaxHP", "MaxMP", "DamageMax" }, new string[] { CharacterTemplate.Instance.lv.ToString(), CharacterTemplate.Instance.expCur.ToString(), CharacterTemplate.Instance.force.ToString(), CharacterTemplate.Instance.intellect.ToString(), CharacterTemplate.Instance.maxHp.ToString(), CharacterTemplate.Instance.maxMp.ToString(), CharacterTemplate.Instance.damageMax.ToString() }, "CharacterID", "1"); } else { db.UpdateInto("T_Character", new string[] { "ExpCur" }, new string[] { CharacterTemplate.Instance.expCur.ToString() }, "CharacterID", "1"); } SqliteDataReader goldInfo = db.Select("T_Money", "AccountID", "1"); while (goldInfo.Read()) { CharacterTemplate.Instance.gold = int.Parse(goldInfo[1].ToString()); } CharacterTemplate.Instance.gold += gold; db.UpdateInto("T_Money", new string[] { "Gold" }, new string[] { CharacterTemplate.Instance.gold.ToString() }, "AccountID", "1"); db.CloseSqlConnection(); }