NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/PlayerSkill/Logic/PlayerSkillLogic01.cs

67 lines
2.2 KiB
C#
Raw Normal View History

2023-12-08 13:28:03 +08:00
using System.Collections.Generic;
using Gameplay.Area;
using Gameplay.Bullet;
using Gameplay.Common;
2023-12-13 16:20:41 +08:00
using Gameplay.Unit;
using Gameplay.Unit.Data;
2023-12-08 13:28:03 +08:00
namespace Gameplay.PlayerSkill.Logic
{
/// <summary>
/// 技能影响区域的所有人立即进入撤退状态
2023-12-12 12:49:49 +08:00
/// 具体逻辑:
/// 通过_SearchUnits()方法获取影响区域内的所有单位
/// 通过_EmitBulletToUnits()方法向这些单位发射子弹
/// 子弹id通过技能配置的参数0获取
2023-12-08 13:28:03 +08:00
/// </summary>
public class PlayerSkillLogic01 : BasePlayerSkillLogic
{
2023-12-11 16:53:44 +08:00
protected List<GameUnit> _selectUnits;
2023-12-08 13:28:03 +08:00
protected override void _OnInit()
{
_SearchUnits();
_EmitBulletToUnits();
isFinished = true;
}
private void _EmitBulletToUnits()
{
var bulletId = owner.ReadParamInt(0);
for (int i = 0; i < _selectUnits.Count; i++)
{
var unit = _selectUnits[i];
BulletManager.instance.EmitBullet(bulletId, unit, owner.playerUnit);
}
}
2023-12-11 16:53:44 +08:00
protected virtual void _SearchUnits()
2023-12-08 13:28:03 +08:00
{
_selectUnits = new List<GameUnit>();
var influenceAreaId = owner.readySkillConfig.InfluenceAreaId;
var centerCellIndex = owner.selectedCellIndex;
var influenceCellIndexs = AreaManager.instance.GetCellIndexs(centerCellIndex, influenceAreaId);
for (int i = 0; i < influenceCellIndexs.Count; i++)
{
var cellIndex = influenceCellIndexs[i];
var units = AreaManager.instance.GetUnitsByCellIndex(cellIndex);
for (int j = 0; j < units.Count; j++)
{
var unit = units[j];
// 只针对己方单位
if (unit.commonData.troopId != owner.playerUnit.commonData.troopId) continue;
// 只针对角色生效
if (unit.gameunitType != EGameUnitType.Character) continue;
// 重复的不添加
if (_selectUnits.Contains(unit)) continue;
_selectUnits.Add(unit);
}
}
}
}
}