// Start is called before the first frame update
 void Start()
 {
     pontuaçãoFinal = FindObjectOfType <Pontuador>();
     if (pontuaçãoFinal == null)
     {
         pontos = Random.Range(10, 50);
         tempo  = "1d:24h:59m:59s";
     }
     else
     {
         pontos = pontuaçãoFinal.Pontuacao();
         tempo  = pontuaçãoFinal.TempoDeJogoFinalConvertido();
     }
     if (PlayerPrefs.HasKey(nomeChavePlayerPref))
     {
         nomeJogador = PlayerPrefs.GetString(nomeChavePlayerPref);
     }
     else
     {
         nomeJogador = "CallMeSusie";
         Debug.Log(nomeJogador);
     }
 }
        private void InitializeWindowPositionCheckStatus()
        {
            _windowPositionCheckCount = windowPositionCheckInterval;
            if (PlayerPrefs.HasKey(InitialPositionXKey) &&
                PlayerPrefs.HasKey(InitialPositionYKey)
                )
            {
#if !UNITY_EDITOR
                int x = PlayerPrefs.GetInt(InitialPositionXKey);
                int y = PlayerPrefs.GetInt(InitialPositionYKey);
                _prevWindowPosition = new Vector2Int(x, y);
                SetUnityWindowPosition(x, y);
#endif
            }
            else
            {
#if !UNITY_EDITOR
                _prevWindowPosition = GetUnityWindowPosition();
                PlayerPrefs.SetInt(InitialPositionXKey, _prevWindowPosition.x);
                PlayerPrefs.SetInt(InitialPositionYKey, _prevWindowPosition.y);
#endif
            }
        }
        void Start()
        {
#if !BESTHTTP_DISABLE_COOKIES && (!UNITY_WEBGL || UNITY_EDITOR)
            // Set a "user" cookie if we previously used the 'Enter Name' button.
            // The server will set this username to the new connection.
            if (PlayerPrefs.HasKey("userName"))
            {
                CookieJar.Set(URI, new Cookie("user", PlayerPrefs.GetString("userName")));
            }
#endif

            signalRConnection = new Connection(URI);

            // to serialize the Message class, set a more advanced json encoder
            signalRConnection.JsonEncoder = new BestHTTP.SignalR.JsonEncoders.LitJsonEncoder();

            // set up event handlers
            signalRConnection.OnStateChanged  += signalRConnection_OnStateChanged;
            signalRConnection.OnNonHubMessage += signalRConnection_OnGeneralMessage;

            // Start to connect to the server.
            signalRConnection.Open();
        }
Example #4
0
    void Start()
    {
        rb           = GetComponent <Rigidbody>();
        speed        = 25f;
        flaps        = maxFlaps;
        currentScore = (int)transform.position.y;
        if (currentScoreText != null)
        {
            currentScoreText.text = "Current score: " + currentScore.ToString();
        }

        if (highscoreText != null)
        {
            highscoreText.text = !PlayerPrefs.HasKey("highscore") ? "Highscore: 0" : "Highscore: " + PlayerPrefs.GetInt("highscore");
        }

        if (flapsText != null)
        {
            flapsText.text = "Flaps: " + flaps.ToString();
        }

        AudioManager.instance.Play("Wind1");
    }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public override T GetObject <T>(string key, T defaultValue)
        {
            if (!PlayerPrefs.HasKey(Key(key)))
            {
                return(defaultValue);
            }

            string str = PlayerPrefs.GetString(Key(key));

            if (string.IsNullOrEmpty(str))
            {
                return(defaultValue);
            }

            if (this.encryptor != null)
            {
                byte[] data = Convert.FromBase64String(str);
                data = this.encryptor.Decode(data);
                str  = Encoding.UTF8.GetString(data);
            }

            return((T)serializer.Deserialize(str, typeof(T)));
        }
        private List <SaveFile> GatherSaveFiles(int profileID, bool isImport, int boolID, string separateFilePrefix)
        {
            List <SaveFile> gatheredSaveFiles = new List <SaveFile>();

            for (int i = 0; i < 50; i++)
            {
                bool   isAutoSave = false;
                string filename   = (isImport) ? GetImportFilename(i, separateFilePrefix, profileID) : GetSaveFilename(i, profileID);

                if (PlayerPrefs.HasKey(filename))
                {
                    string label = "Save " + i.ToString();
                    if (i == 0)
                    {
                        label      = "Autosave";
                        isAutoSave = true;
                    }
                    gatheredSaveFiles.Add(new SaveFile(i, profileID, label, filename, isAutoSave, null, "", 0));
                }
            }

            return(gatheredSaveFiles);
        }
    private string DeviceUniqueIdentifier()
    {
        string deviceId = "";

#if UNITY_EDITOR
        deviceId = SystemInfo.deviceUniqueIdentifier + "-editor";
#elif UNITY_ANDROID
        AndroidJavaClass  up = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = up.GetStatic <AndroidJavaObject> ("currentActivity");
        AndroidJavaObject contentResolver = currentActivity.Call <AndroidJavaObject> ("getContentResolver");
        AndroidJavaClass  secure          = new AndroidJavaClass("android.provider.Settings$Secure");
        deviceId = secure.CallStatic <string> ("getString", contentResolver, "android_id");
#elif UNITY_WEBGL
        if (!PlayerPrefs.HasKey("UniqueIdentifier"))
        {
            PlayerPrefs.SetString("UniqueIdentifier", Guid.NewGuid().ToString());
        }
        deviceId = PlayerPrefs.GetString("UniqueIdentifier");
#else
        deviceId = SystemInfo.deviceUniqueIdentifier;
#endif
        return(deviceId);
    }
