void Start() { //todo когда буду делать стрельбу стоя по установкам, то надо isStand перенести в метод и определять через toggle isStand = false; isReloaded = true; bullet = 5; listOfTargets = new List <Targert100>(); statistic = saveManager.LoadShootingStatic(); }
IEnumerator Respond(WWW request, SaveManager manager, ShootingStatistic statistic) { yield return(request); answer = request.text; if (!answer.Equals("hits saved")) { manager.saveNewId(statistic, answer); } }
public void saveNewId(ShootingStatistic shooting, string answer) { ShootingStatistic shooterId = new ShootingStatistic(); Debug.Log(answer); JsonUtility.FromJsonOverwrite(answer, shooterId); if (!shooting.shooterId.Equals(shooterId.shooterId) && shooterId.shooterId != 0) { Debug.Log("create new ID"); shooting.shooterId = shooterId.shooterId; Save(shooting); } }
public ShootingStatistic LoadShootingStatic() { if (PlayerPrefs.HasKey("save")) { ShootingStatistic statistic = Helper.Deserialize <ShootingStatistic>(PlayerPrefs.GetString("save")); if (statistic != null) { return(statistic); } else { return(new ShootingStatistic()); } } else { Debug.Log("SaveNewShootingStatistic"); return(new ShootingStatistic()); } }
public void RequestToUploadShootStatistic(ShootingStatistic statistic, SaveManager manager) { string hitsParamName = "hits"; int hits = statistic.hit; string shootCountParamName = "hits-count"; int shootCount = statistic.shootCount; string shooterIdParamName = "userid"; long idShooter = statistic.shooterId; string isStandParamName = "isStand"; bool isStand = statistic.isStand; string paramsForRequest = "?" + hitsParamName + "=" + hits + "&" + shootCountParamName + "=" + shootCount + "&" + shooterIdParamName + "=" + idShooter + "&" + isStandParamName + "=" + isStand; WWW request = new WWW(URL + "hits" + paramsForRequest); StartCoroutine(Respond(request, manager, statistic)); }
private void UploadOnServer(ShootingStatistic shooting) { API.RequestToUploadShootStatistic(shooting, this); }
public void Save(ShootingStatistic shootingStatic) { PlayerPrefs.SetString("save", Helper.Serialize <ShootingStatistic>(shootingStatic)); UploadOnServer(shootingStatic); }