using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Gameplay.Summon { using Framework; using Gameplay.Area; using Gameplay.Bullet; using Gameplay.Common; using Gameplay.Skill; using LTGame; public class SummonStateMineIdle : BaseSummonState { private SummonMine _mine; private bool _needCheckSelfCell; public SummonStateMineIdle(SummonMine owner) : base(owner, ESummonState.MineIdle) { _mine = owner; } protected override void _OnEnter(NBaseState exitState, object param) { base._OnEnter(exitState, param); _needCheckSelfCell = true; EventManager.Instance.Register(EventManager.EventName.INFIGHT_UNIT_CELLINDEX_CHANGE, (Action)_OnAnyCharacterCellIndexChange); } protected override void _OnRunning() { base._OnRunning(); if (_needCheckSelfCell) { _needCheckSelfCell = false; _CheckSelfCell(); } } protected override void _OnExit(NBaseState exitState, object param) { base._OnExit(exitState, param); EventManager.Instance.Unregister(EventManager.EventName.INFIGHT_UNIT_CELLINDEX_CHANGE, (Action)_OnAnyCharacterCellIndexChange); } private void _OnAnyCharacterCellIndexChange(GameUnit unit) { _needCheckSelfCell = true; } private void _CheckSelfCell() { var units = AreaManager.instance.GetUnitsByCellIndex(owner.transData.cellIndex); for (var i = 0; i < units.Count; ++i) { var unit = units[i]; if (unit.commonData.troopId != owner.commonData.troopId) { // 爆炸 isFinished = true; nextState = ESummonState.MineBoom; return; } } } } }