Exemplo n.º 1
0
        /// <summary>
        /// If it is a replay, it will go through a specific number of locations from the replayLocations List for each ship
        /// If it is live, it will get the live locations from the backend and go throught them for each ship
        /// </summary>
        /// <returns></returns>
        private bool LoadPoints()
        {
            if (isPlaying)
            {
                mapView.ClearMap();

                sortedLocations = new List <ShipLocation>();

                if (isReplay)
                {
                    foreach (ShipLocation shipLocation in replayLocations)
                    {
                        int amount = replayAmount;

                        if (currentIndex + replayAmount > shipLocation.LocationsRegistrations.Count)
                        {
                            amount = shipLocation.LocationsRegistrations.Count - (currentIndex + 1);
                        }
                        if (amount > 0)
                        {
                            sortedLocations.Add(new ShipLocation {
                                ShipId = shipLocation.ShipId, LocationsRegistrations = new List <Location>(), TeamName = shipLocation.TeamName
                            });

                            RegisterReplay(shipLocation, currentIndex, amount);
                        }
                    }
                    currentIndex += speed;

                    if (sortedLocations.Count > 1)
                    {
                        sortedLocations.Sort((a, b) => (a.LocationsRegistrations.Last().RaceScore < b.LocationsRegistrations.Last().RaceScore ? 1 : -1));
                        Console.WriteLine("Count = " + sortedLocations.Count);

                        for (int i = 0; i < sortedLocations.Count; i++)
                        {
                            sortedLocations[i].Placement = i + 1;
                        }
                    }
                    Locations = sortedLocations;
                }
                else
                {
                    Locations = serverClient.GetLiveLocations(sharedData.SelectedEvent.EventId);
                    foreach (ShipLocation shipLocation in Locations)
                    {
                        RegisterLive(shipLocation);
                    }
                }
                if (sharedData.isMapDisplayed)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }