53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using Gameplay.PlayerSkill.Data;
|
|
using Gameplay.Unit;
|
|
using Gameplay.Unit.Data;
|
|
using UnityEngine;
|
|
namespace Gameplay.PlayerSkill.Logic
|
|
{
|
|
public class PlayerSkillLogic09 : BasePlayerSkillLogic
|
|
{
|
|
|
|
protected override void _OnInit()
|
|
{
|
|
base._OnInit();
|
|
|
|
var allSelfDeadUnits = new List<GameUnit>();
|
|
for (int i = 0; i < GameUnitManager.instance.deadUnits.count; i++)
|
|
{
|
|
var unit = GameUnitManager.instance.deadUnits.GetByIndex(i);
|
|
if (unit.gameunitType != EGameUnitType.Character)
|
|
{
|
|
continue;
|
|
}
|
|
if (unit.commonData.troopId != owner.playerUnit.commonData.troopId)
|
|
{
|
|
continue;
|
|
}
|
|
allSelfDeadUnits.Add(unit);
|
|
}
|
|
|
|
var count = allSelfDeadUnits.Count;
|
|
if (count == 0)
|
|
{
|
|
DebugUtil.LogError("没有已死亡单位");
|
|
isFinished = true;
|
|
return;
|
|
}
|
|
|
|
var randomUnit = allSelfDeadUnits[Random.Range(0, count)];
|
|
var unitId = randomUnit.GetID();
|
|
|
|
var reviveData = new UnitReviveData()
|
|
{
|
|
hpPercent = owner.ReadParamFloat(0),
|
|
shieldPercent = owner.ReadParamFloat(1),
|
|
};
|
|
GameUnitManager.instance.ReviveUnit(unitId, reviveData);
|
|
|
|
isFinished = true;
|
|
}
|
|
|
|
}
|
|
}
|