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