/// <summary> /// /// </summary> /// <param name="castInfos"></param> /// <param name="target"></param> /// <param name="direction"></param> /// <param name="length"></param> /// <returns></returns> public static FightActionResultEnum ApplyPush(CastInfos castInfos, AbstractFighter target, int direction, int length) { var currentCell = target.Cell; for (int i = 0; i < length; i++) { var nextCell = target.Fight.GetCell(Pathfinding.NextCell(castInfos.Map, currentCell.Id, direction)); if (nextCell != null && nextCell.CanWalk) { if (nextCell.HasObject(FightObstacleTypeEnum.TYPE_TRAP)) { target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + nextCell.Id)); target.Fight.SetSubAction(() => { return(target.SetCell(nextCell)); }, 1 + ++i * WorldConfig.FIGHT_PUSH_CELL_TIME); return(FightActionResultEnum.RESULT_NOTHING); } } else { if (i != 0) { target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id)); } target.Fight.SetSubAction(() => { if (castInfos.EffectType == EffectEnum.PushBack) { var pushResult = PushEffect.ApplyPushBackDamages(castInfos, target, length, i); if (pushResult != FightActionResultEnum.RESULT_NOTHING) { return(pushResult); } } return(target.SetCell(currentCell)); }, 1 + (i * WorldConfig.FIGHT_PUSH_CELL_TIME)); return(FightActionResultEnum.RESULT_NOTHING); } currentCell = nextCell; } target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id)); target.Fight.SetSubAction(() => { return(target.SetCell(currentCell)); }, 1 + length * WorldConfig.FIGHT_PUSH_CELL_TIME); return(FightActionResultEnum.RESULT_NOTHING); }
/// <summary> /// /// </summary> /// <param name="castInfos"></param> /// <param name="target"></param> /// <param name="direction"></param> /// <param name="length"></param> /// <returns></returns> public static FightActionResultEnum ApplyPush(CastInfos castInfos, AbstractFighter target, int direction, int length) { var currentCell = target.Cell; for (int i = 0; i < length; i++) { var nextCell = target.Fight.GetCell(Pathfinding.NextCell(castInfos.Map, currentCell.Id, direction)); if (nextCell != null && nextCell.CanWalk) { if (nextCell.HasObject(FightObstacleTypeEnum.TYPE_TRAP)) { target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + nextCell.Id)); target.Fight.SetSubAction(() => { return target.SetCell(nextCell); }, 1 + ++i * WorldConfig.FIGHT_PUSH_CELL_TIME); return FightActionResultEnum.RESULT_NOTHING; } } else { if (i != 0) { target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id)); } target.Fight.SetSubAction(() => { if (castInfos.EffectType == EffectEnum.PushBack) { var pushResult = PushEffect.ApplyPushBackDamages(castInfos, target, length, i); if (pushResult != FightActionResultEnum.RESULT_NOTHING) return pushResult; } return target.SetCell(currentCell); }, 1 + (i * WorldConfig.FIGHT_PUSH_CELL_TIME)); return FightActionResultEnum.RESULT_NOTHING; } currentCell = nextCell; } target.Fight.Dispatch(WorldMessage.GAME_ACTION(GameActionTypeEnum.MAP_PUSHBACK, target.Id, target.Id + "," + currentCell.Id)); target.Fight.SetSubAction(() => { return target.SetCell(currentCell); }, 1 + length * WorldConfig.FIGHT_PUSH_CELL_TIME); return FightActionResultEnum.RESULT_NOTHING; }