コード例 #1
0
        private IEnumerable <VaultPossibleConnection> GetPossibleVaultConnections(IMap map, List <VaultPlacement> vaultPlacements)
        {
            foreach (var vault in vaultPlacements)
            {
                foreach (var otherVault in vaultPlacements.Except(new[] { vault }))
                {
                    foreach (var connectFrom in vault.VaultConnectionPoints)
                    {
                        foreach (var connectTo in otherVault.VaultConnectionPoints)
                        {
                            var pointsBetween = _lineDrawing.DrawLine(connectFrom.Coordinate, connectTo.Coordinate).Except(new[] { connectFrom.Coordinate, connectTo.Coordinate });

                            if (!pointsBetween.Any(p => map.CellExists(p)))
                            {
                                var connection = new VaultPossibleConnection
                                {
                                    FirstVault  = vault,
                                    SecondVault = otherVault,
                                    First       = connectFrom,
                                    Second      = connectTo
                                };

                                yield return(connection);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void AddVaultConnectionToMap(IMap map, VaultPossibleConnection vaultConnection)
        {
            if (vaultConnection.IsRightAngle)
            {
                var corner = vaultConnection.GetCorner();

                CarveCornerTunnel(map, vaultConnection.First.Coordinate, corner);
                CarveCornerTunnel(map, vaultConnection.Second.Coordinate, corner);
            }
            else // We're straight across.
            {
                var(firstCorner, secondCorner) = vaultConnection.GetCorners();

                CarveCornerTunnel(map, vaultConnection.First.Coordinate, firstCorner);
                CarveCornerTunnel(map, firstCorner, secondCorner);
                CarveCornerTunnel(map, secondCorner, vaultConnection.Second.Coordinate);
            }
        }