public void UpdateWalls(BombFighter fighter)
        {
            bool seq = fighter.Fight.SequencesManager.StartSequence(SequenceTypeEnum.SEQUENCE_SPELL);

            foreach (var wall in new List <Wall>(fighter.Walls))
            {
                if (wall.Valid() == false)
                {
                    wall.Destroy();
                }
            }

            foreach (var direction in WallDirections)
            {
                MapPoint current = fighter.Point.GetCellInDirection(direction, 1);

                for (byte i = 0; i < WALL_MAX_DISTANCE; i++)
                {
                    if (current != null)
                    {
                        current = current.GetCellInDirection(direction, 1);

                        if (current != null) // La cell n'existe pas
                        {
                            BombFighter target = fighter.Fight.GetFighter(current.CellId) as BombFighter;

                            if (target != null && target.IsOwner(fighter.Owner) && target.SpellBombRecord.SpellId == fighter.SpellBombRecord.SpellId)
                            {
                                foreach (var targetWall in target.Walls.ToArray())
                                {
                                    if (targetWall.ContainsCell(fighter.CellId))
                                    {
                                        targetWall.Destroy();
                                    }
                                }
                                Wall wall = fighter.Fight.AddWall(fighter.Owner, fighter.WallSpellLevel, fighter.WallSpellLevel.Effects.FirstOrDefault(), fighter, target, i);

                                foreach (var cell in wall.GetCells())
                                {
                                    var wall2 = fighter.Walls.FirstOrDefault(x => x.ContainsCell(cell));

                                    if (wall2 != null)
                                    {
                                        wall2.Destroy();
                                    }
                                }

                                fighter.Walls.Add(wall);
                                target.Walls.Add(wall);
                                break;
                            }
                        }
                    }
                }
            }
            if (seq)
            {
                fighter.Fight.SequencesManager.EndSequence(SequenceTypeEnum.SEQUENCE_SPELL);
            }
        }
        public Wall CreateWall(BombFighter source, BombFighter target, short spellId, sbyte spellGrade, int color)
        {
            int  wallRadius = PathHelper.GetDistanceBetween(source.CellId, target.CellId);
            Wall wall       = new Wall(source.Master, target.CellId, source.CellId, WALL_SHAPE, (short)wallRadius, spellId, spellGrade, color, source, target);

            return(wall);
        }
 public Wall(Fighter caster, short centercell, short entitycell, char shapetype,
             short radius, short associatedspellid, sbyte spellgrade,
             int markcolor, BombFighter firstBomb, BombFighter secondBomb) : base(caster, centercell, entitycell, shapetype, radius,
                                                                                  associatedspellid, spellgrade, markcolor)
 {
     this.FirstBomb  = firstBomb;
     this.SecondBomb = secondBomb;
 }
Exemple #4
0
 public Wall(short id, Fighter source, SpellLevelRecord spellLevel, EffectInstance effect,
             MapPoint startPoint, Color color, BombFighter firstBomb, BombFighter secondBomb, byte delta, DirectionsEnum direction)
     : base(id, source, spellLevel, effect, startPoint, new Zone(WALL_SHAPE, delta, direction), color,
            MarkTriggerTypeEnum.ON_TURN_STARTED | MarkTriggerTypeEnum.ON_CAST | MarkTriggerTypeEnum.AFTER_MOVE)
 {
     this.FirstBomb  = firstBomb;
     this.SecondBomb = secondBomb;
 }
Exemple #5
0
 public Wall(Fighter caster,short centercell,short entitycell,char shapetype,
     short radius,short associatedspellid,sbyte spellgrade,
     int markcolor,BombFighter firstBomb,BombFighter secondBomb)
     : base(caster,centercell,entitycell,shapetype,radius,
     associatedspellid,spellgrade,markcolor)
 {
     this.FirstBomb = firstBomb;
     this.SecondBomb = secondBomb;
 }
        // CONSTRUCTORS
        public BombWall(Fight fight, FightActor caster, Spell castedSpell, BombFighter from, BombFighter to)
        {
            this.m_wall = new List <BombWallTrigger>();

            this.Fight  = fight;
            this.Caster = caster;
            this.Spell  = castedSpell;

            this.From = from;
            this.To   = to;
        }
        public IEnumerable <Wall> GetPotentialWalls(Fight fight, BombFighter bomb)
        {
            List <short> checkedCells = GetCheckedCells(bomb.CellId);

            foreach (var cellId in checkedCells)
            {
                BombFighter fighter = fight.GetFighter <BombFighter>(x => x.CellId == cellId && x.MonsterTemplate.Id == bomb.MonsterTemplate.Id);

                if (fighter != null && fighter != bomb && fighter.Fight.GetMarks <Wall>().Find(x => x.Cells.Contains(cellId)) == null)
                {
                    Wall wall = MarksHelper.Instance.CreateWall(bomb, fighter, (short)bomb.BombWallRecord.SpellId, bomb.Grade, bomb.BombWallRecord.Color);
                    yield return(wall);
                }
            }
            yield break;
        }
