Exemple #1
0
 void Start()
 {
     //todo когда буду делать стрельбу стоя по установкам, то надо isStand перенести в метод и определять через toggle
     isStand       = false;
     isReloaded    = true;
     bullet        = 5;
     listOfTargets = new List <Targert100>();
     statistic     = saveManager.LoadShootingStatic();
 }
Exemple #2
0
    IEnumerator Respond(WWW request, SaveManager manager, ShootingStatistic statistic)
    {
        yield return(request);

        answer = request.text;
        if (!answer.Equals("hits saved"))
        {
            manager.saveNewId(statistic, answer);
        }
    }
Exemple #3
0
    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);
        }
    }
Exemple #4
0
 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());
     }
 }
Exemple #5
0
    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));
    }
Exemple #6
0
 private void UploadOnServer(ShootingStatistic shooting)
 {
     API.RequestToUploadShootStatistic(shooting, this);
 }
Exemple #7
0
 public void Save(ShootingStatistic shootingStatic)
 {
     PlayerPrefs.SetString("save", Helper.Serialize <ShootingStatistic>(shootingStatic));
     UploadOnServer(shootingStatic);
 }