float CalculateDistanceOfNowCoordinationToSpot(SpotData targetSpotData) { Vector2 a = new Vector2(locationCoordination.GetLongitude, locationCoordination.GetLatitude); Vector2 b = new Vector2(targetSpotData.longitude, targetSpotData.letitude); return(long_lati_calculator.GetInstance.CalculateLetiAndLongDistanceOfAtoB(a, b)); }
public static string SpotCreator(this SpotData spot) { var buf = new StringBuilder() .Append("new Spot(") .Append(Hash64(spot.Name ?? "")) .Append("ul,") .Append(Hash64(spot.DisplayName ?? "")) .Append("ul,") .Append(Hash64(spot.Image ?? "")) .Append("ul,") .Append(Hash64(spot.Map ?? "")) .Append("ul,") .Append(Hash64(spot.BGM ?? "")) .Append("ul,") .Append(Hash64(spot.Dungeon ?? "")) .Append("ul,new uint2(").Append(spot.X ?? 0).Append(',').Append(spot.Y ?? 0) .Append("),new uint2(").Append(spot.Width ?? 32).Append(',').Append(spot.Height ?? 32) .Append("),") .Append(spot.Gain ?? 0) .Append("ul,") .Append(spot.Castle ?? 0) .Append("ul,") .Append(spot.Limit ?? ScriptLoader.Context.btl_limit) .Append("ul,(ushort)") .Append(spot.CastleLot ?? ScriptLoader.Context.BattleCastleLot) .Append(",(byte)") .Append(spot.Volume ?? ScriptLoader.Context.BGMVolume) .Append(",(byte)") .Append(spot.Capacity ?? ScriptLoader.Context.SpotCapacity) .Append(",(byte)") .Append((spot.IsCastleBattle ?? false ? 1 : 0) | (spot.IsNotHome ?? false ? 2 : 0) | (spot.IsNotRaisableSpot ?? false ? 4 : 0) | (spot.Politics ?? false ? 8 : 0)) .Append(");"); return(buf.ToString()); }
public async Task NormalizeFromCacheAndSaveToDBAsync() { _logger.LogInformation("Normalizing and saving data to database"); try { var listOfSpots = await _cache.GetAsync <ConcurrentBag <string> >(_cachedSpotList); if (listOfSpots == null) { return; } var toSave = new List <SpotData>(); var actualTime = DateTimeOffset.Now.UtcDateTime.Truncate(TimeSpan.FromMinutes(1)); foreach (var id in listOfSpots) { var sensor = await _cache.GetAsync <SpotData>(id); var normalizedParkEntry = new SpotData() { SensorDevui = sensor.SensorDevui, Name = sensor.Name, ParkEntries = sensor.ParkEntries.Count == 0 ? new ConcurrentBag <ParkEntry>() : new ConcurrentBag <ParkEntry>() { new ParkEntry() { Parked = sensor.ParkEntries.Any(x => x.Parked), TimeStamp = actualTime } } }; sensor.ParkEntries.Clear(); toSave.Add(normalizedParkEntry); } var b = DateTimeOffset.Now.LocalDateTime.GetDateTimeFormats(); await SaveDataAsync(toSave); _logger.LogInformation("Data normalized succesfully"); } catch (NotFoundException ex) { _logger.LogError(ex, ex.Message); } catch (Exception ex) { _logger.LogError(ex, "Error while normalizing and saving data to database"); } }
Deck <SpotData> GenerateSpots() { // deck of spots Deck <SpotData> spots = new Deck <SpotData>(); // start at corner float x = transform.position.x - width / 2f; float z = transform.position.z - length / 2f; // start with a half-step offset to center coordinates float dx = width / 6f; float dz = length / 6f; SpotData curData = new SpotData(); Vector3 curVec = Vector3.zero; Quaternion curRot = Quaternion.identity; // iterate through a grid for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { // current spot is corner + offsets curVec.x = x + dx; curVec.z = z + dz; curVec.y = 0f; // skip the center if (!(i == 1 && j == 1)) { curData.pos = curVec; SpotRotations(ref curData, i, j); spots.Add(curData); } // increase x offset dx += width / 3f; } // reset x offset, increase z offset dx = width / 6f; dz += length / 3f; } // shuffle spots.Shuffle(); // yay return(spots); }
void SpotRotations(ref SpotData curData, int i, int j) { // corner spots get two distinct rotation options // side spots get the same option twice if (i % 2 == 0 && j % 2 == 0) { // prefabs all face +z direction by default if (i == 2) // top wall: rotate 180 { curData.rot1 = Quaternion.AngleAxis(180, Vector3.up); } else // bottom wall: rotate 0 { curData.rot1 = Quaternion.identity; } if (j == 2) // left wall: rotate 270 { curData.rot2 = Quaternion.AngleAxis(270, Vector3.up); } else // right wall: rotate 90 { curData.rot2 = Quaternion.AngleAxis(90, Vector3.up); } } else { // Same as above but double if (i == 2) // top { curData.rot1 = curData.rot2 = Quaternion.AngleAxis(180, Vector3.up); } else if (i == 0) // bottom { curData.rot1 = curData.rot2 = Quaternion.identity; } else if (j == 2) // left { curData.rot1 = curData.rot2 = Quaternion.AngleAxis(270, Vector3.up); } else if (j == 0) // right { curData.rot1 = curData.rot2 = Quaternion.AngleAxis(90, Vector3.up); } } }
public void SetThisSpotData(SpotData NextSpotData) { thisSpotData = NextSpotData; }