Example #1
0
 public DrawingArea()
 {
     InitializeComponent();
     Shapes          = new List <IShape>();
     _undoneShapes   = new List <IShape>();
     _shapesProvider = new ShapesProvider();
 }
        public static short SearchScrollCellId(short cellid, MapScrollType type, MapRecord map)
        {
            var defaultCell = GetScrollDefaultCellId(cellid, type);
            var cells       = ShapesProvider.GetMapBorder(GetOposedTransition(type));
            var walkables   = cells.FindAll(x => map.Walkable(x));

            return(walkables.Count == 0 ? map.RandomWalkableCell() : walkables[new AsyncRandom().Next(0, walkables.Count - 1)]);
        }
        private List <short> GetCheckedCells(short bombCellId)
        {
            List <short> checkedCells = new List <short>();

            checkedCells.AddRange(ShapesProvider.GetLineFromDirection(bombCellId, BOMB_LINE_SIZE, DirectionsEnum.DIRECTION_NORTH_EAST));
            checkedCells.AddRange(ShapesProvider.GetLineFromDirection(bombCellId, BOMB_LINE_SIZE, DirectionsEnum.DIRECTION_NORTH_WEST));
            checkedCells.AddRange(ShapesProvider.GetLineFromDirection(bombCellId, BOMB_LINE_SIZE, DirectionsEnum.DIRECTION_SOUTH_WEST));
            checkedCells.AddRange(ShapesProvider.GetLineFromDirection(bombCellId, BOMB_LINE_SIZE, DirectionsEnum.DIRECTION_SOUTH_EAST));
            return(checkedCells);
        }
 public void HandleWeaponEffect(short cellid, List <ExtendedSpellEffect> handledEffects, FightSpellCastCriticalEnum critical)
 {
     foreach (var effect in handledEffects)
     {
         Fight.TryStartSequence(ContextualId, 1);
         short[] cells  = ShapesProvider.Handle(effect.ZoneShape, cellid, CellId, effect.ZoneSize).ToArray();
         var     actors = GetAffectedActors(cells, effect.Targets);
         SpellEffectsHandler.Handle(this, null, effect, actors, cellid);
         Fight.TryEndSequence(1, 0);
     }
     Fight.CheckFightEnd();
 }
        public short CloseCell(short cellid)
        {
            var cells = ShapesProvider.GetSquare(cellid, false);

            foreach (var cell in cells)
            {
                if (WalkableCells.Contains(cell))
                {
                    return((short)cell);
                }
            }
            return(0);
        }
 public MarkTrigger(Fighter caster, short centercell, short entitycell, char shapetype, short radius, short associatedspellid, sbyte spellgrade, int markcolor)
 {
     this.Id                   = (short)caster.Fight.MarkIdProvider.Pop();
     this.CenterCell           = centercell;
     this.Radius               = radius;
     this.Caster               = caster;
     this.ShapeType            = shapetype;
     this.Cells                = ShapesProvider.Handle(shapetype, centercell, entitycell, radius);
     this.AssociatedSpellId    = associatedspellid;
     this.AssociatedSpellGrade = spellgrade;
     this.MarkColor            = markcolor;
     this.MarkedCells          = GetMarkedCells();
 }
        public bool IsAligned(Fighter fighter)
        {
            var direction = ShapesProvider.GetDirectionFromTwoCells(this.CellId, fighter.CellId);

            if (direction == DirectionsEnum.DIRECTION_EAST || direction == DirectionsEnum.DIRECTION_NORTH ||
                direction == DirectionsEnum.DIRECTION_SOUTH || direction == DirectionsEnum.DIRECTION_WEST)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public void OverrideDamages(Fighter source)
        {
            var          direction = ShapesProvider.GetDirectionFromTwoCells(Fighter.CellId, source.CellId);
            List <short> line      = ShapesProvider.GetLineFromOposedDirection(Fighter.CellId, Delta, direction);
            List <short> cells     = Fighter.Fight.BreakAtFirstObstacles(line);

            if (cells.Count > 0)
            {
                Fighter.Fight.TryStartSequence(Fighter.ContextualId, 5);
                Fighter.Fight.Send(new GameActionFightSlideMessage(0, Fighter.ContextualId, Fighter.ContextualId, Fighter.CellId, cells.Last()));
                Fighter.CellId = cells.Last();
                Fighter.Fight.TryEndSequence(5, 2);
            }
        }
        public override bool OnEventCalled(object arg1, object arg2, object arg3)
        {
            var source = Fighter.Fight.GetFighter((int)arg1);

            if (ShapesProvider.GetSquare(Fighter.CellId, false).Contains(source.CellId))
            {
                OverrideDamages(source);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        public static void BePulled(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
        {
            foreach (var target in affecteds)
            {
                var          direction = ShapesProvider.GetDirectionFromTwoCells(target.CellId, fighter.CellId);
                List <short> line      = ShapesProvider.GetLineFromDirection(target.CellId, (byte)effect.BaseEffect.DiceNum, direction);
                List <short> cells     = fighter.Fight.BreakAtFirstObstacles(line);
                cells.Reverse();

                if (cells.Count > 0)
                {
                    fighter.Slide(fighter.ContextualId, cells);
                }
            }
        }
        public void ActivateOnTurnStart(Fighter fighter)
        {
            var spellLevel = SpellLevelRecord.GetLevel((ushort)AssociatedSpellId, AssociatedSpellGrade);

            DisplayTriggered(fighter);
            foreach (var effect in spellLevel.Effects)
            {
                Caster.Fight.TryStartSequence(Caster.ContextualId, 1);
                short[] cells = ShapesProvider.Handle(effect.ZoneShape, CenterCell, fighter.CellId, effect.ZoneSize).ToArray();
                SpellEffectsHandler.Handle(Caster, spellLevel, effect, new List <Fighter>()
                {
                    fighter
                }, CenterCell);
                Caster.Fight.TryEndSequence(1, 0);
            }
            Caster.Fight.CheckFightEnd();
        }
        public override void Execute(MonsterFighter fighter)
        {
            var summonSpell = fighter.Template.Spells.ConvertAll <SpellRecord>(x => SpellRecord.GetSpell(x)).Find(x => x.Category == SpellCategoryEnum.Summon);

            if (summonSpell != null && fighter.SummonCount <= 1)
            {
                var cells = ShapesProvider.GetSquare(fighter.CellId, false);
                var cell  = cells.Find(x => !fighter.Fight.IsObstacle(x));
                if (cell != 0)
                {
                    fighter.CastSpellOnCell(summonSpell.Id, cell);
                }
                else
                {
                    fighter.Fight.Reply("Unable to summon");
                }
            }
        }
        public override bool OnEventCalled(object arg1, object arg2, object arg3)
        {
            int          sourceId = (int)arg1;
            TakenDamages damages  = (TakenDamages)arg2;

            damages.Delta = damages.GetDeltaPercentage(REWIND_PERCENTAGE);
            List <short> cellIds = ShapesProvider.GetCrossCells(Fighter.CellId, Fighter.CellId, 1);

            foreach (var cellId in cellIds)
            {
                Fighter target = Fighter.Fight.GetFighter(cellId);
                if (target != null)
                {
                    //target.Fight.Send(new DebugHighlightCellsMessage(0, new ushort[] { (ushort)cellId }));
                }
            }
            return(false);
        }
Example #14
0
        [EffectHandler(EffectsEnum.Eff_1104)] // Xelor
        public static void SymetryToTargetMove(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
        {
            var symetrySource = fighter.Fight.GetFighter(castcellid);

            if (symetrySource == null)
            {
                return;
            }
            var   target          = fighter.Fight.GetFighter(castcellid);
            var   direction       = ShapesProvider.GetDirectionFromTwoCells(target.CellId, fighter.CellId);
            short destinationCell = (short)((target.CellId * 2) - fighter.CellId);

            if (ShapesProvider.IsDiagonalDirection(direction))
            {
                if (PathHelper.GetDistanceBetween(fighter.CellId, target.CellId) % 2 != 0)
                {
                    destinationCell = (short)((target.CellId * 2) - fighter.CellId - 1);
                }
                else
                {
                    destinationCell = (short)((target.CellId * 2) - fighter.CellId);
                }
            }
            else if (PathHelper.GetDistanceBetween(fighter.CellId, castcellid) % 2 != 0)
            {
                destinationCell = (short)((target.CellId * 2) - fighter.CellId - 1);
            }
            if (fighter.Fight.IsObstacle(destinationCell) && fighter.Fight.GetFighter(destinationCell) == null)
            {
                return;
            }
            if (fighter.Fight.GetFighter(destinationCell) != null)
            {
                SwitchPosition(fighter, null, null, new List <Fighter>()
                {
                    fighter.Fight.GetFighter(destinationCell)
                }, destinationCell);
            }
            else
            {
                fighter.Teleport(destinationCell);
            }
        }
 public static MapScrollType GetScrollTypeFromCell(short cellid)
 {
     if (ShapesProvider.GetMapBorder(MapScrollType.TOP).Contains(cellid))
     {
         return(MapScrollType.TOP);
     }
     if (ShapesProvider.GetMapBorder(MapScrollType.BOTTOM).Contains(cellid))
     {
         return(MapScrollType.BOTTOM);
     }
     if (ShapesProvider.GetMapBorder(MapScrollType.LEFT).Contains(cellid))
     {
         return(MapScrollType.LEFT);
     }
     if (ShapesProvider.GetMapBorder(MapScrollType.RIGHT).Contains(cellid))
     {
         return(MapScrollType.RIGHT);
     }
     return(MapScrollType.UNDEFINED);
 }
        public void HandleSpellEffects(SpellLevelRecord spell, short cellid, FightSpellCastCriticalEnum critical)
        {
            List <ExtendedSpellEffect> handledEffects = critical == FightSpellCastCriticalEnum.CRITICAL_HIT ? spell.CriticalEffects : spell.Effects;

            Dictionary <ExtendedSpellEffect, List <Fighter> > validatedEffectsDatas = new Dictionary <ExtendedSpellEffect, List <Fighter> >();


            SelectRandomEffect(handledEffects);
            foreach (var effect in handledEffects)
            {
                short[] cells  = ShapesProvider.Handle(effect.ZoneShape, cellid, CellId, effect.ZoneSize).ToArray();
                var     actors = GetAffectedActors(cells, effect.Targets);
                validatedEffectsDatas.Add(effect, actors);
            }
            foreach (var data in validatedEffectsDatas)
            {
                Fight.TryStartSequence(ContextualId, 1);
                SpellEffectsHandler.Handle(this, spell, data.Key, data.Value, cellid);
                Fight.TryEndSequence(1, 0);
            }
        }
Example #17
0
 public static void PullForward(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
 {
     foreach (var target in affecteds)
     {
         DirectionsEnum direction;
         if (target.CellId != castcellid)
         {
             direction = ShapesProvider.GetDirectionFromTwoCells(target.CellId, castcellid);
         }
         else
         {
             direction = ShapesProvider.GetDirectionFromTwoCells(target.CellId, fighter.CellId);
         }
         List <short> line  = ShapesProvider.GetLineFromDirection(target.CellId, effect.BaseEffect.DiceNum, direction);
         List <short> cells = fighter.Fight.BreakAtFirstObstacles(line);
         if (cells.Count > 0)
         {
             target.Slide(fighter.ContextualId, cells);
         }
     }
 }
Example #18
0
        [EffectHandler(EffectsEnum.Eff_1106)] // symétrie esprit
        public static void SymetryMove(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
        {
            var   direction       = ShapesProvider.GetDirectionFromTwoCells(fighter.CellId, castcellid);
            var   line            = ShapesProvider.GetLineFromDirection(fighter.CellId, 2, direction);
            short destinationCell = line.Last();

            if (fighter.Fight.IsObstacle(destinationCell))
            {
                var target = fighter.Fight.GetFighter(destinationCell);
                if (target != null)
                {
                    SwitchPosition(fighter, null, null, new List <Fighter>()
                    {
                        target
                    }, destinationCell);
                }
            }
            else
            {
                fighter.Teleport(destinationCell);
            }
        }
Example #19
0
        [EffectHandler(EffectsEnum.Eff_RepelsTo)] // Peur du sram
        public static void RepelsTo(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
        {
            var dir             = ShapesProvider.GetDirectionFromTwoCells(fighter.CellId, castcellid);
            var movedCellAmount = (short)(PathHelper.GetDistanceBetween(fighter.CellId, castcellid));

            fighter.Fight.Reply(movedCellAmount.ToString());
            var line = ShapesProvider.GetLineFromDirection(fighter.CellId, movedCellAmount, dir);

            if (line.Count > 0)
            {
                var target = fighter.Fight.GetFighter(line.First());
                if (target != null)
                {
                    line.Remove(target.CellId);
                    List <short> cells = fighter.Fight.BreakAtFirstObstacles(line);
                    if (cells.Count > 0)
                    {
                        target.Slide(fighter.ContextualId, cells);
                    }
                }
            }
        }
        public override bool OnEventCalled(object arg1, object arg2, object arg3)
        {
            Fighter source = Fighter.Fight.GetFighter(SourceId);

            if (!Fighter.IsAligned(source))
            {
                return(false);
            }

            DirectionsEnum dir   = ShapesProvider.GetDirectionFromTwoCells(Fighter.CellId, source.CellId);
            List <short>   cells = Fighter.Fight.BreakAtFirstObstacles(ShapesProvider.GetLineFromDirection(Fighter.CellId, 1, dir));

            if (cells.Count > 0)
            {
                Fighter.Slide(SourceId, new List <short>()
                {
                    Fighter.CellId, cells[0]
                });
            }

            return(false);
        }
Example #21
0
 public static void SymetryToLauncherMove(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
 {
     foreach (Fighter affected in affecteds)
     {
         var   direction       = ShapesProvider.GetDirectionFromTwoCells(castcellid, fighter.CellId);
         short destinationCell = (short)((fighter.CellId * 2) - castcellid);
         if (ShapesProvider.IsDiagonalDirection(direction))
         {
             if (PathHelper.GetDistanceBetween(fighter.CellId, affected.CellId) % 2 != 0)
             {
                 destinationCell = (short)((fighter.CellId * 2) - castcellid + 1);
             }
             else
             {
                 destinationCell = (short)((fighter.CellId * 2) - castcellid);
             }
         }
         else if (PathHelper.GetDistanceBetween(fighter.CellId, affected.CellId) % 2 != 0)
         {
             destinationCell = (short)((fighter.CellId * 2) - castcellid + 1);
         }
         if (fighter.Fight.IsObstacle(destinationCell) && fighter.Fight.GetFighter(destinationCell) == null)
         {
             return;
         }
         if (fighter.Fight.GetFighter(destinationCell) != null)
         {
             SwitchPosition(affected, null, null, new List <Fighter>()
             {
                 fighter.Fight.GetFighter(destinationCell)
             }, destinationCell);
         }
         else
         {
             affected.Teleport(destinationCell);
         }
     }
 }
Example #22
0
        public D3Form()
        {
            InitializeComponent();

            BackColor = Color.FromArgb(26, 23, 18);

            var provider = new ShapesProvider();

            var shapes = Data.Select(x => new ImageShape(x.Image1.Size, x.Image1, x.Image2)).ToArray();

            for (var i = 0; i < shapes.Length; i++)
            {
                provider.Add(shapes[i]);

                if (i == 0)
                {
                    continue;
                }

                shapes[i].CenterLocation = shapes[i - 1].CenterLocation + new Vector2F(shapes[i - 1].CurrentImage.Width + 3, 0);
            }

            _topViewPort.Height   = shapes[0].CurrentImage.Height + 30;
            _topViewPort.Position = new Vector2F(_topViewPort.Width / 2 - shapes[0].CurrentImage.Width, 0);
            _topViewPort.Shapes   = provider;

            var viewPortInputInfoProcessor = _topViewPort.Add <ViewPortInputInfoProcessor>("View Port IIP");

            viewPortInputInfoProcessor.AllowChangePosition = true;
            viewPortInputInfoProcessor.AllowChangeZoom     = true;

            _topViewPort.Add <SelectionInputInfoProcessor>("Selection IIP");
            _topViewPort.Add <MouseOverInputInfoProcessor>("Mouse Over IIP");

            _fillViewPort.Shapes = new ShapesProvider();
        }
Example #23
0
        [EffectHandler(EffectsEnum.Eff_1041)]  //Appui du zobal
        public static void PushCaster(Fighter fighter, SpellLevelRecord level, ExtendedSpellEffect effect, List <Fighter> affecteds, short castcellid)
        {
            foreach (var target in affecteds)
            {
                List <short> line = ShapesProvider.GetLineFromOposedDirection(target.CellId, (byte)(effect.BaseEffect.DiceNum + 1), ShapesProvider.GetDirectionFromTwoCells(fighter.CellId, target.CellId));

                List <short> cells = new List <short>();
                foreach (var cell in line)
                {
                    if (!fighter.Fight.IsObstacle(cell) || cell == fighter.CellId)
                    {
                        cells.Add(cell);
                    }
                    else
                    {
                        break;
                    }
                }
                if (cells.Count > 0)
                {
                    fighter.Slide(fighter.ContextualId, cells);
                }
            }
        }
        public bool CanCast(short targetedcell, SpellLevelRecord level, Fighter targetedFighter)
        {
            if (level.CastInLine)
            {
                if (targetedcell == this.CellId && level.MinRange == 0)
                {
                    return(true);
                }
                var direction = ShapesProvider.GetDirectionFromTwoCells(this.CellId, targetedcell);
                if (direction == DirectionsEnum.DIRECTION_EAST || direction == DirectionsEnum.DIRECTION_NORTH ||
                    direction == DirectionsEnum.DIRECTION_SOUTH || direction == DirectionsEnum.DIRECTION_WEST)
                {
                    OnSpellCastFailed(CastFailedReason.RANGE, level);
                    return(false);
                }
                var line = ShapesProvider.GetLineFromDirection(CellId, level.MaxRange, direction);

                if (line.Contains(targetedFighter.CellId))
                {
                    return(true);
                }
                else
                {
                    OnSpellCastFailed(CastFailedReason.RANGE, level);
                    return(false);
                }
            }
            int Distance = PathHelper.GetDistanceBetween(targetedcell, this.CellId);

            if (Distance > level.MaxRange + FighterStats.Stats._Range || Distance < level.MinRange)
            {
                OnSpellCastFailed(CastFailedReason.RANGE, level);
                return(false);
            }
            return(true);
        }