迁移 Coin/Exp/Projectile/Effect 实体的生成路径
This commit is contained in:
parent
734f2cd5af
commit
d28ccaa7f9
|
|
@ -1,6 +1,8 @@
|
|||
using SepCore.Event;
|
||||
using SepCore.Entity;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Entity.Weapon;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -127,7 +129,7 @@ namespace SepCore.Simulation
|
|||
{
|
||||
Position = args.HitPosition
|
||||
};
|
||||
entityComponent.ShowEffect(effectData);
|
||||
entityComponent.ShowEffectAsync(effectData).Forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using SepCore.Definition;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -10,5 +12,31 @@ public abstract class EnemyBase : TargetableObject
|
|||
public virtual float AttackRange => 1f;
|
||||
|
||||
public virtual void SetTarget(Transform target) => _target = target;
|
||||
|
||||
protected EnemyData _enemyData;
|
||||
|
||||
|
||||
protected override void OnDead(EntityBase attacker)
|
||||
{
|
||||
if (Random.value < _enemyData.DropPercent)
|
||||
{
|
||||
var data = new CoinData(_enemyData.DropCoin, GameEntry.Entity.NextId(), 10001)
|
||||
{
|
||||
Position = this.CachedTransform.position
|
||||
};
|
||||
GameEntry.Entity.ShowCoinAsync(data).Forget();
|
||||
}
|
||||
|
||||
if (Random.value < _enemyData.DropPercent)
|
||||
{
|
||||
var data = new ExpData(_enemyData.DropExp, GameEntry.Entity.NextId(), 10002)
|
||||
{
|
||||
Position = this.CachedTransform.position
|
||||
};
|
||||
GameEntry.Entity.ShowExpAsync(data).Forget();
|
||||
}
|
||||
|
||||
base.OnDead(attacker);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using SepCore.Components;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
|
|
@ -27,7 +26,13 @@ namespace SepCore.Entity
|
|||
private float _currAttackTimer;
|
||||
|
||||
private AttackStateType _attackState = AttackStateType.Idle;
|
||||
private EnemyData _meleeEnemyData;
|
||||
|
||||
private EnemyData _meleeEnemyData
|
||||
{
|
||||
get => _enemyData;
|
||||
set => _enemyData = value;
|
||||
}
|
||||
|
||||
private TargetableObject _targetableTarget;
|
||||
|
||||
protected override TargetableObjectData _targetableObjectData => _meleeEnemyData;
|
||||
|
|
@ -83,29 +88,6 @@ namespace SepCore.Entity
|
|||
UpdateAttackState(elapseSeconds);
|
||||
}
|
||||
|
||||
protected override void OnDead(EntityBase attacker)
|
||||
{
|
||||
if (Random.value < _meleeEnemyData.DropPercent)
|
||||
{
|
||||
var data = new CoinData(_meleeEnemyData.DropCoin, GameEntry.Entity.NextId(), 10001)
|
||||
{
|
||||
Position = this.CachedTransform.position
|
||||
};
|
||||
GameEntry.Entity.ShowCoin(data);
|
||||
}
|
||||
|
||||
if (Random.value < _meleeEnemyData.DropPercent)
|
||||
{
|
||||
var data = new ExpData(_meleeEnemyData.DropExp, GameEntry.Entity.NextId(), 10002)
|
||||
{
|
||||
Position = this.CachedTransform.position
|
||||
};
|
||||
GameEntry.Entity.ShowExp(data);
|
||||
}
|
||||
|
||||
base.OnDead(attacker);
|
||||
}
|
||||
|
||||
protected override void OnHide(bool isShutdown, object userData)
|
||||
{
|
||||
_movementComponent.OnReset();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
using SepCore.Components;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
|
|
@ -34,7 +35,11 @@ namespace SepCore.Entity
|
|||
[SerializeField] private float _projectileSpawnHeightOffset = 0.6f;
|
||||
[SerializeField] private string _projectileAssetName = "BulletHandgun";
|
||||
|
||||
private EnemyData _remoteEnemyData;
|
||||
private EnemyData _remoteEnemyData
|
||||
{
|
||||
get => _enemyData;
|
||||
set => _enemyData = value;
|
||||
}
|
||||
|
||||
protected override TargetableObjectData _targetableObjectData => _remoteEnemyData;
|
||||
public override float AttackRange => _attackRange;
|
||||
|
|
@ -154,13 +159,12 @@ namespace SepCore.Entity
|
|||
Rotation = Quaternion.LookRotation(direction, Vector3.up)
|
||||
};
|
||||
|
||||
GameEntry.Entity.ShowEntity(
|
||||
entityId: projectileEntityId,
|
||||
entityLogicType: typeof(EnemyProjectile),
|
||||
entityAssetName: AssetUtility.GetEntityAsset(_projectileAssetName),
|
||||
entityGroupName: EnemyProjectileGroupName,
|
||||
priority: Constant.AssetPriority.BulletAsset,
|
||||
userData: projectileData);
|
||||
GameEntry.Entity.ShowEntityAsync<EnemyProjectile>(
|
||||
projectileEntityId,
|
||||
AssetUtility.GetEntityAsset(_projectileAssetName),
|
||||
EnemyProjectileGroupName,
|
||||
Constant.AssetPriority.BulletAsset,
|
||||
projectileData).Forget();
|
||||
|
||||
_currAttackTimer = 0f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,5 @@
|
|||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using SepCore.Components;
|
||||
using SepCore.Components;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.CustomUtility;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue