Ejemplo n.º 1
0
        // Attack execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no damage.
            if (Damage == null)
            {
                return(false);
            }

            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to attack.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            // If no target to attack.
            IDamageable target = cell.Unit;

            if (target == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;

            // If cell is not in range.
            if (!InRange(cell, map))
            {
                return(false);
            }

            // If not enough action points.
            if (!unit.UseActionPoints(Cost))
            {
                return(false);
            }

            unit.UpdateFacing(cell);

            unit.DealDamage(target, Damage);

            return(true);
        }
Ejemplo n.º 2
0
        // Skill execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to teleport.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;

            // If target is not a wizard on the same cell.
            // TODO nullexception
            if (unit == null || unit.Cell == null || cell.Unit == null || !(cell.Unit.Class is Wizard && cell.Equals(unit.Cell)))
            {
                return(false);
            }

            // If cell is not in range.
            if (!InRange(cell, map))
            {
                return(false);
            }

            // If not enough action points.
            if (!unit.UseActionPoints(Cost))
            {
                return(false);
            }

            // finds random unoccupied cell to teleport the wizard to
            var targetCell = map.GetRandomUnoccupiedCell(false, false, true);

            unit.UpdateFacing(cell);

            unit.Cell.Unit  = null;
            unit.Cell       = targetCell;
            targetCell.Unit = unit;

            return(true);
        }
Ejemplo n.º 3
0
        // Move execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to move to.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;

            // If cell is not in range.
            if (!InRange(cell, map))
            {
                return(false);
            }

            // If there is no place to move to.
            if (!cell.Tile.Walkable || cell.Unit != null)
            {
                return(false);
            }

            // If not enough action points.
            if (!unit.UseActionPoints(Cost))
            {
                return(false);
            }

            unit.UpdateFacing(cell);

            unit.Cell.Unit = null;
            unit.Cell      = cell;
            cell.Unit      = unit;

            return(true);
        }
Ejemplo n.º 4
0
        // Skill execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to place spikes.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;

            // If cell is not in range.
            if (!InRange(cell, map))
            {
                return(false);
            }

            // If not enough action points.
            if (!unit.UseActionPoints(Cost))
            {
                return(false);
            }

            unit.UpdateFacing(cell);

            new BasicObject(cell, ObjectType.Spikes);

            return(true);
        }
Ejemplo n.º 5
0
        // Attack execution.
        public override bool Execute(List <Cell> targets, Map map)
        {
            // If no damage.
            if (Damage == null)
            {
                return(false);
            }

            // If no target.
            if (targets == null)
            {
                return(false);
            }

            // If more than one target.
            if (targets.Count != 1)
            {
                return(false);
            }

            Cell cell = targets[0];

            // If no executer or cell to attack.
            if (Executer == null || cell == null)
            {
                return(false);
            }

            // If no target to attack.
            BasicUnit target = cell.Unit;

            if (target == null)
            {
                return(false);
            }

            BasicUnit unit = Executer as BasicUnit;

            // If cell is not in range.
            if (!InRange(cell, map))
            {
                return(false);
            }

            // If not enough action points.
            if (!unit.UseActionPoints(Cost))
            {
                return(false);
            }

            var translation      = Coordinates.GetVectorByDirection(unit.Cell.GetDirection(cell));
            var targetCellCoords = new Coordinates(unit.Cell.Position.X + (int)translation.x, unit.Cell.Position.Y + (int)translation.y);
            var targetCell       = map.Cells[targetCellCoords];

            target.Cell.Unit = null;
            target.Cell      = targetCell;
            targetCell.Unit  = target;

            unit.UpdateFacing(targetCell);
            target.UpdateFacing(unit.Cell);

            unit.DealDamage(target, Damage);

            return(true);
        }