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

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
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 0878ab0829c34f44a83d5e5a1eb586ea
timeCreated: 1770292173
@@ -4,40 +4,47 @@ using UnityGameFramework.Runtime;
namespace SepCore.Entity
{
public class CoinEntity : EntityBase
public class DropEntity : EntityBase
{
private CoinData _coinData;
private DropData _dropData;
private bool _isCollected;
protected override void OnShow(object userData)
{
base.OnShow(userData);
_isCollected = false;
if (userData is CoinData coinData)
if (userData is DropData dropData)
{
_coinData = coinData;
_dropData = dropData;
}
else
{
Log.Error("CoinEntity.OnShow() called with wrong type.");
Log.Error("DropEntity.OnShow() called with wrong type: {0}.", userData?.GetType().Name);
}
this.CachedTransform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
CachedTransform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
public bool TryCollect(Player player, float collectDistance = 0f)
{
if (_isCollected || player == null || !player.Available || _coinData == null) return false;
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;
if (distance > collectDistance)
{
return false;
}
}
_isCollected = true;
player.Coin += _coinData.Value;
player.Coin += _dropData.CoinCount;
player.Exp += _dropData.ExpCount;
GameEntry.Entity.HideEntity(this);
return true;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46bb2720dba28ea4eb80892da753e866
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -75,20 +75,13 @@ namespace SepCore.Entity
{
if (Random.value < EnemyData.DropPercent)
{
var data = new CoinData(EnemyData.DropCoin, GameEntry.Entity.NextId())
int coinCount = GameEntry.Luban.Global.DropEntityCoinCount;
int expCount = GameEntry.Luban.Global.DropEntityExpCount;
var data = new DropData(coinCount, expCount, GameEntry.Entity.NextId())
{
Position = CachedTransform.position
};
GameEntry.Entity.ShowCoinAsync(data).Forget();
}
if (Random.value < EnemyData.DropPercent)
{
var data = new ExpData(EnemyData.DropExp, GameEntry.Entity.NextId())
{
Position = CachedTransform.position
};
GameEntry.Entity.ShowExpAsync(data).Forget();
GameEntry.Entity.ShowDropAsync(data).Forget();
}
base.OnDead(attacker);
@@ -1,49 +0,0 @@
using SepCore.Entity;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace SepCore.Entity
{
public class ExpEntity:EntityBase
{
private ExpData _expData;
private bool _isCollected;
protected override void OnShow(object userData)
{
base.OnShow(userData);
_isCollected = false;
if (userData is ExpData expData)
{
_expData = expData;
}
else
{
Log.Error("expEntity.OnShow() called with wrong type.");
}
this.CachedTransform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
}
public bool TryCollect(Player player, float collectDistance = 0f)
{
if (_isCollected || player == null || !player.Available || _expData == null) return false;
if (collectDistance > 0f)
{
float distance = Vector3.Distance(player.CachedTransform.position, CachedTransform.position);
if (distance > collectDistance) return false;
}
_isCollected = true;
player.Exp += _expData.Value;
GameEntry.Entity.HideEntity(this);
return true;
}
private void OnTriggerEnter(Collider other)
{
TryCollect(other.GetComponent<Player>());
}
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: ec4ae4b0a327442a88463eafd59c5b6e
timeCreated: 1770293001
@@ -105,7 +105,7 @@ namespace SepCore.Entity
return null;
}
float actualTimeout = timeout ?? (GameEntry.Luban.Global.EntityAsyncTimeout / 1000f);
float actualTimeout = GameEntry.Luban.Global.EntityAsyncTimeout;
WeaponBase weapon = await GameEntry.Entity.ShowWeaponAsync(weaponData, actualTimeout);
if (weapon == null)
{
@@ -160,7 +160,7 @@ namespace SepCore.Entity
int id = GameEntry.Entity.NextId();
var weaponData = EntityDataFactory.Create(id, nextTierConfig, Id, CampType.Player);
float actualTimeout = timeout ?? (GameEntry.Luban.Global.EntityAsyncTimeout / 1000f);
float actualTimeout = GameEntry.Luban.Global.EntityAsyncTimeout;
WeaponBase newWeapon = await GameEntry.Entity.ShowWeaponAsync(weaponData, actualTimeout);
if (newWeapon == null)
{
@@ -30,7 +30,8 @@ namespace SepCore.Entity
float fromHPRatio = _healthComponent.HealthRatio;
_healthComponent.TakeDamage(damageResult.Damage, damageResult.IsCrit, false, hitPosition);
float toHPRatio = _healthComponent.HealthRatio;
if (fromHPRatio > toHPRatio)
bool isDead = _healthComponent.CurrentHealth <= 0;
if (fromHPRatio > toHPRatio && !isDead)
{
GameEntry.HPBar.ShowHPBar(this, fromHPRatio, toHPRatio);
}
@@ -49,7 +50,7 @@ namespace SepCore.Entity
}
}
if (_healthComponent.CurrentHealth <= 0)
if (isDead)
{
OnDead(attacker);
}