1
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 相机模式
|
||||
/// </summary>
|
||||
public enum EnumCameraMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
MoveAxis,// 移轴
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 输入模式
|
||||
/// </summary>
|
||||
public enum EnumInputMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FixedPreview,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
Standard,// 第三人称
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fc2f524dbb594a40a4a13d3d253c53e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 页面类型
|
||||
/// </summary>
|
||||
public enum EnumPage {
|
||||
None,
|
||||
|
||||
Menu,// 主菜单
|
||||
Scene,// 场景选择
|
||||
Prepare,// 准备游戏
|
||||
Battle,// 战斗页面
|
||||
Settlement,// 结算页面
|
||||
|
||||
Settings,// 游戏设置
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 运行模式
|
||||
/// </summary>
|
||||
public enum EnumRunningMode {
|
||||
None,// 无模式
|
||||
|
||||
Standard,// 标准模式
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 043dda22a291d664fa2124109ddc8dd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -14,11 +14,20 @@ public abstract class CameraController : MonoBehaviour {
|
||||
public abstract Vector3 Right { get; set; }
|
||||
/// <summary> 旋转 </summary>
|
||||
public abstract Vector3 EulerAngles { get; set; }
|
||||
/// <summary> 距离 </summary>
|
||||
public abstract float Distance { get; set; }
|
||||
/// <summary> 视野 </summary>
|
||||
public abstract float VisualField { get; set; }
|
||||
|
||||
/// <summary> 初始化 </summary>
|
||||
public abstract void Initialize();
|
||||
public virtual void Initial() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
/// <summary> 释放 </summary>
|
||||
public virtual void Release() {
|
||||
ModuleCamera.OnCameraMode -= ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
/// <summary> 相机模式 </summary>
|
||||
public abstract void ModuleCamera_OnCameraMode(CameraMode mode);
|
||||
/// <summary> 重置相机 </summary>
|
||||
public abstract void ResetCamera();
|
||||
|
||||
|
||||
@@ -23,21 +23,17 @@ public class CameraDefault : CameraController {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
public override float Distance {
|
||||
public override float VisualField {
|
||||
get => throw new System.NotImplementedException();
|
||||
set => throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Initialize() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
private void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
public override void ModuleCamera_OnCameraMode(CameraMode mode) {
|
||||
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
|
||||
return;
|
||||
#endif
|
||||
gameObject.SetActive(mode == EnumCameraMode.None);
|
||||
if (mode == EnumCameraMode.None) { ModuleCamera.CurrentCamera = this; }
|
||||
gameObject.SetActive(mode == CameraMode.None);
|
||||
if (mode == CameraMode.None) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class CameraMoveAxis : CameraController {
|
||||
get => transform.eulerAngles;
|
||||
set => transform.eulerAngles = value;
|
||||
}
|
||||
public override float Distance {
|
||||
public override float VisualField {
|
||||
get => GetVisualField();
|
||||
set => SetVisualField(value);
|
||||
}
|
||||
@@ -44,13 +44,9 @@ public class CameraMoveAxis : CameraController {
|
||||
// depthOfField.focusDistance.SetValue(new FloatParameter(value));
|
||||
}
|
||||
|
||||
public override void Initialize() {
|
||||
ModuleCamera.OnCameraMode += ModuleCamera_OnCameraMode;
|
||||
}
|
||||
|
||||
private void ModuleCamera_OnCameraMode(EnumCameraMode mode) {
|
||||
gameObject.SetActive(mode == EnumCameraMode.MoveAxis);
|
||||
if (mode == EnumCameraMode.MoveAxis) { ModuleCamera.CurrentCamera = this; }
|
||||
public override void ModuleCamera_OnCameraMode(CameraMode mode) {
|
||||
gameObject.SetActive(mode == CameraMode.MoveAxis);
|
||||
if (mode == CameraMode.MoveAxis) { ModuleCamera.CurrentCamera = this; }
|
||||
}
|
||||
|
||||
public override void ResetCamera() {
|
||||
|
||||
@@ -8,23 +8,40 @@ using MuHua;
|
||||
/// 相机模块
|
||||
/// </summary>
|
||||
public class ModuleCamera : ModuleSingle<ModuleCamera> {
|
||||
|
||||
/// <summary> 当前相机 </summary>
|
||||
public static CameraController CurrentCamera;
|
||||
/// <summary> 相机模式事件 </summary>
|
||||
public static event Action<EnumCameraMode> OnCameraMode;
|
||||
public static event Action<CameraMode> OnCameraMode;
|
||||
|
||||
/// <summary> 设置相机模式 </summary>
|
||||
public static void Mode(EnumCameraMode mode, bool isReset = true) {
|
||||
public static void Settings(CameraMode mode, bool isReset = true) {
|
||||
OnCameraMode?.Invoke(mode);
|
||||
if (isReset) { I.ResetCamera(); }
|
||||
}
|
||||
|
||||
public List<CameraController> cameras;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
protected override void Awake() {
|
||||
NoReplace();
|
||||
cameras.ForEach(obj => obj.Initial());
|
||||
}
|
||||
|
||||
private void Start() => cameras.ForEach(obj => obj.Initialize());
|
||||
private void OnDestroy() => cameras.ForEach(obj => obj.Release());
|
||||
|
||||
/// <summary> 重置相机 </summary>
|
||||
public void ResetCamera() => cameras.ForEach(obj => obj.ResetCamera());
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 相机模式
|
||||
/// </summary>
|
||||
public enum CameraMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
MoveAxis,// 移轴
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
/// <summary>
|
||||
/// 输入 - 控制
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PlayerInput))]
|
||||
public abstract class InputControl : MonoBehaviour {
|
||||
|
||||
protected virtual void Awake() {
|
||||
ModuleInput.OnInputMode += ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy() {
|
||||
ModuleInput.OnInputMode -= ModuleInput_OnInputMode;
|
||||
}
|
||||
|
||||
/// <summary> 输入模式 </summary>
|
||||
protected abstract void ModuleInput_OnInputMode(InputMode mode);
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 398ffa613e85ac24b9a554499e7d6784
|
||||
guid: 3136d74b1e24ab9449f7f63c0344bfd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -11,26 +11,30 @@ using MuHua;
|
||||
public class ModuleInput : ModuleSingle<ModuleInput> {
|
||||
|
||||
/// <summary> 当前输入模式 </summary>
|
||||
public static EnumInputMode inputMode;
|
||||
public static InputMode Current;
|
||||
/// <summary> 回退输入模式 </summary>
|
||||
public static InputMode BackMode;
|
||||
/// <summary> 鼠标指针位置 </summary>
|
||||
public static Vector3 mousePosition;
|
||||
public static Vector2 mousePosition;
|
||||
/// <summary> 转换模式事件 </summary>
|
||||
public static event Action<EnumInputMode> OnInputMode;
|
||||
/// <summary> 临时禁用事件 </summary>
|
||||
public static event Action<bool> OnTemporarilyDisable;
|
||||
|
||||
private static bool isPointerOverUIObject;// 指针是否在UI上
|
||||
public static event Action<InputMode> OnInputMode;
|
||||
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
private static bool isPointerOverUIObject;
|
||||
/// <summary> 指针是否在UI上 </summary>
|
||||
public static bool IsPointerOverUIObject => isPointerOverUIObject;
|
||||
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Mode(EnumInputMode mode) {
|
||||
inputMode = mode;
|
||||
OnInputMode?.Invoke(mode);
|
||||
public static void Settings(InputMode mode) {
|
||||
BackMode = Current;
|
||||
Current = mode;
|
||||
OnInputMode?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 设置输入模式 </summary>
|
||||
public static void Back() {
|
||||
Current = BackMode;
|
||||
OnInputMode?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 临时禁用输入 </summary>
|
||||
public static void TemporarilyDisable(bool value) => OnTemporarilyDisable?.Invoke(value);
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
@@ -50,3 +54,17 @@ public class ModuleInput : ModuleSingle<ModuleInput> {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 输入模式
|
||||
/// </summary>
|
||||
public enum InputMode {
|
||||
None,// 无
|
||||
|
||||
// FixedEdit,// 固定编辑
|
||||
|
||||
// FixedPreview,// 固定编辑
|
||||
|
||||
// FreeEdit,// 自由编辑
|
||||
|
||||
Standard,// 第三人称
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7a4f234254ca334f9e1c14310e920ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,55 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 六边形
|
||||
/// </summary>
|
||||
public class Hexagon : MonoBehaviour {
|
||||
|
||||
public Transform prefab;
|
||||
|
||||
private void Awake() {
|
||||
float size = 0.5f; // 可以根据实际需求调整边长
|
||||
for (int x = 0; x < 10; x++) {
|
||||
for (int y = 0; y < 10; y++) { Create(new Vector2Int(x, y), size); }
|
||||
}
|
||||
}
|
||||
private void Create(Vector2Int grid, float size) {
|
||||
Transform obj = Instantiate(prefab, transform);
|
||||
obj.position = GridToWorld(grid, size);
|
||||
obj.name = $"Hex_{grid}";
|
||||
obj.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取六边形网格的世界坐标
|
||||
/// </summary>
|
||||
/// <param name="grid">网格坐标(x, y)</param>
|
||||
/// <param name="size">六边形边长</param>
|
||||
/// <returns>世界坐标</returns>
|
||||
public static Vector3 GridToWorld(Vector2Int grid, float size) {
|
||||
float width = size * 2f;
|
||||
float height = Mathf.Sqrt(3f) * size;
|
||||
float offsetX = grid.x * (width * 0.75f);
|
||||
float offsetY = grid.y * height + (grid.x % 2 == 0 ? 0 : height / 2f);
|
||||
return new Vector3(offsetX, 0, offsetY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用世界坐标转换成六边形网格的x和y坐标
|
||||
/// </summary>
|
||||
/// <param name="worldPos">世界坐标</param>
|
||||
/// <param name="size">六边形边长</param>
|
||||
/// <returns>网格坐标(x, y)</returns>
|
||||
public static Vector2Int WorldToGrid(Vector3 worldPosition, float size) {
|
||||
float width = size * 2f;
|
||||
float height = Mathf.Sqrt(3f) * size;
|
||||
// 计算近似的x
|
||||
int x = Mathf.RoundToInt(worldPosition.x / (width * 0.75f));
|
||||
// 计算近似的y
|
||||
float yOffset = (x % 2 == 0) ? 0 : height / 2f;
|
||||
int y = Mathf.RoundToInt((worldPosition.z - yOffset) / height);
|
||||
return new Vector2Int(x, y);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90c26411725660045a445e742ce72bf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 场景 - 管理器
|
||||
/// </summary>
|
||||
public class ManagerScene : ModuleSingle<ManagerScene> {
|
||||
/// <summary> 场景加载完成 </summary>
|
||||
public static event Action OnCompleteLoad;
|
||||
/// <summary> 平滑进度 </summary>
|
||||
public float smoothedProgress;
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
#region 协程加载
|
||||
/// <summary> 协程加载内置场景 </summary>
|
||||
public void Load(string sceneName, Action complete = null, LoadSceneMode mode = LoadSceneMode.Single) {
|
||||
StartCoroutine(ILoad(sceneName, complete, mode));
|
||||
}
|
||||
/// <summary> 协程加载内置场景 </summary>
|
||||
public IEnumerator ILoad(string sceneName, Action complete, LoadSceneMode mode) {
|
||||
smoothedProgress = 0f;
|
||||
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName, mode);
|
||||
operation.allowSceneActivation = false;
|
||||
while (!operation.isDone) { yield return ILoad(operation); }
|
||||
SettingsProgress(false, smoothedProgress);
|
||||
complete?.Invoke();
|
||||
OnCompleteLoad?.Invoke();
|
||||
}
|
||||
/// <summary> 协程处理进度 </summary>
|
||||
public IEnumerator ILoad(AsyncOperation operation) {
|
||||
// 输出加载进度
|
||||
float progress = Mathf.Clamp01(operation.progress / 0.9f);
|
||||
smoothedProgress = Mathf.MoveTowards(smoothedProgress, progress, Time.deltaTime);
|
||||
SettingsProgress(true, smoothedProgress);
|
||||
// 当加载进度达到90%且平滑变量和实际进度一致时,激活场景
|
||||
if (operation.progress < 0.9f || smoothedProgress < 1f) { yield break; }
|
||||
operation.allowSceneActivation = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary> 设置进度 </summary>
|
||||
private void SettingsProgress(bool active, float progress) {
|
||||
// ModuleUI.LoadingSettings(active, progress);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e190b0f10e563546bd18df3605da42f
|
||||
guid: dc0f04b4d1e94e3469c593bff5d56655
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -4,46 +4,10 @@ using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏管理
|
||||
/// 全局管理
|
||||
/// </summary>
|
||||
public class SingleManager : ModuleSingle<SingleManager> {
|
||||
|
||||
/// <summary> 运行模式 </summary>
|
||||
public static EnumRunningMode runningMode;
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
/// <summary> 设置运行模式 </summary>
|
||||
public static void SetRunningMode(EnumRunningMode runningMode) {
|
||||
SingleManager.runningMode = runningMode;
|
||||
}
|
||||
|
||||
protected override void Awake() {
|
||||
NoReplace();
|
||||
// ManagerScene.OnComplete += ManagerScene_OnComplete;
|
||||
}
|
||||
private void Start() {
|
||||
// ModuleUI.Jump(EnumPage.Menu);
|
||||
// ModuleInput.Mode(EnumInputMode.None);
|
||||
// ModuleCamera.Mode(EnumCameraMode.None);
|
||||
// SceneManager.LoadScene("MenuScene");
|
||||
}
|
||||
|
||||
private void ManagerScene_OnComplete() {
|
||||
// if (runningMode == EnumRunningMode.None) {
|
||||
// ModuleUI.Jump(EnumPage.Menu);
|
||||
// ModuleInput.Mode(EnumInputMode.None);
|
||||
// ModuleCamera.Mode(EnumCameraMode.None);
|
||||
// }
|
||||
// if (runningMode == EnumRunningMode.Standard) {
|
||||
// ModuleUI.Jump(EnumPage.Battle);
|
||||
// // ModuleInput.Mode(EnumInputMode.ThirdPerson);
|
||||
// // ModuleCamera.Mode(EnumCameraMode.ThirdPerson);
|
||||
// }
|
||||
}
|
||||
|
||||
public void StartGame() {
|
||||
// ManagerScene.LoadScene(null);
|
||||
// ModuleUI.Jump(EnumPage.Battle);
|
||||
// ModuleInput.Mode(EnumInputMode.Standard);
|
||||
// ModuleCamera.Mode(EnumCameraMode.MoveAxis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ using MuHua;
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleSingle<ModuleUI> {
|
||||
public static EnumPage page;
|
||||
public static event Action<EnumPage> OnJumpPage;
|
||||
public static Page page;
|
||||
public static event Action<Page> OnJumpPage;
|
||||
|
||||
public UIDocument document;// 绑定文档
|
||||
|
||||
@@ -20,5 +20,19 @@ public class ModuleUI : ModuleSingle<ModuleUI> {
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Jump(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
|
||||
public static void Jump(Page pageType) => OnJumpPage?.Invoke(pageType);
|
||||
}
|
||||
/// <summary>
|
||||
/// 页面类型
|
||||
/// </summary>
|
||||
public enum Page {
|
||||
None,
|
||||
|
||||
Menu,// 主菜单
|
||||
Scene,// 场景选择
|
||||
Prepare,// 准备游戏
|
||||
Battle,// 战斗页面
|
||||
Settlement,// 结算页面
|
||||
|
||||
Settings,// 游戏设置
|
||||
}
|
||||
@@ -6,10 +6,13 @@ using UnityEngine;
|
||||
/// 可视化控制器
|
||||
/// </summary>
|
||||
public abstract class VisualController<T> : MonoBehaviour {
|
||||
|
||||
/// <summary> 更新可视化内容 </summary>
|
||||
public abstract void UpdateVisual(ref T visual);
|
||||
/// <summary> 释放可视化内容 </summary>
|
||||
public abstract void ReleaseVisual(T visual);
|
||||
/// <summary> 释放全部可视化内容 </summary>
|
||||
public abstract void ReleaseAllVisual();
|
||||
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static void Create<Type>(ref Type value, Transform original, Transform parent) {
|
||||
|
||||
@@ -8,9 +8,13 @@ using UnityEngine;
|
||||
public abstract class VisualGenerator<T> : MonoBehaviour {
|
||||
|
||||
/// <summary> 更新可视化内容 </summary>
|
||||
public abstract void CreateVisual(ref T visual, Transform original);
|
||||
public abstract T CreateVisual(Transform original);
|
||||
/// <summary> 更新可视化内容 </summary>
|
||||
public abstract void UpdateVisual(ref T visual, Transform original);
|
||||
/// <summary> 释放可视化内容 </summary>
|
||||
public abstract void ReleaseVisual(T visual);
|
||||
/// <summary> 释放全部可视化内容 </summary>
|
||||
public abstract void ReleaseAllVisual();
|
||||
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static Type Create<Type>(Transform original, Transform parent) {
|
||||
|
||||
Reference in New Issue
Block a user