【设置】评分存盘放入设置中

Android_release
zhangaotian 2024-08-08 20:00:10 +08:00
parent b4833ef177
commit d5d2d5fc2c
13 changed files with 68 additions and 50 deletions

View File

@ -1,3 +1,4 @@
using Framework.Constants;
using UnityEngine;
public class CameraAdapter : MonoBehaviour
@ -8,7 +9,7 @@ public class CameraAdapter : MonoBehaviour
{
_camera = transform.GetComponent<Camera>();
var size = _camera.orthographicSize;
_camera.orthographicSize = size * GlobalConstants.DesignResolutionWidth /
GlobalConstants.DesignResolutionHeight * Screen.height / Screen.width;
_camera.orthographicSize = size * NormalConstants.DesignResolutionWidth /
NormalConstants.DesignResolutionHeight * Screen.height / Screen.width;
}
}

View File

@ -1,3 +1,4 @@
using Framework.Constants;
using UnityEngine;
using UnityEngine.InputSystem;
@ -35,7 +36,7 @@ public class CameraController : MonoBehaviour
{
_camera = transform.GetComponent<Camera>();
var size = _camera.orthographicSize;
_camera.orthographicSize = size * GlobalConstants.DesignResolutionWidth /
GlobalConstants.DesignResolutionHeight * Screen.height / Screen.width;
_camera.orthographicSize = size * NormalConstants.DesignResolutionWidth /
NormalConstants.DesignResolutionHeight * Screen.height / Screen.width;
}
}

View File

@ -9,23 +9,7 @@ namespace Framework.Constants
public const int PropPrice = 100;
public const int TimePropPrice = 50;
//多语言
public const string Chinese = "简体中文";
public const string English = "English";
//BI事件
public const string FteLevelSuccess = "fte_level_success_{0}";
public const string FteLevelEnter = "fte_level_enter_{0}";
//评分弹窗相关
public const string PopUpNumber = "PopUpNumber";
public const string PopUpToScore = "ToScore";
public const int PopUpLimitNumber = 8;
public const int LevelRateIndex = 4;
/// <summary>
/// 关卡选择 一页数量
/// </summary>
// 关卡选择 一页的数量
public const int LevelSelectCount = 15;
//通关奖励

View File

@ -0,0 +1,23 @@
namespace Framework.Constants
{
public static class NormalConstants
{
public const float DesignResolutionWidth = 1080;
public const float DesignResolutionHeight = 1920;
public const string UserBuildSaveKey = "UserBuildInfo";
public const string DefaultBuildID = "Build_1";
//多语言
public const string Chinese = "简体中文";
public const string English = "English";
//BI事件
public const string FteLevelSuccess = "fte_level_success_{0}";
public const string FteLevelEnter = "fte_level_enter_{0}";
//评分弹窗相关
public const int PopUpLimitNumber = 8;
public const int LevelRateIndex = 4;
}
}

View File

@ -1,8 +0,0 @@
public static class GlobalConstants
{
public const float DesignResolutionWidth = 1080;
public const float DesignResolutionHeight = 1920;
public const string UserBuildSaveKey = "UserBuildInfo";
public const string DefaultBuildID = "Build_1";
}

View File