Exemple #8
0
        public override bool Apply(Fighter[] targets)
        {
            var target = Fight.GetFighter(CastPoint);

            if (target != null)
            {
                SpellBombRecord record = SpellBombRecord.GetSpellBombRecord(SpellLevel.SpellId);
                var             level  = SpellRecord.GetSpellRecord(record.CibleExplosionSpellId).GetLevel(SpellLevel.Grade);
                Source.ForceSpellCast(level, CastPoint.CellId);
            }
            else
            {
                MonsterRecord record  = MonsterRecord.GetMonster(Effect.DiceMin);
                BombFighter   fighter = new BombFighter(record, Source, Source.Team, CastPoint.CellId, SpellLevel.Grade, SpellLevel);
                Fight.AddBomb(fighter, Source);
            }
            return(true);
        }
Exemple #9
0
 public void AddBomb(BombFighter fighter)
 {
     m_fighters.Add(fighter);
     fighter.Fight = Fight;
 }
Exemple #10
0
 public void SpawnBomb(Fighter master,short templateid,sbyte grade,short cellid,FightTeam team)
 {
     BombFighter bomb = new BombFighter(master,team,MonsterRecord.GetMonster((ushort)templateid),cellid,grade);
     Send(new GameActionFightSummonMessage(181,bomb.ContextualId,bomb.FighterInformations));
     bomb.CheckWalls();
 }
        public override bool Apply()
        {
            bool result;
            var  monsterGrade = Singleton <MonsterManager> .Instance.GetMonsterGrade((int)base.Dice.DiceNum, (int)base.Dice.DiceFace);

            if (monsterGrade == null)
            {
                SummonBomb.logger.Error <short, short>("Cannot summon monster {0} grade {1} (not found)", base.Dice.DiceNum, base.Dice.DiceFace);
                result = false;
            }
            else
            {
                var spellBombTemplate = Singleton <SpellManager> .Instance.GetSpellBombTemplate(base.Dice.DiceNum);

                if (!this.Fight.IsCellFree(base.TargetedCell))
                {
                    if (spellBombTemplate != null)
                    {
                        var instantSpell = this.GetInstantSpell(spellBombTemplate);
                        if (instantSpell != null)
                        {
                            base.Caster.ForceCastSpell(instantSpell, base.TargetedCell);
                        }
                    }

                    result = false;
                }
                else
                {
                    if (!this.Caster.CanPutBomb())
                    {
                        result = false;
                    }
                    else
                    {
                        var bomb = new BombFighter(base.Fight.GetNextContextualId(), base.Caster.Team, base.Caster, monsterGrade, base.TargetedCell);
                        ActionsHandler.SendGameActionFightSummonMessage(base.Fight.Clients, bomb);

                        var bombs = base.Caster.BombsOfType(monsterGrade.Template)
                                    .Where((BombFighter entry) => entry.Position.Point.X == bomb.Position.Point.X || entry.Position.Point.Y == bomb.Position.Point.Y);

                        if (bombs.Any() && spellBombTemplate != null)
                        {
                            var instantSpell = this.GetInstantSpell(spellBombTemplate);
                            if (instantSpell != null)
                            {
                                foreach (var bombFighter in bombs)
                                {
                                    var distance = bombFighter.Position.Point.DistanceToCell(bomb.Position.Point);

                                    if (distance < BombWall.MAX_BOMB_DISTANCE)
                                    {
                                        var trigger = new BombWall(base.Fight, base.Caster, instantSpell, bombFighter, bomb);

                                        // TODO

                                        trigger.MarkWall();
                                    }
                                }
                            }
                        }

                        base.Caster.AddBomb(bomb);
                        base.Caster.Team.AddFighter(bomb);
                        result = true;
                    }
                }
            }

            return(result);
        }
Exemple #12
0
        public Wall AddWall(Fighter source, SpellLevelRecord level, EffectInstance effect, BombFighter firstBomb, BombFighter secondBomb, byte delta)
        {
            var  direction = firstBomb.Point.OrientationTo(secondBomb.Point, true);
            Wall wall      = new Wall((short)this.m_markIdPopper.Pop(), source, level, effect, firstBomb.Point.GetCellInDirection(direction, 1), Color.FromArgb(firstBomb.SpellBombRecord.WallColor),
                                      firstBomb, secondBomb, delta, direction);

            this.AddMark(wall);
            return(wall);
        }
 public void AddBomb(BombFighter fighter)
 {
     m_fighters.Add(fighter);
     fighter.Fight = Fight;
 }