继续调整,创建 Procedure 与 Presentation 程序集
- 创建 Procedure 与 Presentation 两个程序集 - 初步解决这两个程序集与原程序集的引用关系
This commit is contained in:
+13
-24
@@ -10,48 +10,37 @@ using GameFramework;
|
||||
using StarForce;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace CustomComponent
|
||||
{
|
||||
public class BuiltinDataComponent : GameFrameworkComponent
|
||||
{
|
||||
[SerializeField]
|
||||
private TextAsset m_BuildInfoTextAsset = null;
|
||||
[FormerlySerializedAs("m_BuildInfoTextAsset")] [SerializeField]
|
||||
private TextAsset _buildInfoTextAsset = null;
|
||||
|
||||
[SerializeField]
|
||||
private TextAsset m_DefaultDictionaryTextAsset = null;
|
||||
[FormerlySerializedAs("m_DefaultDictionaryTextAsset")] [SerializeField]
|
||||
private TextAsset _defaultDictionaryTextAsset = null;
|
||||
|
||||
[SerializeField]
|
||||
private UpdateResourceForm m_UpdateResourceFormTemplate = null;
|
||||
[FormerlySerializedAs("m_UpdateResourceFormTemplate")] [SerializeField]
|
||||
private GameObject _updateResourceFormTemplate = null;
|
||||
|
||||
private BuildInfo m_BuildInfo = null;
|
||||
|
||||
public BuildInfo BuildInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_BuildInfo;
|
||||
}
|
||||
}
|
||||
public BuildInfo BuildInfo => m_BuildInfo;
|
||||
|
||||
public UpdateResourceForm UpdateResourceFormTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_UpdateResourceFormTemplate;
|
||||
}
|
||||
}
|
||||
public GameObject UpdateResourceFormTemplate => _updateResourceFormTemplate;
|
||||
|
||||
public void InitBuildInfo()
|
||||
{
|
||||
if (m_BuildInfoTextAsset == null || string.IsNullOrEmpty(m_BuildInfoTextAsset.text))
|
||||
if (_buildInfoTextAsset == null || string.IsNullOrEmpty(_buildInfoTextAsset.text))
|
||||
{
|
||||
Log.Info("Build info can not be found or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_BuildInfo = Utility.Json.ToObject<BuildInfo>(m_BuildInfoTextAsset.text);
|
||||
m_BuildInfo = Utility.Json.ToObject<BuildInfo>(_buildInfoTextAsset.text);
|
||||
if (m_BuildInfo == null)
|
||||
{
|
||||
Log.Warning("Parse build info failure.");
|
||||
@@ -61,13 +50,13 @@ namespace CustomComponent
|
||||
|
||||
public void InitDefaultDictionary()
|
||||
{
|
||||
if (m_DefaultDictionaryTextAsset == null || string.IsNullOrEmpty(m_DefaultDictionaryTextAsset.text))
|
||||
if (_defaultDictionaryTextAsset == null || string.IsNullOrEmpty(_defaultDictionaryTextAsset.text))
|
||||
{
|
||||
Log.Info("Default dictionary can not be found or empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GameEntry.Localization.ParseData(m_DefaultDictionaryTextAsset.text))
|
||||
if (!GameEntry.Localization.ParseData(_defaultDictionaryTextAsset.text))
|
||||
{
|
||||
Log.Warning("Parse default dictionary failure.");
|
||||
return;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a11ef2e359b24bfdb6c9120cc2ec81b8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-527
@@ -1,527 +0,0 @@
|
||||
#if UNITY_EDITOR || DEVELOPMENT_BUILD
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Components;
|
||||
using SepCore.Event;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using Entity;
|
||||
using CustomUtility;
|
||||
using Procedure;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace CustomComponent
|
||||
{
|
||||
public class RuntimeDebugPanelComponent : GameFrameworkComponent
|
||||
{
|
||||
private const float MinSpawnRate = 0.1f;
|
||||
private const float CornerTapWindow = 0.6f;
|
||||
private const int RequiredCornerTapCount = 3;
|
||||
private const int DebugHealAmount = 200;
|
||||
|
||||
[Header("Window Content")]
|
||||
[SerializeField] private bool _showBuffSection = true;
|
||||
[SerializeField] private bool _showBattleOverview = true;
|
||||
[SerializeField] private bool _showCollisionStats = true;
|
||||
[SerializeField] private bool _showSpawnControls = true;
|
||||
[SerializeField] private bool _showBattleDurationControls = true;
|
||||
[SerializeField] private bool _showPlayerWeaponControls = true;
|
||||
[SerializeField] private bool _showPlayerHealthControls = true;
|
||||
[SerializeField] private bool _showTips = true;
|
||||
|
||||
private Rect _windowRect = new Rect(20f, 60f, 460f, 800f);
|
||||
private bool _isPanelVisible;
|
||||
private int _windowId;
|
||||
|
||||
private string _searchText = string.Empty;
|
||||
private int _selectedIndex;
|
||||
private int _addCount = 1;
|
||||
private Vector2 _buffScroll;
|
||||
|
||||
private float _spawnRateScaleInput = 1f;
|
||||
private float _extendDurationSeconds = 30f;
|
||||
|
||||
private DRProp[] _allProps = Array.Empty<DRProp>();
|
||||
private DRProp[] _filteredProps = Array.Empty<DRProp>();
|
||||
private string[] _displayNames = Array.Empty<string>();
|
||||
|
||||
private int _cornerTapCount;
|
||||
private float _lastCornerTapTime = -10f;
|
||||
private bool _lockPlayerHealthToMax;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
_windowId = GetInstanceID();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (IsTogglePressed())
|
||||
{
|
||||
_isPanelVisible = !_isPanelVisible;
|
||||
}
|
||||
|
||||
HandleCornerTapGesture();
|
||||
if (_lockPlayerHealthToMax)
|
||||
{
|
||||
KeepPlayerHealthAtMax();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
DrawToggleButton();
|
||||
if (!_isPanelVisible) return;
|
||||
|
||||
_windowRect = GUI.Window(_windowId, _windowRect, DrawWindow, "Runtime Debug Panel");
|
||||
}
|
||||
|
||||
private void DrawToggleButton()
|
||||
{
|
||||
const float width = 64f;
|
||||
const float height = 30f;
|
||||
Rect buttonRect = new Rect(Screen.width - width - 12f, 10f, width, height);
|
||||
if (GUI.Button(buttonRect, "DEBUG"))
|
||||
{
|
||||
_isPanelVisible = !_isPanelVisible;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawWindow(int windowId)
|
||||
{
|
||||
if (_showBuffSection)
|
||||
{
|
||||
EnsurePropList();
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
bool hasPreviousSection = false;
|
||||
if (_showBuffSection)
|
||||
{
|
||||
DrawBuffSection();
|
||||
hasPreviousSection = true;
|
||||
}
|
||||
|
||||
if (HasVisibleBattleSection())
|
||||
{
|
||||
if (hasPreviousSection)
|
||||
{
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label(string.Empty, GUI.skin.horizontalSlider);
|
||||
GUILayout.Space(8f);
|
||||
}
|
||||
|
||||
DrawBattleSection();
|
||||
hasPreviousSection = true;
|
||||
}
|
||||
|
||||
if (_showTips)
|
||||
{
|
||||
if (hasPreviousSection)
|
||||
{
|
||||
GUILayout.Space(8f);
|
||||
}
|
||||
|
||||
GUILayout.Label("Tips: press `F8` or tap top-left corner 3 times to toggle.", GUILayout.Height(20f));
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUI.DragWindow(new Rect(0, 0, 10000, 22));
|
||||
}
|
||||
|
||||
private void DrawBuffSection()
|
||||
{
|
||||
GUILayout.Label("Buff Debug");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Search", GUILayout.Width(52f));
|
||||
_searchText = GUILayout.TextField(_searchText);
|
||||
if (GUILayout.Button("Refresh", GUILayout.Width(80f)))
|
||||
{
|
||||
EnsurePropList(true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ApplyFilter(_searchText);
|
||||
if (_displayNames.Length == 0)
|
||||
{
|
||||
GUILayout.Label("No Buff data. Enter battle and try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1);
|
||||
_buffScroll = GUILayout.BeginScrollView(_buffScroll, GUILayout.Height(120f));
|
||||
_selectedIndex = GUILayout.SelectionGrid(_selectedIndex, _displayNames, 1);
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
DRProp selectedProp = GetSelectedProp();
|
||||
if (selectedProp == null) return;
|
||||
|
||||
GUILayout.Label($"Selected: {selectedProp.Title} ({selectedProp.Rarity})");
|
||||
GUILayout.Label(ItemDescUtility.CreatePropDescription(selectedProp.Modifiers), GUILayout.Height(40f));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Count", GUILayout.Width(52f));
|
||||
string addCountText = GUILayout.TextField(_addCount.ToString(), GUILayout.Width(60f));
|
||||
if (!int.TryParse(addCountText, out _addCount)) _addCount = 1;
|
||||
_addCount = Mathf.Clamp(_addCount, 1, 99);
|
||||
|
||||
if (GUILayout.Button("Add Buff To Player", GUILayout.Height(24f)))
|
||||
{
|
||||
AddSelectedBuffToPlayer(selectedProp, _addCount);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void DrawBattleSection()
|
||||
{
|
||||
GUILayout.Label("Battle Debug");
|
||||
ProcedureGame procedure = GameEntry.Procedure.CurrentProcedure as ProcedureGame;
|
||||
EnemyManagerComponent enemyManager = GameEntry.EnemyManager;
|
||||
Player player = FindPlayer();
|
||||
HealthComponent playerHealth = player != null ? player.GetComponent<HealthComponent>() : null;
|
||||
|
||||
if (enemyManager == null)
|
||||
{
|
||||
GUILayout.Label("EnemyManager unavailable.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (procedure == null)
|
||||
{
|
||||
GUILayout.Label("ProcedureGame unavailable.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_showBattleOverview)
|
||||
{
|
||||
GUILayout.Label($"Spawn Rate: {enemyManager.SpawnRateScale:F2}");
|
||||
GUILayout.Label($"Battle Time: {enemyManager.ElapsedBattleTime:F1}s / {enemyManager.BattleDuration:F1}s");
|
||||
GUILayout.Label($"Enemy Count: {enemyManager.CurrentEnemyCount}");
|
||||
}
|
||||
|
||||
Simulation.SimulationWorld simulationWorld = GameEntry.SimulationWorld;
|
||||
if (_showCollisionStats && simulationWorld != null)
|
||||
{
|
||||
GUILayout.Space(4f);
|
||||
GUILayout.Label(
|
||||
$"Collision Queries: total {simulationWorld.LastCollisionQueryCount} (Projectile {simulationWorld.LastProjectileCollisionQueryCount} / Area {simulationWorld.LastAreaCollisionQueryCount})");
|
||||
GUILayout.Label(
|
||||
$"Collision Candidates: total {simulationWorld.LastCollisionCandidateCount} (Projectile {simulationWorld.LastProjectileCollisionCandidateCount} / Area {simulationWorld.LastAreaCollisionCandidateCount})");
|
||||
GUILayout.Label(
|
||||
$"Area Resolve: hits {simulationWorld.LastResolvedAreaHitCount}");
|
||||
GUILayout.Label(
|
||||
$"Broad Phase: cell {simulationWorld.LastCollisionCellSize:F2}, hasEnemyTargets {(simulationWorld.LastCollisionHasEnemyTargets ? "Yes" : "No")}");
|
||||
if (simulationWorld.LastCollisionCandidateCount != 0)
|
||||
{
|
||||
Log.Info($"LastCollisionCandidateCount:{simulationWorld.LastCollisionCandidateCount}");
|
||||
}
|
||||
|
||||
if (simulationWorld.LastResolvedAreaHitCount != 0)
|
||||
{
|
||||
Log.Info($"LastResolvedAreaHitCount:{simulationWorld.LastResolvedAreaHitCount}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_showSpawnControls)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Rate", GUILayout.Width(52f));
|
||||
string rateText = GUILayout.TextField(_spawnRateScaleInput.ToString("F2"), GUILayout.Width(60f));
|
||||
if (float.TryParse(rateText, out float parsedRate))
|
||||
{
|
||||
_spawnRateScaleInput = Mathf.Clamp(parsedRate, MinSpawnRate, 50f);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Apply", GUILayout.Width(70f)))
|
||||
{
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("x0.5", GUILayout.Width(60f)))
|
||||
{
|
||||
_spawnRateScaleInput = Mathf.Max(MinSpawnRate, enemyManager.SpawnRateScale * 0.5f);
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("x2", GUILayout.Width(60f)))
|
||||
{
|
||||
_spawnRateScaleInput = enemyManager.SpawnRateScale * 2f;
|
||||
enemyManager.SetSpawnRateScale(_spawnRateScaleInput);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (_showBattleDurationControls)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Add Sec", GUILayout.Width(52f));
|
||||
string durationText = GUILayout.TextField(_extendDurationSeconds.ToString("F0"), GUILayout.Width(60f));
|
||||
if (float.TryParse(durationText, out float parsedDuration))
|
||||
{
|
||||
_extendDurationSeconds = Mathf.Clamp(parsedDuration, 1f, 3600f);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Extend Battle", GUILayout.Height(24f)))
|
||||
{
|
||||
if (procedure.CurrentGameState is GameStateBattle gameState)
|
||||
{
|
||||
gameState.AddBattleDuration(_extendDurationSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (_showPlayerWeaponControls)
|
||||
{
|
||||
GUILayout.Label(
|
||||
$"Player Weapon: {(player == null ? "Player not found" : (player.WeaponEnabled ? "Enabled" : "Disabled"))}");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.enabled = player != null;
|
||||
if (GUILayout.Button("Disable Weapons", GUILayout.Height(24f)))
|
||||
{
|
||||
player.SetWeaponEnabled(false);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Enable Weapons", GUILayout.Height(24f)))
|
||||
{
|
||||
player.SetWeaponEnabled(true);
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (_showPlayerHealthControls)
|
||||
{
|
||||
GUILayout.Space(4f);
|
||||
GUILayout.Label(
|
||||
$"Player HP: {(playerHealth == null ? "Unavailable" : $"{playerHealth.CurrentHealth}/{playerHealth.MaxHealth}")}");
|
||||
GUILayout.BeginHorizontal();
|
||||
GUI.enabled = playerHealth != null;
|
||||
if (GUILayout.Button($"+{DebugHealAmount} HP", GUILayout.Height(24f)))
|
||||
{
|
||||
AddPlayerHealth(playerHealth, DebugHealAmount);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(_lockPlayerHealthToMax ? "GodMode: ON" : "GodMode: OFF", GUILayout.Height(24f)))
|
||||
{
|
||||
_lockPlayerHealthToMax = !_lockPlayerHealthToMax;
|
||||
if (_lockPlayerHealthToMax)
|
||||
{
|
||||
RestorePlayerHealthToMax(playerHealth);
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = true;
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasVisibleBattleSection()
|
||||
{
|
||||
return _showBattleOverview ||
|
||||
_showCollisionStats ||
|
||||
_showSpawnControls ||
|
||||
_showBattleDurationControls ||
|
||||
_showPlayerWeaponControls ||
|
||||
_showPlayerHealthControls;
|
||||
}
|
||||
|
||||
private void EnsurePropList(bool force = false)
|
||||
{
|
||||
if (!force && _allProps != null && _allProps.Length > 0) return;
|
||||
|
||||
if (GameEntry.DataTable == null)
|
||||
{
|
||||
_allProps = Array.Empty<DRProp>();
|
||||
_filteredProps = Array.Empty<DRProp>();
|
||||
_displayNames = Array.Empty<string>();
|
||||
return;
|
||||
}
|
||||
|
||||
var table = GameEntry.DataTable.GetDataTable<DRProp>();
|
||||
_allProps = table != null ? table.ToArray() : Array.Empty<DRProp>();
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, Mathf.Max(0, _allProps.Length - 1));
|
||||
ApplyFilter(_searchText);
|
||||
}
|
||||
|
||||
private void ApplyFilter(string keyword)
|
||||
{
|
||||
if (_allProps == null || _allProps.Length == 0)
|
||||
{
|
||||
_filteredProps = Array.Empty<DRProp>();
|
||||
_displayNames = Array.Empty<string>();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
_filteredProps = _allProps;
|
||||
}
|
||||
else
|
||||
{
|
||||
string search = keyword.Trim();
|
||||
_filteredProps = _allProps.Where(p =>
|
||||
p != null &&
|
||||
(p.Title?.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
p.Id.ToString().Contains(search))).ToArray();
|
||||
}
|
||||
|
||||
_displayNames = _filteredProps.Select(p => $"[{p.Id}] {p.Title} ({p.Rarity})").ToArray();
|
||||
if (_displayNames.Length == 0) _selectedIndex = 0;
|
||||
else _selectedIndex = Mathf.Clamp(_selectedIndex, 0, _displayNames.Length - 1);
|
||||
}
|
||||
|
||||
private DRProp GetSelectedProp()
|
||||
{
|
||||
if (_filteredProps == null || _filteredProps.Length == 0) return null;
|
||||
_selectedIndex = Mathf.Clamp(_selectedIndex, 0, _filteredProps.Length - 1);
|
||||
return _filteredProps[_selectedIndex];
|
||||
}
|
||||
|
||||
private static Player FindPlayer()
|
||||
{
|
||||
return UnityEngine.Object.FindObjectOfType<Player>();
|
||||
}
|
||||
|
||||
private void KeepPlayerHealthAtMax()
|
||||
{
|
||||
Player player = FindPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
HealthComponent playerHealth = player.GetComponent<HealthComponent>();
|
||||
if (playerHealth == null) return;
|
||||
|
||||
RestorePlayerHealthToMax(playerHealth);
|
||||
}
|
||||
|
||||
private static void AddPlayerHealth(HealthComponent playerHealth, int amount)
|
||||
{
|
||||
if (playerHealth == null || amount <= 0) return;
|
||||
if (playerHealth.CurrentHealth <= 0) return;
|
||||
|
||||
int maxHealth = playerHealth.MaxHealth;
|
||||
if (maxHealth <= 0) return;
|
||||
|
||||
int nextHealth = Mathf.Clamp(playerHealth.CurrentHealth + amount, 0, maxHealth);
|
||||
if (nextHealth == playerHealth.CurrentHealth) return;
|
||||
|
||||
playerHealth.CurrentHealth = nextHealth;
|
||||
PublishPlayerHealthChanged(playerHealth);
|
||||
}
|
||||
|
||||
private static void RestorePlayerHealthToMax(HealthComponent playerHealth)
|
||||
{
|
||||
if (playerHealth == null) return;
|
||||
if (playerHealth.CurrentHealth <= 0) return;
|
||||
|
||||
int maxHealth = playerHealth.MaxHealth;
|
||||
if (maxHealth <= 0 || playerHealth.CurrentHealth >= maxHealth) return;
|
||||
|
||||
playerHealth.CurrentHealth = maxHealth;
|
||||
PublishPlayerHealthChanged(playerHealth);
|
||||
}
|
||||
|
||||
private static void PublishPlayerHealthChanged(HealthComponent playerHealth)
|
||||
{
|
||||
if (playerHealth == null || GameEntry.Event == null) return;
|
||||
|
||||
GameEntry.Event.Fire(null,
|
||||
PlayerHealthChangeEventArgs.Create(0, playerHealth.CurrentHealth, playerHealth.MaxHealth));
|
||||
}
|
||||
|
||||
private static void AddSelectedBuffToPlayer(DRProp prop, int count)
|
||||
{
|
||||
Player player = FindPlayer();
|
||||
if (player == null || prop == null || prop.Modifiers == null) return;
|
||||
|
||||
int applyCount = Mathf.Clamp(count, 1, 99);
|
||||
for (int i = 0; i < applyCount; i++)
|
||||
{
|
||||
player.AddProp(new PropItem(prop.Modifiers, prop.Rarity, prop.Title, prop.IconAssetName));
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCornerTapGesture()
|
||||
{
|
||||
if (!TryGetTouchReleased(out Vector2 touchPosition)) return;
|
||||
if (touchPosition.x > 80f || touchPosition.y < Screen.height - 80f) return;
|
||||
|
||||
float now = Time.unscaledTime;
|
||||
if (now - _lastCornerTapTime > CornerTapWindow)
|
||||
{
|
||||
_cornerTapCount = 0;
|
||||
}
|
||||
|
||||
_lastCornerTapTime = now;
|
||||
_cornerTapCount++;
|
||||
|
||||
if (_cornerTapCount >= RequiredCornerTapCount)
|
||||
{
|
||||
_cornerTapCount = 0;
|
||||
_isPanelVisible = !_isPanelVisible;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsTogglePressed()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
Keyboard keyboard = Keyboard.current;
|
||||
if (keyboard == null) return false;
|
||||
return keyboard.backquoteKey.wasPressedThisFrame || keyboard.f8Key.wasPressedThisFrame;
|
||||
#else
|
||||
return Input.GetKeyDown(KeyCode.BackQuote) || Input.GetKeyDown(KeyCode.F8);
|
||||
#endif
|
||||
}
|
||||
|
||||
private static bool TryGetTouchReleased(out Vector2 touchPosition)
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
Touchscreen touchscreen = Touchscreen.current;
|
||||
if (touchscreen == null)
|
||||
{
|
||||
touchPosition = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
var touch = touchscreen.primaryTouch;
|
||||
if (!touch.press.wasReleasedThisFrame)
|
||||
{
|
||||
touchPosition = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
touchPosition = touch.position.ReadValue();
|
||||
return true;
|
||||
#else
|
||||
if (Input.touchCount <= 0)
|
||||
{
|
||||
touchPosition = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
Touch touch = Input.GetTouch(0);
|
||||
if (touch.phase != TouchPhase.Ended)
|
||||
{
|
||||
touchPosition = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
touchPosition = touch.position;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d8ada5157a04921a6e543a040e57960
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,8 +4,6 @@ using SepCore.Definition;
|
||||
using Entity;
|
||||
using Entity.EntityData;
|
||||
using GameFramework.Event;
|
||||
using Procedure;
|
||||
using StarForce;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using Entity;
|
||||
using GameFramework;
|
||||
using GameFramework.DataTable;
|
||||
using GameFramework.Sound;
|
||||
using UnityGameFramework.Runtime;
|
||||
using CustomUtility;
|
||||
|
||||
namespace StarForce
|
||||
{
|
||||
public static class SoundExtension
|
||||
{
|
||||
private const float FadeVolumeDuration = 1f;
|
||||
private static int? s_MusicSerialId = null;
|
||||
|
||||
public static int? PlayMusic(this SoundComponent soundComponent, int musicId, object userData = null)
|
||||
{
|
||||
soundComponent.StopMusic();
|
||||
|
||||
IDataTable<DRMusic> dtMusic = GameEntry.DataTable.GetDataTable<DRMusic>();
|
||||
DRMusic drMusic = dtMusic.GetDataRow(musicId);
|
||||
if (drMusic == null)
|
||||
{
|
||||
Log.Warning("Can not load music '{0}' from data table.", musicId.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
PlaySoundParams playSoundParams = PlaySoundParams.Create();
|
||||
playSoundParams.Priority = 64;
|
||||
playSoundParams.Loop = true;
|
||||
playSoundParams.VolumeInSoundGroup = 1f;
|
||||
playSoundParams.FadeInSeconds = FadeVolumeDuration;
|
||||
playSoundParams.SpatialBlend = 0f;
|
||||
s_MusicSerialId = soundComponent.PlaySound(AssetUtility.GetMusicAsset(drMusic.AssetName), "Music", Constant.AssetPriority.MusicAsset, playSoundParams, null, userData);
|
||||
return s_MusicSerialId;
|
||||
}
|
||||
|
||||
public static void StopMusic(this SoundComponent soundComponent)
|
||||
{
|
||||
if (!s_MusicSerialId.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
soundComponent.StopSound(s_MusicSerialId.Value, FadeVolumeDuration);
|
||||
s_MusicSerialId = null;
|
||||
}
|
||||
|
||||
public static int? PlaySound(this SoundComponent soundComponent, int soundId, EntityBase bindingEntity = null, object userData = null)
|
||||
{
|
||||
IDataTable<DRSound> dtSound = GameEntry.DataTable.GetDataTable<DRSound>();
|
||||
DRSound drSound = dtSound.GetDataRow(soundId);
|
||||
if (drSound == null)
|
||||
{
|
||||
Log.Warning("Can not load sound '{0}' from data table.", soundId.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
PlaySoundParams playSoundParams = PlaySoundParams.Create();
|
||||
playSoundParams.Priority = drSound.Priority;
|
||||
playSoundParams.Loop = drSound.Loop;
|
||||
playSoundParams.VolumeInSoundGroup = drSound.Volume;
|
||||
playSoundParams.SpatialBlend = drSound.SpatialBlend;
|
||||
return soundComponent.PlaySound(AssetUtility.GetSoundAsset(drSound.AssetName), "Sound", Constant.AssetPriority.SoundAsset, playSoundParams, bindingEntity != null ? bindingEntity.Entity : null, userData);
|
||||
}
|
||||
|
||||
public static int? PlayUISound(this SoundComponent soundComponent, int uiSoundId, object userData = null)
|
||||
{
|
||||
IDataTable<DRUISound> dtUISound = GameEntry.DataTable.GetDataTable<DRUISound>();
|
||||
DRUISound drUISound = dtUISound.GetDataRow(uiSoundId);
|
||||
if (drUISound == null)
|
||||
{
|
||||
Log.Warning("Can not load UI sound '{0}' from data table.", uiSoundId.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
PlaySoundParams playSoundParams = PlaySoundParams.Create();
|
||||
playSoundParams.Priority = drUISound.Priority;
|
||||
playSoundParams.Loop = false;
|
||||
playSoundParams.VolumeInSoundGroup = drUISound.Volume;
|
||||
playSoundParams.SpatialBlend = 0f;
|
||||
return soundComponent.PlaySound(AssetUtility.GetUISoundAsset(drUISound.AssetName), "UISound", Constant.AssetPriority.UISoundAsset, playSoundParams, userData);
|
||||
}
|
||||
|
||||
public static bool IsMuted(this SoundComponent soundComponent, string soundGroupName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(soundGroupName))
|
||||
{
|
||||
Log.Warning("Sound group is invalid.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
|
||||
if (soundGroup == null)
|
||||
{
|
||||
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
|
||||
return true;
|
||||
}
|
||||
|
||||
return soundGroup.Mute;
|
||||
}
|
||||
|
||||
public static void Mute(this SoundComponent soundComponent, string soundGroupName, bool mute)
|
||||
{
|
||||
if (string.IsNullOrEmpty(soundGroupName))
|
||||
{
|
||||
Log.Warning("Sound group is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
|
||||
if (soundGroup == null)
|
||||
{
|
||||
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
|
||||
return;
|
||||
}
|
||||
|
||||
soundGroup.Mute = mute;
|
||||
|
||||
GameEntry.Setting.SetBool(Utility.Text.Format(Constant.Setting.SoundGroupMuted, soundGroupName), mute);
|
||||
GameEntry.Setting.Save();
|
||||
}
|
||||
|
||||
public static float GetVolume(this SoundComponent soundComponent, string soundGroupName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(soundGroupName))
|
||||
{
|
||||
Log.Warning("Sound group is invalid.");
|
||||
return 0f;
|
||||
}
|
||||
|
||||
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
|
||||
if (soundGroup == null)
|
||||
{
|
||||
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
|
||||
return 0f;
|
||||
}
|
||||
|
||||
return soundGroup.Volume;
|
||||
}
|
||||
|
||||
public static void SetVolume(this SoundComponent soundComponent, string soundGroupName, float volume)
|
||||
{
|
||||
if (string.IsNullOrEmpty(soundGroupName))
|
||||
{
|
||||
Log.Warning("Sound group is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);
|
||||
if (soundGroup == null)
|
||||
{
|
||||
Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
|
||||
return;
|
||||
}
|
||||
|
||||
soundGroup.Volume = volume;
|
||||
|
||||
GameEntry.Setting.SetFloat(Utility.Text.Format(Constant.Setting.SoundGroupVolume, soundGroupName), volume);
|
||||
GameEntry.Setting.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cded0c5c73a207a498c6e5af208e5f7e
|
||||
timeCreated: 1528026160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user