/// <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="DamageValue"></param> /// <param name="damageInfos"></param> /// <returns></returns> public override FightActionResultEnum ApplyEffect(ref int damageValue, CastInfos damageInfos = null) { if (!damageInfos.IsMelee || Pathfinding.GoalDistance(Target.Map, Target.Cell.Id, damageInfos.Caster.Cell.Id) > 1) { return(FightActionResultEnum.RESULT_NOTHING); } damageValue = 0; // Annihilation des dommages; // cannot apply push if target move with last effects if (Target.Cell.Id != damageInfos.TargetKnownCellId) { return(FightActionResultEnum.RESULT_NOTHING); } var subInfos = new CastInfos(EffectEnum.PushBack, 0, 0, 0, 0, 0, 0, 0, damageInfos.Caster, null); var direction = Pathfinding.GetDirection(Target.Fight.Map, damageInfos.Caster.Cell.Id, Target.Cell.Id); // Application du push return(PushEffect.ApplyPush(subInfos, Target, direction, 1)); }