Esempio n. 1
0
        public void OnComplete(Android.Gms.Tasks.Task task)
        {
            if (task.IsSuccessful)
            {
                var documents = (QuerySnapshot)task.Result;


                foreach (var doc in documents.Documents)
                {
                    Locations loc = new Locations();
                    loc.Centers = new List <string>();

                    loc.Location = (string)doc.Get("Location");
                    var centersDoc  = doc.Get("Centers");
                    var centersList = new Android.Runtime.JavaList((System.Collections.IEnumerable)centersDoc);

                    var list = centersList.ToArray();

                    for (int i = 0; i < list.Length; i++)
                    {
                        var o = (Java.Lang.Object)list[i].ToString();

                        loc.Centers.Add((string)o);
                    }

                    AllLocations.Add(loc);
                }
                HasLocations = true;
            }
            else
            {
                AllLocations.Clear();
            }
        }
Esempio n. 2
0
 public Solution(IPuzzle puzzle) : base(puzzle, x => x.Trim('\n').Split("\n"))
 {
     foreach (var i in Input)
     {
         string[] split = i.Split(',');
         AllLocations.Add(new Location(int.Parse(split[0]), int.Parse(split[1])));
     }
 }
Esempio n. 3
0
 public void AddLocation(Location l)
 {
     if (l.TerrainType == Terrain.WalkableWater)
     {
         _locations[(int)Terrain.Swamp].Add(l);
     }
     else
     {
         _locations[(int)l.TerrainType].Add(l);
     }
     AllLocations.Add(l);
     _locsByCoords.Add(l.Coords, l);
 }
Esempio n. 4
0
        //---------------------------------------------------------------------
        public void Add(ActiveSite site)
        {
            AllLocations.Add(site.Location);
            this.activeArea = AllLocations.Count * Model.Core.CellArea;
            //set site var
            SiteVars.Stand[site] = this;

            //loop- really just 2 locations, relative (-1, 0) and relative (0, -1)
            foreach (RelativeLocation neighbor_loc in neighborsAboveAndLeft)
            {
                //check this site for neighbors that are different
                Site neighbor = site.GetNeighbor(neighbor_loc);
                if (neighbor != null && neighbor.IsActive)
                {
                    //declare a stand with this site as its index.
                    Stand neighbor_stand = SiteVars.Stand[neighbor];
                    //check for non-null stand
                    //also, only allow stands in same management area to be called neighbors
                    if (neighbor_stand != null && this.ManagementArea == neighbor_stand.ManagementArea)
                    {
                        //if neighbor_stand is different than this stand, then it is a true
                        //neighbor.  add it as a neighbor and add 'this' as a neighbor of that.
                        if (this != neighbor_stand)
                        {
                            //add neighbor_stand as a neighboring stand to this
                            AddNeighbor(neighbor_stand);
                            //add this as a neighboring stand to neighbor_stand
                            neighbor_stand.AddNeighbor(this);
                        }
                    }
                    //take into account other management areas just for stand-adjacency issue
                    else if (neighbor_stand != null && this.ManagementArea != neighbor_stand.ManagementArea)
                    {
                        if (this != neighbor_stand)
                        {
                            //add neighbor_stand as a ma-neighboring stand to this
                            AddMaNeighbor(neighbor_stand);
                            //add this as a ma-neighbor stand to neighbor_stand
                            neighbor_stand.AddMaNeighbor(this);
                        }
                    }
                }
            }
        }