导入敌人模型素材,统一经验和金币掉落物

This commit is contained in:
2026-10-04 18:54:11 +08:00
parent aaa8cf3ee2
commit 01374fec43
253 changed files with 13508 additions and 231 deletions
@@ -0,0 +1,57 @@
using SepCore.Entity;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.Entity
{
public class DropEntity : EntityBase
{
private DropData _dropData;
private bool _isCollected;
protected override void OnShow(object userData)
{
base.OnShow(userData);
_isCollected = false;
if (userData is DropData dropData)
{
_dropData = dropData;
}
else
{
Log.Error("DropEntity.OnShow() called with wrong type: {0}.", userData?.GetType().Name);
}
CachedTransform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
public bool TryCollect(Player player, float collectDistance = 0f)
{
if (_isCollected || player == null || !player.Available || _dropData == null)
{
return false;
}
if (collectDistance > 0f)
{
float distance = Vector3.Distance(player.CachedTransform.position, CachedTransform.position);
if (distance > collectDistance)
{
return false;
}
}
_isCollected = true;
player.Coin += _dropData.CoinCount;
player.Exp += _dropData.ExpCount;
GameEntry.Entity.HideEntity(this);
return true;
}
private void OnTriggerEnter(Collider other)
{
TryCollect(other.GetComponent<Player>());
}
}
}