Example #1
0
 private void UpdateDiaryValues(IPetStatus petStatus)
 {
     if (_diaryUiFields.Count > 0)
     {
         foreach (Text value in _diaryUiFields)
         {
             if (value.name.Equals(GameConstants.DIARY_LOVE_VALUE_STRING))
             {
                 value.text = petStatus.Love.ToString();
             }
             if (value.name.Equals(GameConstants.DIARY_HUNGER_VALUE_STRING))
             {
                 value.text = petStatus.Hunger.ToString();
             }
             if (value.name.Equals(GameConstants.DIARY_SLEEP_VALUE_STRING))
             {
                 value.text = petStatus.Sleep.ToString();
             }
             if (value.name.Equals(GameConstants.DIARY_PLAY_VALUE_STRING))
             {
                 value.text = petStatus.Play.ToString();
             }
         }
     }
 }
Example #2
0
    public void SavePetStateToPlayerPrefs(IPetStatus petStatus)
    {
        PlayerPrefs.SetString(GameConstants.SAVE_FILE_CAT_NAME_KEY, petStatus.Name);
        PlayerPrefs.SetFloat(GameConstants.SAVE_FILE_CAT_HUNGER_KEY, petStatus.Hunger);
        PlayerPrefs.SetFloat(GameConstants.SAVE_FILE_CAT_LOVE_KEY, petStatus.Love);
        PlayerPrefs.SetFloat(GameConstants.SAVE_FILE_CAT_PLAY_KEY, petStatus.Play);
        PlayerPrefs.SetFloat(GameConstants.SAVE_FILE_CAT_SLEEP_KEY, petStatus.Sleep);

        PlayerPrefs.Save();
        PetStateSaved?.Invoke(petStatus);
    }
Example #3
0
 public void LoadPetStateFromPlayerPrefs(IPetStatus petStatus)
 {
     if (PlayerPrefs.HasKey(GameConstants.SAVE_FILE_CAT_NAME_KEY))
     {
         petStatus.Name = PlayerPrefs.GetString(GameConstants.SAVE_FILE_CAT_NAME_KEY);
     }
     if (PlayerPrefs.HasKey(GameConstants.SAVE_FILE_CAT_HUNGER_KEY))
     {
         petStatus.Hunger = PlayerPrefs.GetFloat(GameConstants.SAVE_FILE_CAT_HUNGER_KEY);
     }
     if (PlayerPrefs.HasKey(GameConstants.SAVE_FILE_CAT_LOVE_KEY))
     {
         petStatus.Love = PlayerPrefs.GetFloat(GameConstants.SAVE_FILE_CAT_LOVE_KEY);
     }
     if (PlayerPrefs.HasKey(GameConstants.SAVE_FILE_CAT_PLAY_KEY))
     {
         petStatus.Play = PlayerPrefs.GetFloat(GameConstants.SAVE_FILE_CAT_PLAY_KEY);
     }
     if (PlayerPrefs.HasKey(GameConstants.SAVE_FILE_CAT_SLEEP_KEY))
     {
         petStatus.Sleep = PlayerPrefs.GetFloat(GameConstants.SAVE_FILE_CAT_SLEEP_KEY);
     }
 }