Example #8
0
    void Start()
    {
        //SumScore.Reset(); // Ensure score is 0 when object loads
        if (initialScore != 0)
        {
            SumScore.Add(initialScore);  // Set initial score
        }
        if (storeHighScore)
        {
            if (PlayerPrefs.HasKey("sumHS"))
            {
                // Set high score value and tell manager
                SumScore.HighScore = PlayerPrefs.GetInt("sumHS");
                UpdatedHS();
            }
            else
            {
                SumScore.HighScore = 0;
            }
        }

        Updated(); // Set initial score in UI
    }
    void Start()
    {
        audioSource = GetComponent <AudioSource>();

        if (audioSource == null)
        {
            Debug.Log("Audio Source not found!");
        }

        gameManager = GameObject.FindObjectOfType <GameManager>();

        if (gameManager == null)
        {
            Debug.Log("GameManager not found!");
        }

        if (PlayerPrefs.HasKey("volume"))
        {
            var volume = PlayerPrefs.GetFloat("volume");

            audioSource.volume = volume;
        }
    }
Example #10
0
    //Load audio settings;
    void LoadAudioSettings()
    {
        if (PlayerPrefs.HasKey("Sounds"))
        {
            Game.sounds = Game.GetBool("Sounds");
        }
        soundImage.sprite = Game.sounds ? sounds.onIcon : sounds.offIcon;

        if (PlayerPrefs.HasKey("Music"))
        {
            Game.music = Game.GetBool("Music");
        }
        musicImage.sprite = Game.music ? music.onIcon : music.offIcon;

        if (Game.music)
        {
            music.ambientSource.Play();
        }
        else
        {
            music.ambientSource.Pause();
        }
    }
Example #11
0
 protected virtual void Init()
 {
     if (AlwaysPickFromSystemLanguage)
     {
         ApplySystemLanguageAsInitial();
     }
     else
     {
         if (SaveLastLanguageUsed)
         {
             CurrentLanguage = PlayerPrefs.GetString(LANGUANGE_KEY, m_startingLanguage);
         }
         else
         {
             CurrentLanguage = StartingLanguage;
         }
     }
     if (AlwaysPickFromSystemLanguage && PlayerPrefs.HasKey(LANGUANGE_KEY))
     {
         PlayerPrefs.DeleteKey(LANGUANGE_KEY);
     }
     GetOrLoadCurrentData();
 }
 public void Awake()
 {
     if (!PlayerPrefs.HasKey("music"))
     {
         PlayerPrefs.SetInt("music", 1);
         toggle.isOn     = true;
         myAudio.enabled = true;
         PlayerPrefs.Save();
     }
     else
     {
         if (PlayerPrefs.GetInt("music") == 0)
         {
             myAudio.enabled = false;
             toggle.isOn     = false;
         }
         else
         {
             myAudio.enabled = true;
             toggle.isOn     = true;
         }
     }
 }
Example #13
0
    /// <summary>
    /// Gets the sound set.
    /// 读取声音相关配置;
    /// </summary>
    public void GetSoundSet()
    {
        if (PlayerPrefs.HasKey(CatchSet.SoundSwitchStrKey))
        {
            int isOnSound = PlayerPrefs.GetInt(CatchSet.SoundSwitchStrKey);
            GameSet.bSoundOn = isOnSound == 1 ? true : false;
        }
        else
        {
            GameSet.bSoundOn = true;
        }


        if (PlayerPrefs.HasKey(CatchSet.MusicSwitchStrKey))
        {
            int isOnMusic = PlayerPrefs.GetInt(CatchSet.MusicSwitchStrKey);
            GameSet.bMusicOn = isOnMusic == 1 ? true : false;
        }
        else
        {
            GameSet.bMusicOn = true;
        }
    }
