示例#1
0
        public void FoundPeer(MCNearbyServiceBrowser browser, MCPeerID peerID, NSDictionary info)
        {
            if (peerID != this.myself.PeerId)
            {
                var appIdentifier = info?[XamarinShotGameAttribute.AppIdentifier];
                if (appIdentifier?.ToString() == NSBundle.MainBundle.BundleIdentifier)
                {
                    DispatchQueue.MainQueue.DispatchAsync(() =>
                    {
                        var player   = new Player(peerID);
                        var gameName = info?[XamarinShotGameAttribute.Name] as NSString;

                        GameTableLocation location = null;
                        var locationIdString       = info?[XamarinShotGameAttribute.Location] as NSString;
                        if (!string.IsNullOrEmpty(locationIdString) && int.TryParse(locationIdString, out int locationId))
                        {
                            location = GameTableLocation.GetLocation(locationId);
                        }

                        var game = new NetworkGame(player, gameName, location?.Identifier ?? 0);
                        this.games.Add(game);
                        this.Delegate?.SawGames(this, new List <NetworkGame>(this.games));
                    });
                }
            }
        }
示例#2
0
        public override void DidRangeBeacons(CLLocationManager manager, CLBeacon[] beacons, CLBeaconRegion region)
        {
            // we want to filter out beacons that have unknown proximity
            var knownBeacon = beacons.FirstOrDefault(beacon => beacon.Proximity != CLProximity.Unknown);

            if (knownBeacon != null)
            {
                GameTableLocation location = null;
                if (knownBeacon.Proximity == CLProximity.Near || knownBeacon.Proximity == CLProximity.Immediate)
                {
                    location = GameTableLocation.GetLocation(knownBeacon.Minor.Int32Value);
                }

                if (this.ClosestLocation != location)
                {
                    // Closest location changed
                    this.ClosestLocation = location;
                    this.Delegate?.LocationChanged(this, location);
                }
            }
        }