コード例 #1
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="cellId"></param>
        ///// <returns></returns>
        public static bool IsStopCell(AbstractFight fight, FightTeam team, int cellId)
        {
            if (fight.GetCell(cellId).HasObject(FightObstacleTypeEnum.TYPE_TRAP))
            {
                return(true);
            }

            if (GetEnnemiesNear(fight, team, cellId).Count() > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="activeType"></param>
        /// <param name="fight"></param>
        /// <param name="caster"></param>
        /// <param name="castInfos"></param>
        /// <param name="cell"></param>
        /// <param name="duration"></param>
        /// <param name="actionId"></param>
        /// <param name="canGoThrough"></param>
        /// <param name="canStack"></param>
        /// <param name="hide"></param>
        protected AbstractActivableObject(FightObstacleTypeEnum type, ActiveType activeType, AbstractFight fight, AbstractFighter caster, CastInfos castInfos, int cell, int duration, int actionId, bool canGoThrough, bool canStack, bool hide = false)
        {
            m_fight        = fight;
            m_caster       = caster;
            m_spellId      = castInfos.SpellId;
            m_actionSpell  = SpellManager.Instance.GetTemplate(castInfos.Value1);
            m_actionEffect = m_actionSpell.GetLevel(castInfos.Value2);

            Cell           = fight.GetCell(cell);
            ObstacleType   = type;
            ActivationType = activeType;
            CanGoThrough   = canGoThrough;
            CanStack       = canStack;
            Color          = castInfos.Value3;
            Targets        = new List <AbstractFighter>();
            Length         = Pathfinding.GetDirection(castInfos.RangeType[1]);
            AffectedCells  = new List <FightCell>();
            Duration       = duration;
            ActionId       = actionId;
            Hide           = hide;

            foreach (var effect in m_actionEffect.Effects)
            {
                if (CastInfos.IsDamageEffect(effect.TypeEnum))
                {
                    Priority--;
                }
            }

            // On ajout l'objet a toutes les cells qu'il affecte
            foreach (var cellId in CellZone.GetCircleCells(fight.Map, cell, Length))
            {
                var fightCell = m_fight.GetCell(cellId);
                if (fightCell != null)
                {
                    fightCell.AddObject(this);
                    AffectedCells.Add(fightCell);
                }
            }

            if (Hide)
            {
                Appear(caster.Team);
            }
            else
            {
                AppearForAll();
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fight"></param>
        /// <param name="beginCell"></param>
        /// <param name="endCell"></param>
        /// <returns></returns>
        public static bool CheckView(AbstractFight fight, int beginCell, int endCell)
        {
            return(BresenhamLine(fight, beginCell, endCell));

            var begin  = GetPoint(fight.Map, beginCell);
            var end    = GetPoint(fight.Map, endCell);
            var deltax = Math.Abs(end.X - begin.X);
            var deltay = Math.Abs(end.Y - begin.Y);
            var error  = deltax / 2;
            var ystep  = 1;

            if (end.Y < begin.Y)
            {
                ystep = -1;
            }

            var nextPoint = begin;

            while (nextPoint.X < end.X)
            {
                if (!nextPoint.Equals(begin) && !nextPoint.Equals(end))
                {
                    var fightCell = fight.GetCell(GetCell(fight.Map, nextPoint.X, nextPoint.Y));
                    if (fightCell == null)
                    {
                        return(false);
                    }
                    else if (!fightCell.LineOfSight)
                    {
                        return(false);
                    }
                    else if (fightCell.HasObject(FightObstacleTypeEnum.TYPE_FIGHTER))
                    {
                        return(false);
                    }
                }

                nextPoint.X++;

                error -= deltay;
                if (error < 0)
                {
                    nextPoint.Y += ystep;
                    error       += deltax;
                }
            }

            return(true);
        }
コード例 #4
0
        private static bool BresenhamLine(AbstractFight fight, int beginCell, int endCell, int x0, int y0, int x1, int y1)
        {
            bool steep = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);

            if (steep)
            {
                Swap(ref x0, ref y0);
                Swap(ref x1, ref y1);
            }
            if (x0 > x1)
            {
                Swap(ref x0, ref x1);
                Swap(ref y0, ref y1);
            }

            int deltax = x1 - x0;
            int deltay = Math.Abs(y1 - y0);
            int error  = 0;
            int ystep;
            int y = y0;

            if (y0 < y1)
            {
                ystep = 1;
            }
            else
            {
                ystep = -1;
            }
            for (int x = x0; x <= x1; x++)
            {
                int cellId = -1;
                if (steep)
                {
                    cellId = GetCell(fight.Map, y, x);
                }
                else
                {
                    cellId = GetCell(fight.Map, x, y);
                }
                if (cellId != beginCell && cellId != endCell)
                {
                    var fightCell = fight.GetCell(cellId);
                    if (fightCell == null)
                    {
                        return(false);
                    }
                    if (!fightCell.LineOfSight)
                    {
                        return(false);
                    }
                    if (fightCell.HasObject(FightObstacleTypeEnum.TYPE_FIGHTER))
                    {
                        return(false);
                    }
                }

                error += deltay;
                if (2 * error >= deltax)
                {
                    y     += ystep;
                    error -= deltax;
                }
            }

            return(true);
        }