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

        answer = request.text;
        if (!answer.Equals("hits saved"))
        {
            manager.saveNewId(statistic, answer);
        }
    }
예제 #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);
        }
    }
예제 #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());
     }
 }
예제 #5
0
파일: API.cs 프로젝트: Kvazemorda/ShooterBi
    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));
    }
예제 #6
0
 private void UploadOnServer(ShootingStatistic shooting)
 {
     API.RequestToUploadShootStatistic(shooting, this);
 }
예제 #7
0
 public void Save(ShootingStatistic shootingStatic)
 {
     PlayerPrefs.SetString("save", Helper.Serialize <ShootingStatistic>(shootingStatic));
     UploadOnServer(shootingStatic);
 }