You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

119 lines
4.9 KiB

using Entitas;
using Framw.AudioFramework;
using UnityEngine;
namespace CoreGame.Render
{
public class BeAttractedFlySystem : IExecuteSystem
{
readonly IGroup<CombatEntity> m_Group;
public BeAttractedFlySystem(Contexts contexts)
{
m_Group = contexts.combat.GetGroup(MatcherExt.s_BeAttractedMatcher);
}
public void Execute(float deltaTime)
{
m_Group.GetEntities(Contexts.s_CacheEntities);
if (Contexts.s_CacheEntities.Count == 0)
return;
var entities = Contexts.s_CacheEntities;
for (int i = 0; i < entities.Count; i++)
{
DoAttract(entities[i], deltaTime);
}
}
private void DoAttract(CombatEntity entity, float dt)
{
var beAttracted = entity.beAttracted;
var attractor = Contexts.Combat.GetEntity(beAttracted.attractorEid);
if (attractor.IsValid() == false || attractor.isDead)
{
// 停下来
// entity.RemoveDoDrop();
entity.Destroy();
return;
}
beAttracted.accTime += dt;
if (beAttracted.accTime > beAttracted.duration)
{
// 播放吸收特效
//attracter.effectShowProxy.ShowCastEffect(BattleConst.EatDropEffectId);
var dropItemData = entity.dropItemData;
var dropItemID = dropItemData.dropItemID;
var dropItemCount = dropItemData.dropItemCount;
attractor.DispatchEvent(ClientEvent.OnCatchDropItem, dropItemData);
entity.Destroy();
if (dropItemData.type == DropItemType.Equip)
{
var pickUpEquipSe = CommParamDescMgr.Instance.PickUpEquipSe;
SoundManager.Instance.PlayOneShot(SoundDescMgr.Instance.GetConfig(pickUpEquipSe.str_val)?.path);
}
else if (dropItemData.type == DropItemType.Item)
{
var itemData = ItemDescMgr.Instance.GetConfigByGhostID(dropItemID);
var path = string.Empty;
if (itemData?.itemID == PersistentKey.Gold)
{
var pickUpGoldSeStr = CommParamDescMgr.Instance.PickUpGoldSe.str_val;
path = SoundDescMgr.Instance.GetConfig(pickUpGoldSeStr)?.path;
}
else if (itemData?.itemID == PersistentKey.Diamond)
{
var pickUpDiaSeStr = CommParamDescMgr.Instance.PickUpDiaSe.str_val;
path = SoundDescMgr.Instance.GetConfig(pickUpDiaSeStr)?.path;
}
else if (itemData?.itemID == PersistentKey.Token)
{
var pickUpTokenSeStr = CommParamDescMgr.Instance.PickUpTokenSe.str_val;
path = SoundDescMgr.Instance.GetConfig(pickUpTokenSeStr)?.path;
}
if (!string.IsNullOrEmpty(path))
{
SoundManager.Instance.PlayOneShot(path);
}
}
else if (dropItemData.type == DropItemType.Custom)
{
var pickUpHpSe = CommParamDescMgr.Instance.PickUpHPSe;
if (pickUpHpSe.int_val == dropItemID)
SoundManager.Instance.PlayOneShot(SoundDescMgr.Instance.GetConfig(pickUpHpSe.str_val)?.path);
var dropSkillDesc = DropSkillDescMgr.Instance.GetConfig(dropItemID);
for (int i = 0; i < dropSkillDesc.skillId.Length; i++)
{
AbilitySrv.AttachAndTryActiveAbility(attractor, dropSkillDesc.skillId[i], true);
}
return;
}
// 掉落物为前端掉落的技能或吸引者为敌方时,不需要上报UI和服务器
var isEnemy = attractor.hasFaction && attractor.faction.faction == Faction.Enemy;
if (!isEnemy)
{
CoreUIBridge.CoreGamePushDropItem(dropItemID, (int)dropItemData.type, dropItemCount);
}
return;
}
var aet = attractor.transformProxy;
var eet = entity.transformProxy;
// todo: 抛物线
eet.position = Vector2.Lerp(beAttracted.startPos, aet.position, beAttracted.accTime / beAttracted.duration);
var lerp = Mathf.Lerp(beAttracted.startScale, beAttracted.targetScale, beAttracted.accTime / beAttracted.duration);
eet.SetLocalScale(Vector2.one * lerp);
// if (BattleModule.Instance.worldType != WorldType.Battle)
{
eet.Sync();
eet.Flush();
}
}
}
}