Ejemplo n.º 1
0
    public void CheckPlayerPrefs(string playerName)                                                                                                                                      // ładowane po kliknieciu LOGO w menu LOGIN po podaniu username
    {
        _playerPrefsExist = _playerProfileController.IsPlayerPrefsNotEmpty();

        if (_playerPrefsExist)
        {
            ProjectData tempProjectData = _playerProfileController.LoadProfiles();
            _projectData.EntireList.Clear();
            _projectData.EntireList.InsertRange(0, tempProjectData.EntireList);

            for (int i = 0; i < _projectData.EntireList.Count; i++)                             // parsuje całą listę obiektów
            {
                if (_projectData.EntireList[i].PlayerName.Equals(playerName))                   // sprawdza czy podane NAME istnieje w pamięci
                {
                    _projectData.CurrentID = i;                                                 // ID znalezionego profilu
                    _isOnTheList           = true;
                    break;
                }
            }

            if (!_isOnTheList)
            {
                AddNewProfile(playerName);                                          // dodaj KOLEJNY profil
            }
        }
        else
        {
            AddNewProfile(playerName);                                      // dodaj PIERWSZY profil
        }

        _isOnTheList = false;                                       // zerowanie flagi wystąpienia playerName na liście
    }