public override bool Apply()
        {
            FightActor fightActor = base.GetAffectedActors().FirstOrDefault <FightActor>();

            if (fightActor != null)
            {
                if (fightActor.PreviousPosition != null)
                {
                    Cell destCell = this.Fight.Cells[fightActor.Position.Point.GetNearestCellInOppositeDirection(fightActor.Position.Direction).CellId];
                    //Cell destCell = fightActor.PreviousPosition.Cell;
                    FightActor oldFighter = base.Fight.GetOneFighter(destCell);
                    if (oldFighter != null)
                    {
                        //if there was a fighter on the cell we are going to tp on, we need to move him at our old position
                        oldFighter.Position.Cell = base.Caster.Position.Cell;
                        oldFighter.AddTelefragState(base.Caster, base.Spell);
                        base.Caster.AddTelefragState(base.Caster, base.Spell);
                        ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, oldFighter, base.Caster.Cell);
                    }
                    fightActor.Position.Cell = destCell;
                    ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, fightActor, destCell);
                }
            }
            return(true);
        }
Esempio n. 2
0
 public override bool Apply()
 {
     //symmetric tp from the center of the cell ex: temporal dust
     //it applies only when the target has the state "Telefrag"
     foreach (FightActor fightActor in base.GetAffectedActors())
     {
         MapPoint   destPoint  = new MapPoint(base.TargetedCell).GetSymmetricCell(fightActor.Position.Point);
         Cell       destCell   = base.Caster.Map.GetCell(destPoint.CellId);
         FightActor oldFighter = base.Fight.GetOneFighter(destCell);
         if (oldFighter != null)
         {
             //if there was a fighter on the cell we are going to tp on, we need to move him at our old position
             oldFighter.AddTelefragState(base.Caster, base.Spell);
             base.Caster.AddTelefragState(base.Caster, base.Spell);
             oldFighter.Position.Cell = fightActor.Position.Cell;
             ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, oldFighter, fightActor.Position.Cell);
         }
         // not sure if it is the right client !! todo : check
         fightActor.Position.Cell = destCell;
         ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, fightActor, destCell);
     }
     return(true);
 }
        public override bool Apply()
        {
            FightActor fightActor = base.GetAffectedActors().FirstOrDefault <FightActor>();

            if (fightActor != null)
            {
                MapPoint   destPoint  = base.Caster.Position.Point.GetSymmetricCell(fightActor.Position.Point);
                Cell       destCell   = base.Caster.Map.GetCell(destPoint.CellId);
                FightActor oldFighter = base.Fight.GetOneFighter(destCell);
                if (oldFighter != null)
                {
                    //if there was a fighter on the cell we are going to tp on, we need to move him at our old position
                    oldFighter.AddTelefragState(base.Caster, base.Spell);
                    fightActor.AddTelefragState(base.Caster, base.Spell);
                    oldFighter.Position.Cell = fightActor.Position.Cell;
                    ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, oldFighter, fightActor.Position.Cell);
                }
                fightActor.Position.Cell = destCell;
                // not sure if it is the right client !! todo : check
                ActionsHandler.SendGameActionFightTeleportOnSameMapMessage(base.Fight.Clients, base.Caster, fightActor, destCell);
            }
            return(true);
        }