Пример #1
0
 public void onActorMoved(Fighter Fighter, Maps.MovementPath Path, FightCell NewCell)
 {
     if (NewCell.HasIFightObject(this))
     {
         onWalkOnLayer(Fighter, NewCell);
     }
 }
Пример #2
0
 public override void onActorMoved(Fighter Fighter, Maps.MovementPath Path, FightCell NewCell)
 {
     if (Fighter.Team == Fight.Team1 && Path.MovementLength != 1)
     {
         Failure(Fighter);
     }
 }
Пример #3
0
        public static bool CheckCellView(Map Map, Fight fight, double x, double y, bool boolean, Point p1, Point p2, double zDiff, double d)
        {
            var       CellId = GetCellNumber(Map, x, y);
            FightCell cell   = fight.GetCell(CellId);

            if (cell == null)
            {
                return(true);
            }
            double YZMaxDiff  = Math.Max(Math.Abs(p1.Y - y), Math.Abs(p1.X - x));
            var    Gradient   = YZMaxDiff / d * zDiff + p1.Z;
            var    CellHeight = GetCellHeight(Map, CellId);
            var    IsFull     = cell.HasUnWalkableFighter() || (YZMaxDiff == 0 || (boolean || p2.X == x && p2.Y == y)) ? (false) : (true);
            bool   ok         = cell.LineOfSight() && (CellHeight <= Gradient && !cell.HasUnWalkableFighter());

            if (!ok)
            {
                //fight.SendToFight(new FightShowCell(fight.Fighters[0].ActorId, CellId));
                return(boolean);
            }
            else
            {
                return(true);
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cell"></param>
        /// <returns></returns>
        public FightActionResultEnum SetCell(FightCell cell)
        {
            if (IsFighterDead)
            {
                return(FightActionResultEnum.RESULT_DEATH);
            }

            if (Cell != null)
            {
                if (Cell == cell)
                {
                    return(FightActionResultEnum.RESULT_NOTHING);
                }

                var removeResult = Cell.RemoveObject(this);
                if (removeResult != FightActionResultEnum.RESULT_NOTHING)
                {
                    return(removeResult);
                }
            }

            Cell = cell;

            if (Cell != null)
            {
                var moveResult = Cell.AddObject(this);
                if (moveResult != FightActionResultEnum.RESULT_NOTHING)
                {
                    return(moveResult);
                }

                var buffResult = BuffManager.EndMove();
                if (buffResult != FightActionResultEnum.RESULT_NOTHING)
                {
                    return(buffResult);
                }

                if (Fight.LoopState != FightLoopStateEnum.STATE_ENDED)
                {
                    return(Fight.TryKillFighter(this, this));
                }
            }

            if (Fight.State != FightStateEnum.STATE_FIGHTING)
            {
                return(FightActionResultEnum.RESULT_NOTHING);
            }

            return(FightActionResultEnum.RESULT_NOTHING);
        }
Пример #5
0
        public static List <int> GetWeaponCells(int WeaponType, Map map, FightCell Cell, int CasterCell)
        {
            List <int> Cells = new List <int>();
            char       c     = getDirBetweenTwoCase(CasterCell, Cell.Id, map, true);

            if (c == (char)0)
            {
                if (Cell.HasGameObject(FightObjectType.OBJECT_FIGHTER) | Cell.HasGameObject(FightObjectType.OBJECT_STATIC))
                {
                    Cells.Add(Cell.Id);
                    return(Cells);
                }
            }
            switch ((ItemTypeEnum)WeaponType)
            {
            case ItemTypeEnum.ITEM_TYPE_MARTEAU:
                Cells.Add(getFighter2CellBefore(CasterCell, c, map));
                Cells.Add(get1StFighterOnCellFromDirection(map, CasterCell, (char)(c - 1)));
                Cells.Add(get1StFighterOnCellFromDirection(map, CasterCell, (char)(c + 1)));
                Cells.Add(Cell.Id);
                break;

            case ItemTypeEnum.ITEM_TYPE_BATON:
                Cells.Add(get1StFighterOnCellFromDirection(map, CasterCell, (char)(c - 1)));
                Cells.Add(get1StFighterOnCellFromDirection(map, CasterCell, (char)(c + 1)));
                Cells.Add(Cell.Id);
                break;

            case ItemTypeEnum.ITEM_TYPE_PIOCHE:
            case ItemTypeEnum.ITEM_TYPE_EPEE:
            case ItemTypeEnum.ITEM_TYPE_FAUX:
            case ItemTypeEnum.ITEM_TYPE_DAGUES:
            case ItemTypeEnum.ITEM_TYPE_BAGUETTE:
            case ItemTypeEnum.ITEM_TYPE_PELLE:
            case ItemTypeEnum.ITEM_TYPE_ARC:
            case ItemTypeEnum.ITEM_TYPE_HACHE:
                Cells.Add(Cell.Id);
                break;
            }
            return(Cells);
        }
Пример #6
0
 public FightTrapLayer(Fighter Caster, SpellLevel CastSpell, FightCell CastCell, int MasterSpellId, int MasterSpellSpriteId, String Zone)
     : base(FightObjectType.OBJECT_TRAP, Caster, CastSpell, CastCell, MasterSpellId, MasterSpellSpriteId, Zone, -1)
 {
 }
Пример #7
0
        public override void onWalkOnLayer(Fighter fighter, FightCell newCell)
        {
            this.Triggered(fighter);
            List <FightCell> myCells = new List <FightCell>();

            myCells.AddRange(this.myCells);
            Dispose();

            // Combat encore en cour ?
            if (this.Fight.FightState != Fights.FightState.STATE_ACTIVE)
            {
                return;
            }

            // La cible si elle existe
            var  TargetE  = this.Fight.HasEnnemyInCell(CellId, Caster.Team);
            long TargetId = TargetE == null ? -1 : TargetE.ActorId;

            CastSpell.Initialize();

            var Effects = CastSpell.Effects;

            if (Effects == null)
            {
                Effects = CastSpell.CriticEffects;
            }
            var Targets = new Dictionary <EffectInfos, List <Fighter> >();

            foreach (var Effect in Effects)
            {
                Targets.Add(Effect, new List <Fighter>());
                foreach (var FightCell in myCells)
                {
                    if (FightCell != null)
                    {
                        if (FightCell.HasGameObject(FightObjectType.OBJECT_FIGHTER) | FightCell.HasGameObject(FightObjectType.OBJECT_STATIC))
                        {
                            Targets[Effect].AddRange(FightCell.GetObjects <Fighter>());
                        }
                    }
                }
                if (!Targets[Effect].Contains(fighter))
                {
                    Targets[Effect].Add(fighter);
                }
            }

            var ActualChance = 0;

            foreach (var Effect in Effects)
            {
                if (Effect.Chance > 0)
                {
                    if (Fight.RANDOM.Next(1, 100) > (Effect.Chance + ActualChance))
                    {
                        ActualChance += Effect.Chance;
                        continue;
                    }
                    ActualChance -= 100;
                }

                // Actualisation des morts
                Targets[Effect].RemoveAll(F => F.Dead);
                var CastInfos = new EffectCast(Effect.EffectType, CastSpell.SpellCache.ID, CellId, Effect.Value1, Effect.Value2, Effect.Value3, Effect.Chance, Effect.Duration, Caster, Targets[Effect], false, EffectEnum.None, 0, Effect.Spell);

                if (EffectBase.TryApplyEffect(CastInfos) == -3)
                {
                    break;
                }
            }
            if (!this.Fight.TryEndFight())
            {
                this.Fight.onApplyGroundLayer(this, Caster, CastSpell, CellId, fighter, Targets);
            }
        }
Пример #8
0
 public override void onActorMoved(Fighter Fighter, Maps.MovementPath Path, FightCell NewCell)
 {
 }
Пример #9
0
 public virtual void onActorMoved(Fighter Fighter, Maps.MovementPath Path, FightCell NewCell)
 {
 }
Пример #10
0
 public FightGlypheLayer(Fighter Caster, SpellLevel CastSpell, FightCell CastCell, int MasterSpellId, short Duration, String Zone)
     : base(FightObjectType.OBJECT_GLYPHE, Caster, CastSpell, CastCell, MasterSpellId, 0, Zone, Duration)
 {
 }
Пример #11
0
 public override void onWalkOnLayer(Fighter fighter, FightCell newCell)
 {
 }
Пример #12
0
        public FightGroundLayer(FightObjectType myObjectType, Fighter Caster, SpellLevel CastSpell, FightCell CastCell, int MasterSpellId, int MasterSpellSpriteId, String Zone, short Duration = -1)
        {
            this.myObjectType        = myObjectType;
            this.myCell              = CastCell;
            this.Caster              = Caster;
            this.CastSpell           = CastSpell;
            this.Size                = (short)StringHelper.HashToInt(Zone[1]);
            this.Duration            = Duration;
            this.MasterSpellId       = MasterSpellId;
            this.MasterSpellSpriteId = MasterSpellSpriteId;

            //CastCell.AddObject(this);
            Fight.addLayer(this);
            Fight.RegisterFightListener(this);

            foreach (int cellId in CellZone.GetCells(this.Fight.Map, CellId, CellId, Zone))
            {
                var Cell = this.Fight.GetCell(cellId);
                if (Cell != null)
                {
                    myCells.Add(Cell);
                    Cell.AddObject(this);
                }
            }

            Show(Caster);
        }
Пример #13
0
 public abstract void onWalkOnLayer(Fighter fighter, FightCell newCell);
Пример #14
0
        public static bool CheckView(Map Map, Fight fight, int Cell1, int Cell2)
        {
            Point Cell1_Point = new Point(GetCoordinates(Map, Cell1));
            Point Cell2_Point = new Point(GetCoordinates(Map, Cell2));

            FightCell cell1 = fight.GetCell(Cell1);
            FightCell cell2 = fight.GetCell(Cell2);

            double Cell1_ZSpriteOnID = !cell1.IsWalkable() ? (1.5) : (0);

            Cell1_ZSpriteOnID += cell1.HasUnWalkableFighter() ? (1.5) : (0);
            double Cell2_ZSpriteOnID = !cell2.IsWalkable() ? (1.5) : (0);

            Cell2_ZSpriteOnID += cell2.HasUnWalkableFighter() ? (1.5) : (0);

            Cell1_Point.Z = GetCellHeight(Map, Cell1) + Cell1_ZSpriteOnID;
            Cell2_Point.Z = GetCellHeight(Map, Cell2) + Cell2_ZSpriteOnID;

            double ZDiff     = Cell2_Point.Z - Cell1_Point.Z;
            double YZMaxDiff = Math.Max(Math.Abs(Cell1_Point.Y - Cell2_Point.Y), Math.Abs(Cell1_Point.X - Cell2_Point.X));

            double CoeffDirector      = (Cell1_Point.Y - Cell2_Point.Y) / (Cell1_Point.X - Cell2_Point.X);
            double YTranslation_Cell1 = Cell1_Point.Y - CoeffDirector * Cell1_Point.X;

            int XReport = Cell2_Point.X - Cell1_Point.X < 0 ? (-1) : (1);
            int YReport = Cell2_Point.Y - Cell1_Point.Y < 0 ? (-1) : (1);

            double Cell1_X = Cell1_Point.X;
            double Cell1_Y = Cell1_Point.Y;

            double XTranslation_Cell2 = Cell2_Point.X * XReport;
            double YTranslation_Cell2 = Cell2_Point.Y * YReport;
            double XTranslation_Cell1 = Cell1_Point.X + 0.5 * XReport;

            var _loc26 = Cell1_Y;

            while ((XTranslation_Cell1 += XReport) * XReport <= XTranslation_Cell2)
            {
                var _loc25 = CoeffDirector * XTranslation_Cell1 + YTranslation_Cell1;

                double _loc21 = 0;
                double _loc22 = 0;
                if (YReport > 0)
                {
                    _loc21 = Math.Round(_loc25);
                    _loc22 = Math.Ceiling(_loc25 - 0.5);
                }
                else
                {
                    _loc21 = Math.Ceiling(_loc25 - 0.5);
                    _loc22 = Math.Round(_loc25);
                } // end else if

                _loc26 = Cell1_Y;

                while ((_loc26 += YReport) * YReport <= _loc22 * YReport)
                {
                    if (!CheckCellView(Map, fight, XTranslation_Cell1 - XReport / 2, _loc26, false, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
                    {
                        return(false);
                    }
                }

                Cell1_Y = _loc21;
            }

            _loc26 = Cell1_Y;

            while ((_loc26 += YReport) * YReport <= Cell2_Point.Y * YReport)
            {
                if (!CheckCellView(Map, fight, XTranslation_Cell1 - 0.5 * XReport, _loc26, false, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
                {
                    return(false);
                }
            }

            if (!CheckCellView(Map, fight, XTranslation_Cell1 - 0.5 * XReport, _loc26 - YReport, true, Cell1_Point, Cell2_Point, ZDiff, YZMaxDiff))
            {
                return(false);
            }

            return(true);
        }