@ -3,6 +3,7 @@ using PhxhSDK;
using UnityEngine;
using System.Linq;
using LC.Newtonsoft.Json;
using Framework.Constants;
using Sirenix.OdinInspector;
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
@ -120,7 +121,7 @@ namespace Framework.Manager
public class UserBuildInfo
{
public int GuideGroup;
public string BuildData = GlobalConstants.DefaultBuildID;
public string BuildData = NormalConstants.DefaultBuildID;
public Dictionary<string, string> ChooseNodeInfo;
public UserBuildInfo()
@ -138,6 +139,8 @@ namespace Framework.Manager
public class BuildManager
{
public const string UserBuildSaveKey = "UserBuildInfo";
public const string DefaultBuildID = "Build_1";
private const string NodeName = "Node{0}";
private const string OptionName = "Option{0}";
@ -263,7 +266,7 @@ namespace Framework.Manager
{
StorageManager.Instance.Init();
_userBuildInfo =
StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
StorageManager.Instance.GetStorage<UserBuildInfo>(UserBuildSaveKey);
if (_userBuildInfo == null)
{
var buildId = _curBuildData.buildID;

View File

@ -11,8 +11,9 @@ namespace Framework.Setting
public float SoundVolume = 1f;
public string Language;
public bool FirstLaunch = true;
public int RateUsNumber = 0;
public bool RateUs = false;
}
public class SettingManager : Singlenton<SettingManager>
@ -20,6 +21,12 @@ namespace Framework.Setting
private const string SettingKey = "SettingKey";
private SettingData _settingData;
public SettingData CurSettingData
{
get => _settingData;
private set => _settingData = value;
}
public void Init()
{
_settingData = StorageManager.Instance.GetStorage<SettingData>(SettingKey);
@ -62,9 +69,16 @@ namespace Framework.Setting
SaveSetting();
}
public bool IsFirstLaunch()
public void SetRateUsPopNumber()
{
return _settingData.FirstLaunch;
_settingData.RateUsNumber++;
SaveSetting();
}
public void SetRateUs()
{
_settingData.RateUs = true;
SaveSetting();
}
private void SaveSetting()

View File

@ -55,11 +55,11 @@ namespace Gameplay.LoadingExecutor
/// </summary>
private async UniTask InitBuildScene()
{
var buildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
var buildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(NormalConstants.UserBuildSaveKey);
buildInfo ??= new UserBuildInfo();
if (string.IsNullOrEmpty(buildInfo.BuildData))
{
buildInfo.BuildData = GlobalConstants.DefaultBuildID;
buildInfo.BuildData = NormalConstants.DefaultBuildID;
}
//判断是否开启新手引导
@ -111,7 +111,7 @@ namespace Gameplay.LoadingExecutor
await UIManager.Instance.OpenWindow(UIConstants.UILogin);
#endif
if (SettingManager.Instance.IsFirstLaunch())
if (SettingManager.Instance.CurSettingData.FirstLaunch)
{
await UIManager.Instance.OpenWindow(UIConstants.UIUserAgreement);
}

View File

@ -145,7 +145,7 @@ namespace Gameplay.Manager
public void ReportEnterLevel()
{
BIManager.Instance.TrackStringEventOnce(string.Format(LevelConstants.FteLevelEnter,
BIManager.Instance.TrackStringEventOnce(string.Format(NormalConstants.FteLevelEnter,
CurrentLevel.GetLevelIndex()));
}
@ -275,7 +275,7 @@ namespace Gameplay.Manager
private void ReportPassLevel()
{
BIManager.Instance.TrackStringEventOnce(string.Format(LevelConstants.FteLevelSuccess,
BIManager.Instance.TrackStringEventOnce(string.Format(NormalConstants.FteLevelSuccess,
CurrentLevel.GetLevelIndex()));
}

View File

@ -3,6 +3,7 @@ using UnityEngine.UIElements;
using Framework.Constants;
using Gameplay.Manager;
using Framework.Event;
using Framework.Setting;
using UnityEngine.UI;
using Framework.UI;
using UnityEngine;
@ -81,7 +82,7 @@ public class UILevelSelectController : UIWindow
_scrollRect.normalizedPosition = new Vector2(_scrollRect.normalizedPosition.x, 1f - targetPosition);
}
private void InitData()
private async void InitData()
{
LevelSelectManager.Instance.UpdateLevelInfo();
_list = new UIList<UILevelSelectItem, UILevelDataArray>(_levelObj, "Viewport/Content/LevelPanel",
@ -90,18 +91,16 @@ public class UILevelSelectController : UIWindow
_list.SetDatas(_levelDatas);
//评分弹窗显示
if (!UnityEngine.PlayerPrefs.HasKey(LevelConstants.PopUpToScore) &&
LevelSelectManager.Instance.CurPassLevelIndex >= LevelConstants.LevelRateIndex)
if (!SettingManager.Instance.CurSettingData.RateUs &&
LevelSelectManager.Instance.CurPassLevelIndex >= NormalConstants.LevelRateIndex)
{
var popUpNumber = UnityEngine.PlayerPrefs.GetInt(LevelConstants.PopUpNumber, 0);
if (popUpNumber > LevelConstants.PopUpLimitNumber)
if (SettingManager.Instance.CurSettingData.RateUsNumber > NormalConstants.PopUpLimitNumber)
{
UIManager.Instance.OpenWindow(UIConstants.UIScore);
UnityEngine.PlayerPrefs.SetInt(LevelConstants.PopUpNumber, 0);
await UIManager.Instance.OpenWindow(UIConstants.UIScore);
}
else
{
UnityEngine.PlayerPrefs.SetInt(LevelConstants.PopUpNumber, popUpNumber + 1);
SettingManager.Instance.SetRateUsPopNumber();
}
}
}

View File

@ -1,4 +1,5 @@
using Framework.Constants;
using Framework.Setting;
using Framework.Event;
using Framework.UI;
using UnityEngine;
@ -20,7 +21,7 @@ public class UIScoreController : UIWindow
{
var url = Application.platform == RuntimePlatform.Android ? PathConstants.ScoreUrlAndroid : PathConstants.ScoreUrlIOS;
Application.OpenURL(url);
UnityEngine.PlayerPrefs.SetInt(LevelConstants.PopUpToScore, 1);
SettingManager.Instance.SetRateUs();
CloseWindow();
}

View File

@ -50,8 +50,8 @@ public class UISettingPanelController : UIWindow
_lanDropdown = GameObject.Find("BG_SettingPanel/Language/Dropdown_Lan").GetComponent<TMP_Dropdown>();
_lanDropdown.onValueChanged.AddListener(ChangLanguage);
_lanDropdown.options.Add(new TMP_Dropdown.OptionData(LevelConstants.Chinese));
_lanDropdown.options.Add(new TMP_Dropdown.OptionData(LevelConstants.English));
_lanDropdown.options.Add(new TMP_Dropdown.OptionData(NormalConstants.Chinese));
_lanDropdown.options.Add(new TMP_Dropdown.OptionData(NormalConstants.English));
_lanDropdown.value = StringManager.CurLanguage == StringManager.LanguageType.CN ? 0 : 1;
InitUI();