예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fight"></param>
        /// <param name="fighter"></param>
        /// <param name="currentCell"></param>
        /// <param name="encodedPath"></param>
        /// <returns></returns>
        public static MovementPath IsValidPath(AbstractFight fight, AbstractFighter fighter, int currentCell, string encodedPath)
        {
            if (encodedPath == "")
            {
                return(null);
            }

            var decodedPath = DecodePath(fight.Map, currentCell, encodedPath);
            var finalPath   = new MovementPath();

            var index       = 0;
            int transitCell = 0;

            do
            {
                transitCell = decodedPath.TransitCells[index];
                var length = Pathfinding.IsValidLine(fight, fighter, finalPath, transitCell, decodedPath.GetDirection(transitCell), decodedPath.TransitCells[index + 1]);
                if (length == -1)
                {
                    return(null);
                }
                else if (length == -2)
                {
                    break;
                }
                index++;
            }while (transitCell != decodedPath.LastStep);

            return(finalPath);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Map"></param>
        /// <param name="currentCell"></param>
        /// <param name="encodedPath"></param>
        /// <returns></returns>
        public static MovementPath IsValidPath(AbstractEntity entity, MapInstance map, int currentCell, string encodedPath)
        {
            var decodedPath = DecodePath(map, currentCell, encodedPath);

            if (decodedPath.TransitCells.Count == 0)
            {
                return(null);
            }
            var finalPath       = new MovementPath();
            var index           = 0;
            int transitCell     = 0;
            int nextTransitCell = 0;
            int direction       = 0;

            do
            {
                transitCell     = decodedPath.TransitCells[index];
                nextTransitCell = decodedPath.TransitCells[index + 1];
                direction       = decodedPath.GetDirection(transitCell);
                var length = Pathfinding.IsValidLine(entity, map, finalPath, transitCell, direction, nextTransitCell, decodedPath.EndCell);
                if (length == -1)
                {
                    return(null);
                }
                else if (length == -2)
                {
                    break;
                }
                index++;
            }while (transitCell != decodedPath.LastStep);

            if (entity.Type == EntityTypeEnum.TYPE_CHARACTER)
            {
                var mapCell = map.GetCell(decodedPath.EndCell);
                if (mapCell != null && mapCell.InteractiveObject != null && mapCell.InteractiveObject is Pheonix)
                {
                    var character = (CharacterEntity)entity;
                    character.AutomaticSkillId     = (int)SkillIdEnum.SKILL_USE_PHOENIX;
                    character.AutomaticSkillCellId = decodedPath.EndCell;
                    character.AutomaticSkillMapId  = map.Id;
                }
            }

            return(finalPath);
        }