예제 #1
0
        public static decimal GetAPCostToMove(Player player, string newLocation)
        {
            var     oldLocationl = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == player.dbLocationName);
            var     newLocationl = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == newLocation);
            decimal output       = PathfindingProcedures.GetNumSteps(oldLocationl, newLocationl);

            output *= 1 - player.MoveActionPointDiscount;

            return(output);
        }
예제 #2
0
        public static string MoveTo(Player bot, string locationDbName, int distance, Action <Player, string> playerEnteredTile = null)
        {
            var botLocation = bot.dbLocationName;

            if (botLocation == locationDbName)
            {
                return(botLocation);
            }

            var start = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == botLocation);
            var end   = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == locationDbName);

            var pathTiles = PathfindingProcedures.GetMovementPath(start, end);

            if (pathTiles.Count == 0)
            {
                return(botLocation);
            }

            var botName = bot.FirstName + " " + bot.LastName;

            var nextTileIndex = 0;
            var nextTile      = botLocation;
            var nextTileName  = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == nextTile).Name;

            var numberOfSteps = Math.Min(distance, pathTiles.Count);

            while (nextTileIndex < numberOfSteps)
            {
                var currentTile     = nextTile;
                var currentTileName = nextTileName;

                nextTile     = pathTiles[nextTileIndex++];
                nextTileName = LocationsStatics.LocationList.GetLocation.FirstOrDefault(l => l.dbName == nextTile).Name;

                LocationLogProcedures.AddLocationLog(currentTile, botName + " left toward " + nextTileName);
                LocationLogProcedures.AddLocationLog(nextTile, botName + " entered from " + currentTileName);

                if (playerEnteredTile != null)
                {
                    playerEnteredTile(bot, nextTile);
                }
            }

            return(nextTile);
        }