Ejemplo n.º 1
0
        /// <summary>
        /// Add a new nearby
        /// </summary>
        /// <param name="name">The name of the nearby place</param>
        /// <param name="location">The location of the nearby place</param>
        /// <param name="type">The type of the nearby place</param>
        /// <returns>A new nearby place</returns>
        public Nearby AddNearby(string name, string location, NearbyType type)
        {
            Nearby nearby = new Nearby(name, location, type);

            context.NearbyPlaces.Add(nearby);
            context.SaveChanges();
            return(nearby);
        }
Ejemplo n.º 2
0
 protected override void OnPulse()
 {
     Nearby.Update();
     Cluster.Update();
     CloseNearby.Update();
     BestCluster.Update();
     LargeCluster.Update();
 }
Ejemplo n.º 3
0
        internal void FindNewContacts()
        {
            _dictionary = new Dictionary <int, HashSet <Body> >();

            BroadPhase.UpdatePairs(OnBroadphaseCollision);

            Nearby?.Invoke(this, new NearbyEventArg(_dictionary));
        }
Ejemplo n.º 4
0
 public override void Update(KeyboardState keyboard, MouseState mouse)
 {
     if (keyboard.IsKeyDown(Key.F))
     {
         //Console.WriteLine("F");
         Rotate();
     }
     Rotate();
     Move();
     Accelerate();
     Nearby.Clear();
     //Console.WriteLine(PitchAngle + ", " + YawAngle + ", " + RollAngle);
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            FManager = FragmentManager;
            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            OnNavigationItemSelected(navigation.Menu.GetItem(0));
            sMessageEngine = Nearby.GetMessageEngine(this);
            RequestPermissions();
            sMessageEngine.RegisterStatusCallback(new MyStatusCallback()).AddOnCompleteListener(new TaskListener(this, " RegisterStatusCallback")).AddOnFailureListener(new TaskListener(this, " RegisterStatusCallback"));
        }
Ejemplo n.º 6
0
        public Dictionary <int, string> GetValidFieldPositions()
        {
            //< Get all nearby, valid tix
            var validTix = Nearby.Where(x => x.IsValid(this));

            //< Instantiate a hashset of all 'solved' notes and a map of which indices have been solved by what note
            var usedFields = new HashSet <string>();
            var positions  = new Dictionary <int, string>();

            //< Grab the ticket count so we know how values a note must cover to be a potential solution
            int ticketCount = validTix.Count();

            //< Need to solve for each position within the tickets
            while (usedFields.Count != Mine.Length)
            {
                foreach (int i in Enumerable.Range(0, Mine.Length))
                {
                    if (positions.ContainsKey(i))
                    {
                        //< Already solved - skip
                        continue;
                    }

                    //< Get all the values at this position in the ticket from nearby, valid tix
                    var vals = validTix.Select(x => x.GetValue(i));
                    //< Get the map of number of times a note covered a value in this index
                    var noteMap = GetNoteMap(vals);
                    //< Get the matching notes (notes which were covered by all tix)
                    var matching = noteMap.Where(kvp => !usedFields.Contains(kvp.Key))
                                   .Where(kvp => kvp.Value == ticketCount);
                    //< Switch on the resulting count - if more than one, need to solve other positions first
                    if (matching.Count() > 1)
                    {
                        //< Can't decide yet - retain for later check
                    }
                    else
                    {
                        //< Only one solution here - use it and move on
                        var match = matching.Single();
                        positions.Add(i, match.Key);
                        usedFields.Add(match.Key);
                    }
                }
            }

            return(positions);
        }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.ActivityTabbed);

            Navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);
            Navigation.SetOnNavigationItemSelectedListener(this);
            FManager  = FragmentManager;
            M_SERVICE = this;
            OnNavigationItemSelected(Navigation.Menu.GetItem(0));
            mTransferEngine  = Nearby.GetTransferEngine(this);
            mWifiShareEngine = Nearby.GetWifiShareEngine(this);
            mDiscoveryEngine = Nearby.GetDiscoveryEngine(this);
            Adapter          = new ExpandableAdapter(this, AvaliableDevicesList);
            RequestPermissions();
        }
    void Explode()
    {
        Exp_Particle.Play();


        Collider[] colliders = Physics.OverlapSphere(transform.position, blast_rad);

        foreach (Collider Nearby in colliders)
        {
            Rigidbody rb = Nearby.GetComponent <Rigidbody>();
            if (rb != null)
            {
                rb.AddExplosionForce(blast_force, transform.position, blast_rad);
            }
        }

        has_Explode = true;
    }
Ejemplo n.º 9
0
        public Tickets(string fields, string nearbyTickets, string myTicket)
        {
            Fields = fields
                     .SplitLines()
                     .Select(x => new Field(x))
                     .ToList();

            Nearby = nearbyTickets
                     .SplitLines()
                     .Select(x => new Ticket(x.SplitOn(',').Select(int.Parse), Fields))
                     .ToList();

            MyTicket = new Ticket(myTicket.SplitOn(',').Select(int.Parse), Fields);

            ValidTickets = new List <Ticket>(Nearby.Where(x => x.IsValid))
            {
                MyTicket
            };
        }
Ejemplo n.º 10
0
        public TicketManager(IEnumerable <string> input)
        {
            this.Source = input.ToList();

            int blankCounter = 0;

            foreach (var line in input)
            {
                if (line == "")
                {
                    blankCounter++;
                }
                else if (!line.EndsWith(":"))
                {
                    switch (blankCounter)
                    {
                    case 0:
                        Notes.Add(new TicketNote(line));
                        break;

                    case 1:
                        Mine = new Ticket(line);
                        break;

                    case 2:
                        Nearby.Add(new Ticket(line));
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }

            PopulateRangeMap();
        }