コード例 #1
0
        public static void PushBack(Fight fight, Fighter caster, List <Fighter> targets, int cellID, Engines.Spells.SpellEffect effect)
        {
            int power = effect.Value;

            foreach (Fighter target in targets)
            {
                int dirPush = 0;
                if (target.CellID != cellID)
                {
                    dirPush = fight.Map.PathfindingMaker.GetDirection(cellID, target.CellID);
                }
                else
                {
                    dirPush = fight.Map.PathfindingMaker.GetDirection(caster.CellID, target.CellID);
                }

                int        remoteCell  = Engines.Pathfinding.GetRemoteCaseInThisDir(dirPush, power, target.CellID, fight.Map.Map);
                List <int> cellsPushed = Engines.Pathfinding.GetAllCellsForThisLinePath(dirPush, target.CellID, remoteCell, fight.Map.Map);

                if (target.ByWearFighter == null)
                {
                    foreach (int cell in cellsPushed)
                    {
                        if (target.IsDead)
                        {
                            break;
                        }
                        Fighter fighterOnCell = fight.GetFighterOnCell(cell);
                        if (fighterOnCell != null)
                        {
                            target.TakeDamages(target.ID, -(power * 10), 0);
                            fighterOnCell.TakeDamages(fighterOnCell.ID, -(power * 7), 0);
                            break;
                        }
                        if (!fight.Map.IsFree(cell))
                        {
                            target.TakeDamages(target.ID, -(power * 10), 0);
                            break;
                        }
                        target.CellID = cell;
                    }
                }
                if (target.WearedFighter != null)
                {
                    target.WearedFighter.CellID = target.CellID;
                }

                target.Team.Fight.Send("GA0;5;" + caster.ID + ";" + target.ID + "," + target.CellID);
            }
        }