(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)

Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com>
Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
2025-10-10 14:08:23 +08:00
parent 9a797479ff
commit 16b49f3d3a
1900 changed files with 114053 additions and 34157 deletions

View File

@@ -1,39 +1,24 @@
// Setting.cs
using System;
using Newtonsoft.Json;
using UnityEngine;
using Utils;
namespace Base
{
public class Setting : Utils.Singleton<Setting>
public class Setting : Singleton<Setting>
{
// 游戏设置数据类(用于序列化)
[System.Serializable]
public class GameSettings
// 窗口模式枚举
public enum WindowMode
{
public float progressStepDuration = 0.5f;
public float exitAnimationDuration = 1f;
public bool developerMode = false; // 默认值仍为 false在编辑器中会被覆盖
public bool friendlyFire = false;
public bool showMiniMap = true;
public float globalVolume = 1.0f;
public WindowMode currentWindowMode = WindowMode.Fullscreen;
public Vector2Int windowResolution = new(1920, 1080);
public string[] loadOrder;
public bool showHealthBarByHit = true;
public bool alwaysShowHealthBar = false;
public bool showHitNumber = true;
Fullscreen,
Windowed,
Borderless
}
// 当前游戏设置
public GameSettings CurrentSettings = new();
// 窗口模式枚举
public enum WindowMode { Fullscreen, Windowed, Borderless }
// 常用分辨率选项
public static readonly Vector2Int[] CommonResolutions = new Vector2Int[]
public static readonly Vector2Int[] CommonResolutions =
{
new(800, 600),
new(1024, 768),
@@ -45,6 +30,9 @@ namespace Base
new(3840, 2160)
};
// 当前游戏设置
public GameSettings CurrentSettings = new();
// 初始化加载设置
public void Init()
{
@@ -57,7 +45,7 @@ namespace Base
PlayerPrefs.SetString("GameSettings", json);
PlayerPrefs.Save();
}
public void LoadSettings()
{
if (PlayerPrefs.HasKey("GameSettings"))
@@ -80,7 +68,7 @@ namespace Base
ApplyAudioSettings();
ApplyWindowSettings();
}
// 应用音频设置
private void ApplyAudioSettings()
{
@@ -93,15 +81,38 @@ namespace Base
switch (CurrentSettings.currentWindowMode)
{
case WindowMode.Fullscreen:
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.FullScreenWindow);
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y,
FullScreenMode.FullScreenWindow);
break;
case WindowMode.Windowed:
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.Windowed);
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y,
FullScreenMode.Windowed);
break;
case WindowMode.Borderless:
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y, FullScreenMode.MaximizedWindow);
Screen.SetResolution(CurrentSettings.windowResolution.x, CurrentSettings.windowResolution.y,
FullScreenMode.MaximizedWindow);
break;
}
}
// 游戏设置数据类(用于序列化)
[Serializable]
public class GameSettings
{
public float progressStepDuration = 0.5f;
public float exitAnimationDuration = 1f;
public bool developerMode; // 默认值仍为 false在编辑器中会被覆盖
public bool friendlyFire;
public bool showMiniMap = true;
public float globalVolume = 1.0f;
public WindowMode currentWindowMode = WindowMode.Fullscreen;
public Vector2Int windowResolution = new(1920, 1080);
public string[] loadOrder;
public bool showHealthBarByHit = true;
public bool alwaysShowHealthBar;
public bool showHitNumber = true;
}
}
}
}