using System.Collections.Generic; using Gameplay.Area; using Gameplay.Bullet; using Gameplay.Common; using Gameplay.Unit; using Gameplay.Unit.Data; namespace Gameplay.PlayerSkill.Logic { /// /// 技能影响区域的所有人立即进入撤退状态 /// 具体逻辑: /// 通过_SearchUnits()方法获取影响区域内的所有单位 /// 通过_EmitBulletToUnits()方法向这些单位发射子弹 /// 子弹id通过技能配置的参数0获取 /// public class PlayerSkillLogic01 : BasePlayerSkillLogic { protected List _selectUnits; 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); } } protected virtual void _SearchUnits() { _selectUnits = new List(); 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); } } } } }