Example #14
0
    void Start()
    {
        string str = PlayerPrefs.GetString(currentLevelName, null);

        LivesPanel.instance.health = PlayerPrefs.GetInt("health", 100);
        this.stat = JsonUtility.FromJson <LevelStats>(str);
        Fruit.setCountZero();
        if (stat == null)
        {
            this.stat = new LevelStats();
        }

        HeroRefugee player = HeroRefugee.instance;

        if (PlayerPrefs.HasKey("x") && PlayerPrefs.HasKey("y") && PlayerPrefs.HasKey("z"))
        {
            x = PlayerPrefs.GetFloat("x");
            y = PlayerPrefs.GetFloat("y");
            z = PlayerPrefs.GetFloat("z");
            Vector3 posVec = new Vector3(x, y, z);
            player.transform.position = posVec;
        }
    }
Example #15
0
    void Start()
    {
        Events.OnChallengeCreate  += OnChallengeCreate;
        Events.OnChallengeClose   += OnChallengeClose;
        Events.OnChallengeRemind  += OnChallengeRemind;
        Events.SendNotificationTo += SendNotificationTo;

        if (PlayerPrefs.HasKey("currentInstallation"))
        {
            string objId = PlayerPrefs.GetString("currentInstallation");
            currentInstallation = ParseObject.CreateWithoutData("_Installation", objId);
        }

        if (currentInstallation == null)
        {
#if UNITY_IPHONE && !UNITY_EDITOR
            NotificationServices.RegisterForNotifications(
                NotificationType.Alert |
                NotificationType.Badge |
                NotificationType.Sound);
#endif
        }
    }
Example #16
0
File: score.cs Project: ShSaw/rock
    // Start is called before the first frame update
    void Start()
    {
        ScoreBoard.text = thescore.ToString();

        PlayerPrefs.SetInt("Score", thescore);

        thescore = PlayerPrefs.GetInt("Score");

        if (PlayerPrefs.HasKey("Round") == false)
        {
            PlayerPrefs.SetInt("Round", 0);
            Debug.Log("ROUND DIDN'T Exist");
        }
        else
        {
            round = PlayerPrefs.GetInt("Round");
            Debug.Log("Round Existed");
            round++;
            PlayerPrefs.SetInt("Round", round);
        }

        Debug.Log(round);
    }
