// Use this for initialization void Start() { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Временное хранилище для профиля активировано"); profileNum = PlayerPrefs.GetInt(PlayerPreferencesHelper.ProfilePrefEnum.CurrentProfile.ToString(), -1); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(profileNum); if (PlayerPrefs.GetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 0) == 0) { profileNum = -1; } DontDestroyOnLoad(this); if (FindObjectsOfType <PlayerProfile>().Length == 1) { Primary = true; } if (Primary == false) { Destroy(this.gameObject); } }
Vector2 stoneLineSpawnPosition = new Vector2(0f, 0f); //Место спавна первой каменной линии (HardCore Mode) // Use this for initialization void Start() { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Сцена: " + SceneManager.GetActiveScene().name + " загружена."); SGH = FindObjectOfType <SingleGameHelper>(); MBSGM = FindObjectOfType <MessageBoxSingleGameMenu>(); MBGO = FindObjectOfType <MessageBoxGameOver>(); PP = FindObjectOfType <PlayerProfile>(); score = 0; TxtGameMode.text = "Режим: " + SGH.GetGameMode().ToString(); TxtGameSpeed.text = "Скорость: " + SGH.GetGameSpeed().ToString(); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Получена и выведена информация об настройках игры:" + " Режим: " + SGH.GetGameMode().ToString() + " ;" + " Скорость: " + SGH.GetGameSpeed().ToString()); Vector2 vec = transform.position; playerPositionX = vec.x + stepSize; playerPositionY = vec.y + stepSize; tetrominoSpawnPosition = new Vector2(playerPositionX + stepSize * 5, playerPositionY + stepSize * 22); tetrominoPreviewSpawnPosition = new Vector2(playerPositionX + stepSize * 15f, playerPositionY + stepSize * 16f); stoneLineSpawnPosition = new Vector2(playerPositionX, playerPositionY); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Заданы координаты спавна фигур:" + " Координаты спавна активной фигуры: " + tetrominoSpawnPosition.ToString() + " ;" + " Координаты спавна предпросмотра фигуры: " + tetrominoPreviewSpawnPosition.ToString()); if (SGH != null) { gameSpeed = (11 - (double)SGH.GetGameSpeed()) / 10; GameMode = SGH.GetGameMode(); } else { gameSpeed = 1; GameMode = SingleGameHelper.GameModeEnum.Classic; } SpawnNextTetromino(); bestRecord = PlayerPrefs.GetInt(PlayerPreferencesHelper.GetBestRecordKey(GameMode, SGH.GetGameSpeed()), 0); youBestRecord = PlayerPrefs.GetInt(PlayerPreferencesHelper.GetPersonalBestRecordKey(PP.profileNum , GameMode, SGH.GetGameSpeed()), 0); TxtBestRecord.text = bestRecord.ToString(); TxtYouBestRecord.text = youBestRecord.ToString(); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Получены и выведена информация об рекордах:" + " Общий рекорд: " + TxtYouBestRecord.text + " ;" + " Личный рекорд для " + PP.profileNum + "профиля: " + TxtBestRecord.text); }
// Use this for initialization void Start() { PP = FindObjectOfType <PlayerProfile>(); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(profileNum); if (PlayerPrefs.GetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 0) != 0) { BtnProfileNotExist.SetActive(false); } InitializedPanel(); }
public void SavePlayerProfile() { Resources.UnloadUnusedAssets(); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(profileNum); PlayerPrefs.SetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 1); PlayerPrefs.SetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.NickName, nickName); PlayerPrefs.SetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.Avatar, avatarPath); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Сохранены изменения для " + profileNum + " профиля"); }
public void SelectFirsExistenceProfile() { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Поиск и выбор первого существующего профиля."); for (int i = 0; i < ProfilePanels.Length; i++) { string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(i); if (PlayerPrefs.GetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 0) != 0) { ProfilePanels[i].ButtonClick_SelectProfile(); return; } } Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Ни одного созданного профиля не обнаружено!"); PP.profileNum = -1; }
private bool ItExistenceAnyProfile() { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Проверка на существование созданного профиля."); for (int i = 0; i < ProfilePanels.Length; i++) { string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(i); if (PlayerPrefs.GetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 0) == 1) { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Есть созданные профили."); return(true); } } Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Ни одного созданного профиля не обнаружено."); return(false); }
public void DeletePlayerProfile(int profileNum) { Resources.UnloadUnusedAssets(); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(profileNum); File.Delete(PlayerPrefs.GetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.Avatar, null)); PlayerPrefs.SetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.ExistenceProfile, 0); PlayerPrefs.SetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.NickName, null); PlayerPrefs.SetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.Avatar, null); PlayerPrefs.SetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.RecordClassic, 0); PlayerPrefs.SetInt(prefix + PlayerPreferencesHelper.ProfilePrefEnum.RecordHardCore, 0); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Профиль" + profileNum + " удален"); }
public void InitializePlayerProfile(int ProfileNum) { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Начало инициализации временного хранилища для " + ProfileNum + " профиля"); Resources.UnloadUnusedAssets(); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(ProfileNum); string prefixPath = PlayerPreferencesHelper.GetPrefixAvatarPath(); profileNum = ProfileNum; nickName = PlayerPrefs.GetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.NickName, "Noname"); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Никнейм для инициализации временного хранилища " + ProfileNum + "профиля успешно получен: " + nickName); avatarPath = PlayerPrefs.GetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.Avatar, prefixPath + "NoImage.png"); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Путь к аватару для инициализации временного хранилища " + ProfileNum + "профиля успешно получен: " + avatarPath); try { if (File.Exists(avatarPath)) { WWW www = new WWW("file://" + avatarPath); SpriteAvatar = Sprite.Create(((www.texture)), new Rect(1, 1, ((www.texture)).width - 1, ((www.texture)).height - 1), new Vector2()); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Спрайт автара " + ProfileNum + " профиля успешно создан"); } else { Debug.LogWarning(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Ошибка инициализации временного хранилища профлия " + ProfileNum + ": аватар не найден!"); } } catch (Exception e) { Debug.LogError(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Ошибка инициализации временного хранилища профлия " + ProfileNum + ": " + e.ToString()); return; } Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Инициализация временного хранилища для " + ProfileNum + " профиля успешно завершена"); }
private void InitializedPanel() { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Заполнение панели " + profileNum + " профиля"); string prefix = PlayerPreferencesHelper.GetPrefixProfileKey(profileNum); string prefixPath = PlayerPreferencesHelper.GetPrefixAvatarPath(); TxtProfileNickName.text = PlayerPrefs.GetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.NickName, "Noname"); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Получен и установлен никнейм для " + profileNum + " профиля:" + TxtProfileNickName.text); string avatarPath = PlayerPrefs.GetString(prefix + PlayerPreferencesHelper.ProfilePrefEnum.Avatar, prefixPath + "NoImage.png"); Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Получен путь к аватару для " + profileNum + " профиля"); try { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Попытка установки аватара для " + profileNum + " профиля"); if (File.Exists(avatarPath)) { WWW www = new WWW("file://" + avatarPath); ImgProfileAvatar.sprite = Sprite.Create(((www.texture)), new Rect(1, 1, ((www.texture)).width - 1, ((www.texture)).height - 1), new Vector2()); } else { ImgProfileAvatar = null; Debug.LogWarning(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Аватар " + profileNum + " профиля не обнаружен"); return; } } catch (Exception e) { Debug.LogError("Не удалось загрузить картинку при инициализации предпросмота " + profileNum + " профиля: " + e.ToString()); return; } Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Аватар для " + profileNum + " панели предпосмотра профиля установлен успешно"); }
public void GameOver() //Вызывается при проигрыше { itGameOverBool = true; string text = "Результат: " + score; if (score > youBestRecord) { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Новый личный рекорд для " + PP.profileNum + " профиля: " + score); text += "\n" + "Новый личный рекорд!"; PlayerPrefs.SetInt(PlayerPreferencesHelper.GetPersonalBestRecordKey(PP.profileNum, GameMode, SGH.GetGameSpeed()), score); } if (score > bestRecord) { Debug.Log(DateTime.Now.ToString("hh:mm:ss:ffff") + ": Новый общий рекорд: " + score); text += "\n" + "Новый общий рекорд!"; PlayerPrefs.SetInt(PlayerPreferencesHelper.GetBestRecordKey(GameMode, SGH.GetGameSpeed()), score); } MBGO.ShowMessageBox(text); }
public void SetNewPathAvatar(string Path) { string prefixPath = PlayerPreferencesHelper.GetPrefixAvatarPath(); avatarPath = prefixPath + Path; }