64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using Gameplay.Area;
|
|
using Gameplay.Common;
|
|
using Gameplay.Unit;
|
|
using Gameplay.Unit.Data;
|
|
namespace Gameplay.PlayerSkill.Logic
|
|
{
|
|
public class PlayerSkillLogic07 : BasePlayerSkillLogic
|
|
{
|
|
|
|
private List<GameUnit> _selectUnits;
|
|
|
|
protected override void _OnInit()
|
|
{
|
|
base._OnInit();
|
|
|
|
_SelectUnits();
|
|
|
|
for (int i = 0; i < _selectUnits.Count; i++)
|
|
{
|
|
var unit = _selectUnits[i];
|
|
_SetToReady(unit);
|
|
}
|
|
|
|
isFinished = true;
|
|
}
|
|
|
|
private void _SelectUnits()
|
|
{
|
|
_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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将单位设置到备战席
|
|
/// </summary>
|
|
/// <param name="unit"></param>
|
|
private void _SetToReady(GameUnit unit)
|
|
{
|
|
var unitId = unit.GetID();
|
|
GameUnitManager.instance.MoveUnitToPrepare(unitId);
|
|
}
|
|
|
|
}
|
|
}
|