Example #17
0
 public static string getNextScene()
 {
     if (PlayerPrefs.HasKey("maps"))
     {
         string maps    = PlayerPrefs.GetString("maps");
         string nextMap = maps.Split("%".ToCharArray())[0];
         if (!string.IsNullOrEmpty(nextMap))
         {
             if (maps.Length == nextMap.Length)
             {
                 maps = maps.Replace(nextMap, "");
             }
             else
             {
                 maps = maps.Replace(nextMap + "%", "");
             }
             PlayerPrefs.SetString("maps", maps);
             return(nextMap);
         }
     }
     //Default map
     return("controllerMapper");
 }
    /// <summary>
    /// Helper method to retrieve a bool from PlayerPrefs (stored as an int)
    /// </summary>
    public static bool GetBool(string key, bool defaultValue = false)
    {
        // Use HasKey to check if the bool has been stored (as int defaults to 0 which is ambiguous with a stored False)
        if (PlayerPrefs.HasKey(key))
        {
            int value = PlayerPrefs.GetInt(key);

            // As in C, assume zero is false and any non-zero value (including its intended 1) is true
            if (value != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        else
        {
            // No existing player pref value, so return defaultValue instead
            return(defaultValue);
        }
    }
Example #19
0
 public void SoundButton()
 {
     if (PlayerPrefs.HasKey("Sound"))
     {
         if (PlayerPrefs.GetInt("Sound") == 0)
         {
             soundButton.sprite = soundOn;
             //soundText.text = "On".ToString();
             PlayerPrefs.SetInt("Sound", 1);
         }
         else
         {
             soundButton.sprite = soundOff;
             //soundText.text = "Off".ToString();
             PlayerPrefs.SetInt("Sound", 0);
         }
     }
     else
     {
         soundButton.sprite = soundOff;
         PlayerPrefs.SetInt("Sound", 1);
     }
 }
Example #20
0
 public void LoadHighscore(int level)
 {
     for (int i = 1; i <= 10; i++)
     {
         Text rankLabel = GameObject.Find("Rank" + i).GetComponent <Text>();
         Text timeLabel = GameObject.Find("Time" + i).GetComponent <Text>();
         Text nameLabel = GameObject.Find("Name" + i).GetComponent <Text>();
         if (PlayerPrefs.HasKey("highscore" + i + "level" + level))
         {
             string[] entry = PlayerPrefs.GetString("highscore" + i + "level" + level).Split(';');
             rankLabel.text = i + ".";
             timeLabel.text = entry[1];
             nameLabel.text = entry[0];
         }
         else
         {
             rankLabel.text = "- - -";
             timeLabel.text = "- - -";
             nameLabel.text = "- - -";
         }
     }
     GameObject.Find("TextHighscoreLevel").GetComponent <Text>().text = "Level " + level;
 }
Example #21
0
    private void Start()
    {
        PlayerPrefs.SetFloat("Sensibility X", 75);
        PlayerPrefs.SetFloat("Sensibility Y", 20);

        if (QualitySettings.GetQualityLevel() >= 2)
        {
            fundoMenuAnimado.SetActive(true);
            fundoMenuEstatico.SetActive(false);
        }
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        if (PlayerPrefs.HasKey("gameStarted"))
        {
            Destroy(intro);
            Invoke("DesactivateTransition", 1f);
        }
        PlayerPrefs.DeleteAll();
        transicao.GetComponent <Animator>().SetTrigger("Finish");
        Destroy(intro, 4f);
        Invoke("DesactivateTransition", 3f);
    }
 //checking if this is only singleton in script
 #region Initialization
 private void Awake()
 {
     m_level        = 1;
     m_levelUp.text = "LEVEL " + m_level;
     if (singleton == null)
     {
         singleton = this;
     }
     else if (singleton != this)
     {
         Destroy(gameObject);
     }
     m_CurScore = 0;
     if (!PlayerPrefs.HasKey("HS"))
     {
         m_HighSc.text = "HighScore: 0";
     }
     else
     {
         m_HighSc.text = "HighScore: " + PlayerPrefs.GetInt("HS");
     }
     UpdateScore();
 }
 void StartPlaying()
 {
     // Show some waiting message here
     if (PlayerPrefs.HasKey("PlayerId") && !String.IsNullOrEmpty(PlayerPrefs.GetString("PlayerId")))
     {
         if (GameManager.Instance.tracker.ready)
         {
             GameManager.Instance.SetGamePhase(GameManager.GamePhases.LoadScreen);
         }
         else
         {
             GameManager.Instance.tracker.StartTrackerWithCallback(StartPlayingWithLevelInformation, NoInternetError);
             fetchConfigInProgressOverlay.OpenPanel();
         }
     }
     else
     {
         Debug.Log("missing PlayerId");
         playerIdField.transform.FindChild("Text").GetComponent <Text>().color = Color.red;
         playerIdField.Select();
         playerIdField.ActivateInputField();
     }
 }
Example #24
0
 // Update is called once per frame
 void Update()
 {
     if (gameObject.GetComponent <DefaultTrackableEventHandler> ().flag == 1)
     {
         if ((PlayerPrefs.GetInt("story") == -1) && (number % numbOfLevels == 1) && number < 30)
         {
             PlayerPrefs.SetInt("story", number);
             PlayerPrefs.SetInt("level", 0);
         }
         if (number == PlayerPrefs.GetInt("story") + PlayerPrefs.GetInt("level") && PlayerPrefs.GetInt("level") < 6)
         {
             allow = 1;
             PlayerPrefs.SetInt("level", PlayerPrefs.GetInt("level") + 1);
         }
         if (PlayerPrefs.HasKey("story"))
         {
             if (number >= PlayerPrefs.GetInt("story") && number < PlayerPrefs.GetInt("story") + PlayerPrefs.GetInt("level"))
             {
                 allow = 1;
             }
         }
     }
 }
        /// <summary>
        /// If the user's credentials are stored in PlayerPrefs, this method will retrieve them.
        /// </summary>
        /// <param name="username">Contains the username if retrieval was successfull, empty string otherwise.</param>
        /// <param name="token">Contains the token if retrieval was successfull, empty string otherwise.</param>
        /// <returns>Whether retrieval was successfull or not.</returns>
        public bool GetStoredUserCredentials(out string username, out string token)
        {
            username = token = "";
            if (string.IsNullOrEmpty(UserCredentialsPreferences) || string.IsNullOrEmpty(EncryptionKey) ||
                !PlayerPrefs.HasKey(UserCredentialsPreferences))
            {
                return(false);
            }
            var credentials = PlayerPrefs.GetString(UserCredentialsPreferences).Split('#');

            if (credentials.Length != 2)
            {
                return(false);
            }
            try {
                username = XTEA.Decrypt(credentials[0], EncryptionKey);
                token    = XTEA.Decrypt(credentials[1], EncryptionKey);
                return(true);
            } catch {
                Debug.LogWarning("Failed to retrieve user credentials.");
                return(false);
            }
        }
Example #26
0
    void SetHighscore(string myHighScore)
    {
        string key       = "highscore";
        string highscore = myHighScore;


        if (PlayerPrefs.HasKey(key))
        {
            DateTime t1 = DateTime.Parse(highscore);
            DateTime t2 = DateTime.Parse(PlayerPrefs.GetString(key));

            if (t2 >= t1)
            {
                PlayerPrefs.SetString(key, highscore);
            }
        }
        else
        {
            PlayerPrefs.SetString(key, highscore);
        }

        PlayerPrefs.Save();
    }
Example #27
0
 public void showHeyZapAds()
 {
     if (PlayerPrefs.HasKey("HeyZadAdcount"))
     {
         if (PlayerPrefs.GetInt("HeyZadAdcount") == 3)
         {
             HZInterstitialAd.Show();
             PlayerPrefs.SetInt("HeyZadAdcount", 0);
         }
         else
         {
             if (HZVideoAd.IsAvailable())
             {
                 HZVideoAd.Show();
             }
             PlayerPrefs.SetInt("HeyZadAdcount", PlayerPrefs.GetInt("HeyZadAdcount") + 1);
         }
     }
     else
     {
         PlayerPrefs.SetInt("HeyZadAdcount", 0);
     }
 }
Example #28
0
        public override void Create(RectTransform container)
        {
            var group = Instantiate(templates.SettingGroup, container);

            group.title = @"アカウント設定";

            var label1 = Instantiate(templates.Label, group.container);

            label1.fontSize = 18;
            label1.text     = @"お名前";

            var label2 = Instantiate(templates.Label, group.container);

            label2.fontSize = 11;
            label2.color    = Color.red;
            label2.text     = @"以下の名前でランキングに登録されます";

            var textField = Instantiate(templates.InputField, group.container);

            textField.characterLimit = 10;
            textField.text           = PlayerPrefs.HasKey(PlayerPrefsKey.PlayerName) ? PlayerPrefs.GetString(PlayerPrefsKey.PlayerName) : @"";
            textField.onValueChanged.AddListener(onValueChanged);
        }
Example #29
0
 public static void InitSetting()
 {
     if (!PlayerPrefs.HasKey("language"))
     {
         PlayerPrefs.SetString("language", "s");
     }
     GameConst.Language = PlayerPrefs.GetString("language");
     if (!PlayerPrefs.HasKey("BGM"))
     {
         PlayerPrefs.SetString("BGM", "1");
     }
     GameConst.BGM = PlayerPrefs.GetString("BGM");
     if (!PlayerPrefs.HasKey("MUSIC"))
     {
         PlayerPrefs.SetFloat("MUSIC", 0.8f);
     }
     GameConst.musicVol = PlayerPrefs.GetFloat("MUSIC");
     if (!PlayerPrefs.HasKey("SOUND"))
     {
         PlayerPrefs.SetFloat("SOUND", 0.8f);
     }
     GameConst.soundVol = PlayerPrefs.GetFloat("SOUND");
 }
Example #30
0
 void Start()
 {
     loadRecord();
     isStop = true;
     handler();
     respawnPos = player.transform.position;
     if (PlayerPrefs.HasKey("FlagVirbate"))
     {
         string flag = PlayerPrefs.GetString("FlagVirbate");
         if (flag.Equals("ON"))
         {
             virbation = true;
         }
         else
         {
             virbation = false;
         }
     }
     else
     {
         virbation = true;
     }
     // Use for test in PC delete when publish to phone
     if (Application.platform == RuntimePlatform.Android)
     {
         isAndroid = true;
     }
     else
     {
         isAndroid = false;
     }
     gameOver      = false;
     startTime     = Time.time;
     timeText.text = startTime.ToString(("F1")) + " S";
     pickCount     = 0;
     setScoreText();
 }