Esempio n. 1
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="fight"></param>
        ///// <param name="team"></param>
        ///// <param name="cellId"></param>
        ///// <returns></returns>
        public static List <AbstractFighter> GetFightersNear(AbstractFight fight, int cellId)
        {
            List <AbstractFighter> fighters = new List <AbstractFighter>();

            foreach (var direction in Pathfinding.FIGHT_DIRECTIONS)
            {
                var fighter = fight.GetFighterOnCell(Pathfinding.NextCell(fight.Map, cellId, direction));
                if (fighter != null)
                {
                    if (!fighter.IsFighterDead)
                    {
                        fighters.Add(fighter);
                    }
                }
            }
            return(fighters);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fight"></param>
        /// <param name="fighter"></param>
        /// <param name="path"></param>
        /// <param name="beginCell"></param>
        /// <param name="direction"></param>
        /// <param name="endCell"></param>
        /// <returns></returns>
        public static int IsValidLine(AbstractFight fight, AbstractFighter fighter, MovementPath path, int beginCell, int direction, int endCell)
        {
            var length     = -1;
            var actualCell = beginCell;

            if (!Pathfinding.InLine(fight.Map, beginCell, endCell))
            {
                return(length);
            }

            length = (int)GoalDistance(fight.Map, beginCell, endCell);

            path.AddCell(actualCell, direction);

            for (int i = 0; i < length; i++)
            {
                actualCell = Pathfinding.NextCell(fight.Map, actualCell, direction);

                if (!fight.Map.IsWalkable(actualCell))
                {
                    return(-2);
                }

                if (fight.GetFighterOnCell(actualCell) != null)
                {
                    return(-2);
                }

                path.AddCell(actualCell, direction);
                path.MovementLength++;

                if (Pathfinding.IsStopCell(fighter.Fight, fighter.Team, actualCell))
                {
                    return(-2);
                }
            }

            return(length);
        }