- 调整项目结构以适应打包需求

- 添加控制台便于在游戏运行过程中调试各项功能
- 添加 LevelRarity 表,增加了随关卡数动态调整的商品道具品质刷新概率
This commit is contained in:
SepComet
2026-02-18 22:53:33 +08:00
parent e151619c69
commit b4bc8b0445
202 changed files with 5160 additions and 3393 deletions
@@ -0,0 +1,101 @@
using System;
using Definition.DataStruct;
using Definition.Enum;
using Entity;
using UnityEngine;
namespace Components
{
public class AbsorbComponent : MonoBehaviour
{
[SerializeField] private float _absorbRangeBase = 3f;
[SerializeField] private float _absorbSpeed = 15f;
[SerializeField] private float _collectDistance = 0.35f;
[SerializeField] private int _maxDetectCount = 64;
[SerializeField] private LayerMask _detectLayerMask = ~0;
private Player _player;
private Transform _target;
private StatComponent _statComponent;
private Collider[] _buffer;
private StatProperty _absorbRangeStat;
private Action<StatModifier, bool> _absorbRangeStatCallback;
private float AbsorbRange => Mathf.Max(0f, (_absorbRangeBase + _absorbRangeStat.Value) * _absorbRangeStat.Percent);
public void OnInit(Player player, StatComponent statComponent = null)
{
_player = player;
_target = player != null ? player.CachedTransform : null;
_statComponent = statComponent;
_buffer = new Collider[Mathf.Max(1, _maxDetectCount)];
if (_statComponent != null)
{
_absorbRangeStat = _statComponent.GetStat(StatType.AbsorbRange);
_absorbRangeStatCallback = (modifier, isApply) =>
_statComponent.UpdateStat(_absorbRangeStat, modifier, isApply);
_statComponent.Subscribe(StatType.AbsorbRange, _absorbRangeStatCallback);
}
else
{
_absorbRangeStat = new StatProperty();
}
}
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
if (_player == null || !_player.Available || _target == null || _buffer == null) return;
int hitCount = Physics.OverlapSphereNonAlloc(
_target.position,
AbsorbRange,
_buffer,
_detectLayerMask,
QueryTriggerInteraction.Collide
);
for (int i = 0; i < hitCount; i++)
{
Collider hit = _buffer[i];
if (hit == null) continue;
CoinEntity coin = hit.GetComponent<CoinEntity>();
if (coin != null && coin.Available)
{
AbsorbDrop(coin.CachedTransform, elapseSeconds);
coin.TryCollect(_player, _collectDistance);
continue;
}
ExpEntity exp = hit.GetComponent<ExpEntity>();
if (exp != null && exp.Available)
{
AbsorbDrop(exp.CachedTransform, elapseSeconds);
exp.TryCollect(_player, _collectDistance);
}
}
}
public void OnReset()
{
if (_statComponent != null)
{
_statComponent.Unsubscribe(StatType.AbsorbRange, _absorbRangeStatCallback);
_absorbRangeStatCallback = null;
}
_statComponent = null;
_target = null;
_player = null;
_buffer = null;
}
private void AbsorbDrop(Transform drop, float deltaTime)
{
if (drop == null || _target == null) return;
drop.position = Vector3.MoveTowards(drop.position, _target.position, _absorbSpeed * deltaTime);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46f46350fed64d8389ebb4ae72b65796
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,4 @@
using System;
using System;
using CustomEvent;
using Definition.DataStruct;
using Definition.Enum;
@@ -119,7 +119,9 @@ namespace Components
private void CauseDamage(int damage)
{
//TODO:受击效果:跳字、粒子
if (damage <= 0 || GameEntry.DamageText == null) return;
GameEntry.DamageText.ShowDamage(transform.position + Vector3.up * 1.1f, damage);
}
}
}
}