替换玩家模型素材,添加 ChildrenMap 配置挂点
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Battle;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using UnityEngine;
|
||||
@@ -49,7 +50,7 @@ namespace SepCore.Components
|
||||
|
||||
_weapons = new List<WeaponBase>(WeaponCapacity);
|
||||
_props = new List<PropItem>();
|
||||
_statComponent = GetComponent<StatComponent>();
|
||||
_statComponent = player.StatComponent;
|
||||
_synergyManager.Initialize();
|
||||
}
|
||||
|
||||
@@ -76,12 +77,64 @@ namespace SepCore.Components
|
||||
if (result)
|
||||
{
|
||||
GameEntry.Entity.DetachEntity(weapon.Id, _player.Id);
|
||||
RealignWeaponSlots();
|
||||
_synergyManager.RefreshSynergies(_weapons, _statComponent.Pipeline);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void RealignWeaponSlots()
|
||||
{
|
||||
if (_weaponSlots == null || _player == null) return;
|
||||
|
||||
for (int i = 0; i < _weapons.Count; i++)
|
||||
{
|
||||
if (i < _weaponSlots.Length && _weapons[i] != null)
|
||||
{
|
||||
GameEntry.Entity.AttachEntity(_weapons[i].Id, _player.Id, _weaponSlots[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanCombineWeapon(int index, out int matchIndex, out WeaponConfig nextTierConfig)
|
||||
{
|
||||
matchIndex = -1;
|
||||
nextTierConfig = null;
|
||||
|
||||
if (_weapons == null || index < 0 || index >= _weapons.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
WeaponBase target = _weapons[index];
|
||||
if (target?.WeaponData == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WeaponUtility.TryGetNextTierConfig(target.WeaponData.Config, out nextTierConfig))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < _weapons.Count; i++)
|
||||
{
|
||||
if (i == index) continue;
|
||||
WeaponBase other = _weapons[i];
|
||||
if (other?.WeaponData == null) continue;
|
||||
|
||||
if (other.WeaponData.WeaponType == target.WeaponData.WeaponType &&
|
||||
other.WeaponData.Rarity == target.WeaponData.Rarity)
|
||||
{
|
||||
matchIndex = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AttachProp(PropItem prop)
|
||||
{
|
||||
_props.Add(prop);
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.Components
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ChildrenMap : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class Entry
|
||||
{
|
||||
[SerializeField] private string _key = string.Empty;
|
||||
[SerializeField] private GameObject _target = null;
|
||||
|
||||
public string Key => _key;
|
||||
public GameObject Target => _target;
|
||||
|
||||
public Entry()
|
||||
{
|
||||
}
|
||||
|
||||
public Entry(string key, GameObject target)
|
||||
{
|
||||
_key = key;
|
||||
_target = target;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] private List<Entry> _entries = new List<Entry>();
|
||||
|
||||
private Dictionary<string, GameObject> _map;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitMap();
|
||||
}
|
||||
|
||||
public GameObject Get(string key)
|
||||
{
|
||||
if (_map == null)
|
||||
{
|
||||
InitMap();
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
Log.Error("[ChildrenMap] Key is null or empty when getting child on '{0}'.", gameObject.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_map.TryGetValue(key, out GameObject target))
|
||||
{
|
||||
Log.Error("[ChildrenMap] Key '{0}' not found on '{1}'.", key, gameObject.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
Log.Error("[ChildrenMap] Target GameObject for key '{0}' is null on '{1}'.", key, gameObject.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
private void InitMap()
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_map = new Dictionary<string, GameObject>(_entries.Count);
|
||||
for (int i = 0; i < _entries.Count; i++)
|
||||
{
|
||||
Entry entry = _entries[i];
|
||||
if (entry == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(entry.Key))
|
||||
{
|
||||
Log.Error("[ChildrenMap] Key is null or empty on '{0}'.", gameObject.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_map.ContainsKey(entry.Key))
|
||||
{
|
||||
Log.Error("[ChildrenMap] Duplicate key '{0}' on '{1}'.", entry.Key, gameObject.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
_map.Add(entry.Key, entry.Target);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
if (_entries == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var seenKeys = new HashSet<string>();
|
||||
for (int i = 0; i < _entries.Count; i++)
|
||||
{
|
||||
Entry entry = _entries[i];
|
||||
if (entry == null || string.IsNullOrEmpty(entry.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!seenKeys.Add(entry.Key))
|
||||
{
|
||||
Debug.LogWarning($"[ChildrenMap] Duplicate key '{entry.Key}' detected on '{gameObject.name}'.", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb474f3f35451124b830a5d5cf7b367c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -37,16 +37,9 @@ namespace SepCore.Components
|
||||
_cachedTransform = target;
|
||||
_direction = Vector3.forward;
|
||||
_avoidEnemyOverlap = avoidEnemyOverlap;
|
||||
float defaultRadius = GameEntry.Luban != null && GameEntry.Luban.IsReady
|
||||
? GameEntry.Luban.Global.EnemyBodyRadius / 1000f
|
||||
: 0.5f;
|
||||
int defaultIterations = GameEntry.Luban != null && GameEntry.Luban.IsReady
|
||||
? GameEntry.Luban.Global.EnemySeparationIterations
|
||||
: 4;
|
||||
|
||||
_enemyBodyRadius = Mathf.Max(0.01f, enemyBodyRadius ?? defaultRadius);
|
||||
_separationIterations = Mathf.Max(1, separationIterations ?? defaultIterations);
|
||||
|
||||
_enemyBodyRadius = GameEntry.Luban.Global.EnemyBodyRadius;
|
||||
_separationIterations = GameEntry.Luban.Global.EnemySeparationIterations;
|
||||
|
||||
TryGetComponent(out _player);
|
||||
TryGetComponent(out _enemy);
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Components
|
||||
{
|
||||
public class PlayerMovementComponent : MonoBehaviour
|
||||
{
|
||||
private static readonly int WalkStateHash = Animator.StringToHash("Base Layer.Walk");
|
||||
|
||||
[SerializeField] private Transform _model = null;
|
||||
[SerializeField] private Animator _animator = null;
|
||||
[SerializeField] private float _turnSpeed = 720f;
|
||||
|
||||
private Transform _target;
|
||||
private StatComponent _statComponent;
|
||||
private Vector3 _direction;
|
||||
private Quaternion _initialModelRotation = Quaternion.identity;
|
||||
private bool _canMove;
|
||||
private bool _isWalking;
|
||||
|
||||
public float Speed => _statComponent.GetStatValue(StatType.MoveSpeed);
|
||||
public Vector3 Direction => _direction;
|
||||
public bool IsMoving => _isWalking;
|
||||
|
||||
public void OnInit(float speed, Transform target, StatComponent statComponent)
|
||||
{
|
||||
_target = target;
|
||||
_statComponent = statComponent;
|
||||
_statComponent.Pipeline.SetBaseValue(StatType.MoveSpeed, speed);
|
||||
_initialModelRotation = _model.localRotation;
|
||||
_direction = Vector3.zero;
|
||||
_canMove = false;
|
||||
_isWalking = false;
|
||||
_animator.applyRootMotion = false;
|
||||
_animator.Rebind();
|
||||
ResetWalkPose();
|
||||
}
|
||||
|
||||
public void SetMove(bool canMove)
|
||||
{
|
||||
_canMove = canMove;
|
||||
if (!canMove)
|
||||
{
|
||||
_direction = Vector3.zero;
|
||||
SetWalking(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDirection(Vector3 direction)
|
||||
{
|
||||
direction.y = 0f;
|
||||
_direction = Vector3.ClampMagnitude(direction, 1f);
|
||||
}
|
||||
|
||||
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
||||
{
|
||||
if (!_canMove || elapseSeconds <= 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float speed = Speed;
|
||||
bool walking = speed > 0f && _direction.sqrMagnitude > Mathf.Epsilon;
|
||||
SetWalking(walking);
|
||||
if (!walking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_target.position += _direction * (speed * elapseSeconds);
|
||||
Quaternion rotation = Quaternion.LookRotation(_direction, Vector3.up);
|
||||
_model.rotation = Quaternion.RotateTowards(_model.rotation, rotation, _turnSpeed * elapseSeconds);
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_canMove = false;
|
||||
_isWalking = false;
|
||||
_direction = Vector3.zero;
|
||||
_target = null;
|
||||
_statComponent = null;
|
||||
_model.localRotation = _initialModelRotation;
|
||||
ResetWalkPose();
|
||||
}
|
||||
|
||||
private void SetWalking(bool walking)
|
||||
{
|
||||
if (_isWalking == walking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isWalking = walking;
|
||||
if (walking)
|
||||
{
|
||||
_animator.speed = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetWalkPose();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetWalkPose()
|
||||
{
|
||||
_animator.speed = 0f;
|
||||
_animator.Play(WalkStateHash, 0, 0f);
|
||||
_animator.Update(0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9366dc6d1e945058db4c74cb557ae41
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.Components
|
||||
{
|
||||
public class SkinComponent : MonoBehaviour
|
||||
{
|
||||
private static readonly int BaseMapPropertyId = Shader.PropertyToID("_BaseMap");
|
||||
|
||||
private MeshRenderer[] _renderers;
|
||||
private Material _instanceMaterial;
|
||||
private Texture2D _loadedTexture;
|
||||
private int _generation;
|
||||
|
||||
public async UniTask OnInitAsync(RoleConfig role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
int generation = ++_generation;
|
||||
|
||||
EnsureRenderersAndMaterial();
|
||||
SetRenderersVisible(false);
|
||||
_instanceMaterial.SetTexture(BaseMapPropertyId, null);
|
||||
ReleaseLoadedTexture();
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
string textureAssetName = AssetUtility.GetSpriteAsset(role.Texture_Ref.AtlasPath);
|
||||
Texture2D texture;
|
||||
try
|
||||
{
|
||||
texture = await GameEntry.Resource.LoadAssetAsync<Texture2D>(textureAssetName);
|
||||
}
|
||||
catch (Exception exception) when (!(exception is OperationCanceledException))
|
||||
{
|
||||
Log.Error("SkinComponent.OnInitAsync: Failed to load skin texture '{0}'. {1}", textureAssetName,
|
||||
exception.Message);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (generation != _generation || cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
GameEntry.Resource.UnloadAsset(texture);
|
||||
throw new OperationCanceledException(cancellationToken);
|
||||
}
|
||||
|
||||
_loadedTexture = texture;
|
||||
_instanceMaterial.SetTexture(BaseMapPropertyId, _loadedTexture);
|
||||
SetRenderersVisible(true);
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
{
|
||||
_generation++;
|
||||
|
||||
if (_renderers != null)
|
||||
{
|
||||
SetRenderersVisible(false);
|
||||
}
|
||||
|
||||
if (_instanceMaterial != null)
|
||||
{
|
||||
_instanceMaterial.SetTexture(BaseMapPropertyId, null);
|
||||
}
|
||||
|
||||
ReleaseLoadedTexture();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
OnReset();
|
||||
|
||||
if (_instanceMaterial == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
Destroy(_instanceMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestroyImmediate(_instanceMaterial);
|
||||
}
|
||||
|
||||
_instanceMaterial = null;
|
||||
}
|
||||
|
||||
private void EnsureRenderersAndMaterial()
|
||||
{
|
||||
if (_renderers != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_renderers = GetComponentsInChildren<MeshRenderer>(true);
|
||||
_instanceMaterial = new Material(_renderers[0].sharedMaterial);
|
||||
for (int i = 0; i < _renderers.Length; i++)
|
||||
{
|
||||
_renderers[i].sharedMaterial = _instanceMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetRenderersVisible(bool visible)
|
||||
{
|
||||
for (int i = 0; i < _renderers.Length; i++)
|
||||
{
|
||||
_renderers[i].enabled = visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseLoadedTexture()
|
||||
{
|
||||
if (_loadedTexture == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Resource.UnloadAsset(_loadedTexture);
|
||||
_loadedTexture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f3d7be5910a4a0499f0a5cf0f870e96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,7 @@ using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.AsyncTask;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.Entity
|
||||
{
|
||||
@@ -15,10 +16,11 @@ namespace SepCore.Entity
|
||||
protected override TargetableObjectData _targetableObjectData => _playerData;
|
||||
|
||||
private InputComponent _inputComponent;
|
||||
private MovementComponent _movementComponent;
|
||||
private PlayerMovementComponent _movementComponent;
|
||||
private AbsorbComponent _absorbComponent;
|
||||
private StatComponent _statComponent;
|
||||
private BackpackComponent _backpackComponent;
|
||||
private SkinComponent _skinComponent;
|
||||
private PlayerData _playerData;
|
||||
|
||||
/// <summary>
|
||||
@@ -135,6 +137,47 @@ namespace SepCore.Entity
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanCombineWeapon(int index, out int matchIndex, out WeaponConfig nextTierConfig)
|
||||
{
|
||||
return _backpackComponent.CanCombineWeapon(index, out matchIndex, out nextTierConfig);
|
||||
}
|
||||
|
||||
public async UniTask<WeaponBase> CombineWeaponsAsync(WeaponBase weaponA, WeaponBase weaponB, WeaponConfig nextTierConfig, float? timeout = null)
|
||||
{
|
||||
if (weaponA == null || weaponB == null || nextTierConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using (_statComponent.Pipeline.BeginBatchUpdate())
|
||||
{
|
||||
_backpackComponent.DetachWeapon(weaponA);
|
||||
GameEntry.Entity.HideEntity(weaponA);
|
||||
|
||||
_backpackComponent.DetachWeapon(weaponB);
|
||||
GameEntry.Entity.HideEntity(weaponB);
|
||||
|
||||
int id = GameEntry.Entity.NextId();
|
||||
var weaponData = EntityDataFactory.Create(id, nextTierConfig, Id, CampType.Player);
|
||||
|
||||
float actualTimeout = timeout ?? (GameEntry.Luban.Global.EntityAsyncTimeout / 1000f);
|
||||
WeaponBase newWeapon = await GameEntry.Entity.ShowWeaponAsync(weaponData, actualTimeout);
|
||||
if (newWeapon == null)
|
||||
{
|
||||
Log.Error("Player.CombineWeaponsAsync: Failed to show new weapon {0}.", nextTierConfig.Id);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_backpackComponent.AttachWeapon(newWeapon))
|
||||
{
|
||||
GameEntry.Entity.HideEntity(newWeapon);
|
||||
return null;
|
||||
}
|
||||
|
||||
return newWeapon;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enable
|
||||
{
|
||||
get => _enable;
|
||||
@@ -156,11 +199,13 @@ namespace SepCore.Entity
|
||||
_backpackComponent.SetWeaponState(_enable && _weaponEnabled);
|
||||
}
|
||||
|
||||
public void InitRole(RoleConfig role, LevelExperienceConfig expConfig)
|
||||
public async UniTask InitRoleAsync(RoleConfig role, LevelExperienceConfig expConfig,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
// MovementComponent
|
||||
await _skinComponent.OnInitAsync(role, cancellationToken);
|
||||
|
||||
// PlayerMovementComponent
|
||||
_movementComponent.OnInit(role.Speed, this.CachedTransform, _statComponent);
|
||||
_movementComponent.SetMove(true);
|
||||
|
||||
// HealthComponent
|
||||
_healthComponent.OnInit(role.MaxHealth, _statComponent);
|
||||
@@ -168,7 +213,6 @@ namespace SepCore.Entity
|
||||
// BackpackComponent
|
||||
Coin = role.Coin;
|
||||
_backpackComponent.OnInit(this);
|
||||
AddWeaponAsync(EntityDataFactory.Create(GameEntry.Entity.NextId(), WeaponType.Knife, Id, _playerData.Camp)).Forget();
|
||||
|
||||
// StatComponent
|
||||
foreach (var modifier in role.StatModifierConfigs)
|
||||
@@ -178,6 +222,8 @@ namespace SepCore.Entity
|
||||
|
||||
_expRequires = expConfig.ToTargetLevelArray();
|
||||
|
||||
await AddWeaponAsync(EntityDataFactory.Create(GameEntry.Entity.NextId(), WeaponType.Knife, Id, _playerData.Camp));
|
||||
|
||||
// Fire Events
|
||||
GameEntry.Event.Fire(this,
|
||||
PlayerHealthChangeEventArgs.Create(0, _healthComponent.CurrentHealth, _healthComponent.MaxHealth));
|
||||
@@ -198,11 +244,14 @@ namespace SepCore.Entity
|
||||
{
|
||||
base.OnInit(userData);
|
||||
|
||||
_inputComponent = GetComponent<InputComponent>();
|
||||
_movementComponent = GetComponent<MovementComponent>();
|
||||
_absorbComponent = GetComponent<AbsorbComponent>();
|
||||
_statComponent = GetComponent<StatComponent>();
|
||||
_backpackComponent = GetComponent<BackpackComponent>();
|
||||
ChildrenMap childrenMap = GetComponent<ChildrenMap>();
|
||||
_inputComponent = childrenMap.Get("Input").GetComponent<InputComponent>();
|
||||
_movementComponent = childrenMap.Get("Movement").GetComponent<PlayerMovementComponent>();
|
||||
_healthComponent = childrenMap.Get("Health").GetComponent<HealthComponent>();
|
||||
_absorbComponent = childrenMap.Get("Absorb").GetComponent<AbsorbComponent>();
|
||||
_statComponent = childrenMap.Get("Stat").GetComponent<StatComponent>();
|
||||
_backpackComponent = childrenMap.Get("Backpack").GetComponent<BackpackComponent>();
|
||||
_skinComponent = childrenMap.Get("Skin").GetComponent<SkinComponent>();
|
||||
}
|
||||
|
||||
protected override void OnShow(object userData)
|
||||
@@ -217,9 +266,10 @@ namespace SepCore.Entity
|
||||
}
|
||||
|
||||
_inputComponent.OnInit();
|
||||
_inputComponent.SetListening(true);
|
||||
_inputComponent.SetListening(false);
|
||||
_absorbComponent.OnInit(this);
|
||||
_weaponEnabled = true;
|
||||
_enable = false;
|
||||
|
||||
_currentLevel = 0;
|
||||
}
|
||||
@@ -229,6 +279,7 @@ namespace SepCore.Entity
|
||||
base.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
|
||||
_movementComponent.SetDirection(_inputComponent.Direction);
|
||||
_movementComponent.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
_absorbComponent.OnUpdate(elapseSeconds, realElapseSeconds);
|
||||
}
|
||||
|
||||
@@ -240,6 +291,7 @@ namespace SepCore.Entity
|
||||
_statComponent.OnReset();
|
||||
_backpackComponent.OnReset();
|
||||
_absorbComponent.OnReset();
|
||||
_skinComponent.OnReset();
|
||||
|
||||
base.OnHide(isShutdown, userData);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace SepCore.UI
|
||||
public int Price;
|
||||
public Vector3 TargetPos;
|
||||
public Action<int, int> OnRecycle;
|
||||
public bool CanCombine;
|
||||
public Action<int> OnCombine;
|
||||
public int LastWaveDamage;
|
||||
public IReadOnlyDictionary<WeaponTag, int> CurrentTagCounts;
|
||||
}
|
||||
|
||||
@@ -351,5 +351,26 @@ namespace SepCore.UI
|
||||
{
|
||||
return Mathf.FloorToInt(basePrice * GameEntry.Luban.Global.WeaponRecycleRate);
|
||||
}
|
||||
|
||||
public bool CanCombineWeapon(int index, out int matchIndex, out WeaponConfig nextTierConfig)
|
||||
{
|
||||
return _player.CanCombineWeapon(index, out matchIndex, out nextTierConfig);
|
||||
}
|
||||
|
||||
public async UniTask<bool> TryCombineWeaponAsync(int index)
|
||||
{
|
||||
if (!_player.CanCombineWeapon(index, out int matchIndex, out WeaponConfig nextTierConfig))
|
||||
{
|
||||
Log.Warning("ShopUseCase.TryCombineWeaponAsync: Cannot combine weapon at index {0}.", index);
|
||||
return false;
|
||||
}
|
||||
|
||||
var weapons = _player.Weapons;
|
||||
WeaponBase weaponA = weapons[index];
|
||||
WeaponBase weaponB = weapons[matchIndex];
|
||||
|
||||
WeaponBase newWeapon = await _player.CombineWeaponsAsync(weaponA, weaponB, nextTierConfig);
|
||||
return newWeapon != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user