private void OnProgressChanged(object sender, ProgressChangedEventArgs progressChangedEventArgs) { int scaleWidth = Width - PaddingLeft - PaddingRight; int deltaLimit = Max / 2 / _marksCount; for (int i = 0; i < _marksCount; i++) { float offset = MarksSpacing * i; int offsetProgress = (int)Math.Round(offset * 100 / scaleWidth); int delta = Math.Abs(Progress - offsetProgress); if (delta < 1 + _stopDelta) { _stopDelta = 5; SetProgress(offsetProgress, true); break; } if (delta < deltaLimit && _stopDelta != 0) { _stopDelta = 0; break; } } if (Progress < 1) { _stopDelta = 0; SetProgress(1, true); } }
public void Round(int digits) { for (int i = 0; i < 3; i++) { this[i] = Math.Round(this[i], digits); } }
private static H3.Cell.Edge[] ParameterizedFibers(Complex z) { List <H3.Cell.Edge> fibers = new List <H3.Cell.Edge>(); double scale = 0.1; Vector3D v1 = new Vector3D(0, -1); // -i Vector3D v2 = Vector3D.FromComplex(z); int count = (int)Math.Round(Math.Sqrt(NumFibers), 0); for (int i = -count / 2; i < count / 2; i++) { for (int j = 1; j < count; j++) // dilations should remain positive. { double t1 = scale * i; double t2 = scale * j; // Apply the dilation first. Vector3D _v1 = v1; Vector3D _v2 = v2; _v1 *= t2; _v2 *= t2; _v1.X += t1; _v2.X += t1; fibers.Add(new H3.Cell.Edge( H3Models.UHSToBall(_v1), H3Models.UHSToBall(_v2))); } } return(fibers.ToArray()); }
/// <summary> /// Gets fibers for the only fibration with parallel (vs. ultraparallel) fibers. /// Returns result in the ball model. /// </summary> private static H3.Cell.Edge[] ParallelFibers() { List <H3.Cell.Edge> fibers = new List <H3.Cell.Edge>(); double scale = 0.3; // Just a grid of vertical fibers. // We could do any kind of grid we want here really (square, hexagonal, random...) // Each would likely produce different results. // It'd be nice to figure out how to space out the results near the north pole. int count = (int)Math.Round(Math.Sqrt(NumFibers), 0); for (int i = -count / 2; i < count / 2; i++) { for (int j = -count / 2; j < count / 2; j++) { //double off1 = Math.Pow( scale*i, 3 ); //double off2 = Math.Pow( scale*j, 3 ); double off1 = scale * i; double off2 = scale * j; Vector3D v1 = new Vector3D(off1, off2); Vector3D v2 = new Vector3D(double.PositiveInfinity, 1); // Don't use Infinity.InfinityVector, because we want to distiguish this point as being on the boundary. fibers.Add(new H3.Cell.Edge( H3Models.UHSToBall(v1), H3Models.UHSToBall(v2))); } } return(fibers.ToArray()); }
private static Isometry SetupIsometry(Cell clickedCell, Vector3D clickedPoint, Puzzle puzzle) { int p = puzzle.Config.P; Geometry g = puzzle.Config.Geometry; Isometry cellIsometry = clickedCell.Isometry.Clone(); // Take out reflections. // ZZZ - Figuring out how to deal with these reflected isometries was a bit painful to figure out. // I wish I had just taken more care to not have any cell isometries with reflections. // Maybe I can rework that to be different at some point. if (cellIsometry.Reflection != null) { cellIsometry = Isometry.ReflectX() * cellIsometry; } // Round to nearest vertex. Vector3D centered = cellIsometry.Apply(clickedPoint); double angle = Euclidean2D.AngleToCounterClock(centered, new Vector3D(1, 0)); double angleFromZeroToP = p * angle / (2 * Math.PI); angleFromZeroToP = Math.Round(angleFromZeroToP, 0); if (p == (int)angleFromZeroToP) { angleFromZeroToP = 0; } angle = 2 * Math.PI * angleFromZeroToP / p; // This will take vertex to canonical position. Mobius rotation = new Mobius(); rotation.Isometry(g, angle, new Complex()); Isometry rotIsometry = new Isometry(rotation, null); return(rotIsometry * cellIsometry); }
public int GetHashCode(double tolerance) { // Normalize DNE vectors (since we consider any with any NaN component the same). if (this.DNE) { return(double.NaN.GetHashCode()); } // The hash code is dependent on the tolerance: more precision -> less rounding. // Rounding the hashcodes is necessary, since for a given tolerence we might // consider two quantities to be equal, but their hashcodes might differ // without the rounding. double inverse = 1 / tolerance; int decimals = (int)Math.Log10(inverse); return (Math.Round(X, decimals).GetHashCode() ^ Math.Round(Y, decimals).GetHashCode() ^ Math.Round(Z, decimals).GetHashCode() ^ Math.Round(W, decimals).GetHashCode()); // if 0 tolerance //return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); }
public void Add(double t) { //t = MathUtils.Round(t, 3); t = SysMath.Round(t, 3); if (this.times.Count == 0 || this.times[this.times.Count - 1].EpsilonL(t)) { this.times.Add(t); } }
/// <summary> /// Gets the memory cache size based on a percentage of the max available VM memory. /// </summary> /// <example>setting percent to 0.2 would set the memory cache to one fifth of the available memory</example> /// <param name="percent">Percent of available app memory to use to size memory cache</param> /// <returns></returns> private static int GetCacheSizeInPercent(float percent) { if (percent < 0.01f || percent > 0.8f) { throw new Exception("GetCacheSizeInPercent - percent must be between 0.01 and 0.8 (inclusive)"); } return((int)Math.Round(percent * Runtime.GetRuntime().MaxMemory())); }
/// <summary> /// This is only here for a numerical accuracy hack. /// Please don't make a habit of using! /// </summary> public void Round(int digits) { int d = digits; A = new Complex(Math.Round(A.Real, d), Math.Round(A.Imaginary, d)); B = new Complex(Math.Round(B.Real, d), Math.Round(B.Imaginary, d)); C = new Complex(Math.Round(C.Real, d), Math.Round(C.Imaginary, d)); D = new Complex(Math.Round(D.Real, d), Math.Round(D.Imaginary, d)); }
public override int GetHashCode() { double inverse = 1 / Tolerance.Threshold; int decimals = (int)Math.Log10(inverse); return (Math.Round(Radius, decimals).GetHashCode() ^ Math.Round(Length, decimals).GetHashCode()); }
public int GetHashCode(double d) { if (Infinity.IsInfinite(d)) { return(double.PositiveInfinity.GetHashCode()); } double inverse = 1 / m_tolerance; int decimals = (int)Math.Log10(inverse); return(Math.Round(d, decimals).GetHashCode()); }
} //NormalizeArray static void convertToAmplitudePhase(double[,] result) { int longIndexBound = result.GetUpperBound(1); for (var index = 0; index < longIndexBound; ++index) { double re = result[0, index]; double im = result[1, index]; double absValue = Math.Round(Math.Sqrt(re * re + im * im) * 100); double phase = Math.Round(Math.Atan2(re, im) * 180 / Math.PI); result[0, index] = absValue; result[1, index] = phase; } //loop } //convertToAmplitudePhase
public static IList <Point> CreateCircleApproximation(this Point center, double r, int n) { var alpha = 360.0 / n; var grad = 0.0; var points = new List <Point>(); for (int i = 0; i < n; i++) { var z = (int)SysMath.Round(r * SysMath.Sin(grad.ToRadians())); var x = (int)SysMath.Round(r * SysMath.Cos(grad.ToRadians())); points.Add(new Point(x + center.X, center.Y, z + center.Z)); grad += alpha; } return(points); }
private void MoveCursor() { Plane activePlane = new Plane(Vector3.Up, 0); //first find the active voxel, then if (ActivePlane == CurrentActivePlane.XZ) { activePlane = new Plane(Vector3.Up, -CurrentYIndex); } if (ActivePlane == CurrentActivePlane.YZ) { activePlane = new Plane(Vector3.Right, -CurrentXIndex); } if (ActivePlane == CurrentActivePlane.XY) { activePlane = new Plane(Vector3.Forward, CurrentZIndex); } Vector3 collisionPoint = Vector3.Zero; if (SystemCore.Input.GetPlaneMouseRayCollision(activePlane, out collisionPoint)) { collisionPoint.X = (float)Math.Round(collisionPoint.X); collisionPoint.Y = (float)Math.Round(collisionPoint.Y); collisionPoint.Z = (float)Math.Round(collisionPoint.Z); currentbuildPoint = collisionPoint; if (currentbuildPoint.X < -modellingAreaSize / 2 || currentbuildPoint.X > modellingAreaSize / 2) { return; } if (currentbuildPoint.Y < -modellingAreaSize / 2 || currentbuildPoint.Y > modellingAreaSize / 2) { return; } if (currentbuildPoint.Z < -modellingAreaSize / 2 || currentbuildPoint.Z > modellingAreaSize / 2) { return; } mouseCursor.Transform.SetPosition(collisionPoint); } }
public override void Draw(Canvas canvas) { LinePaint.Alpha = (int)Math.Round(_alpha * 255); int width = Bounds.Width(); int height = Bounds.Height(); int stepWidth = width / GridSize; int stepHeight = height / GridSize; for (int i = 1; i < GridSize; i++) { int x = i * stepWidth; int y = i * stepHeight; canvas.DrawLine(Bounds.Left + x, Bounds.Top, Bounds.Left + x, Bounds.Bottom, LinePaint); canvas.DrawLine(Bounds.Left, Bounds.Top + y, Bounds.Right, Bounds.Top + y, LinePaint); } }
public int GetHashCode(CircleNE c) { if (c.IsLine) { return (c.P1.GetHashCode() ^ c.P2.GetHashCode()); } else { double inverse = 1 / Tolerance.Threshold; int decimals = (int)Math.Log10(inverse); return (c.Center.GetHashCode() ^ c.CenterNE.GetHashCode() ^ Math.Round(c.Radius, decimals).GetHashCode()); } }
private int GetNativeMetric(Metric metric, FontStyle style) { // we are going to actually have to create a font object here // will not create an actual variable for this yet. We may // want to do this in the future so that we do not have to keep // creating it over and over again. CTFontSymbolicTraits tMask = CTFontSymbolicTraits.None; if ((style & FontStyle.Bold) == FontStyle.Bold) { tMask |= CTFontSymbolicTraits.Bold; } if ((style & FontStyle.Italic) == FontStyle.Italic) { tMask |= CTFontSymbolicTraits.Italic; } var font = new CTFont(nativeFontDescriptor, 0); font = font.WithSymbolicTraits(0, tMask, tMask); switch (metric) { case Metric.EMHeight: return((int)font.UnitsPerEmMetric); case Metric.CellAscent: return((int)Math.Round(font.AscentMetric / font.Size * font.UnitsPerEmMetric)); case Metric.CellDescent: return((int)Math.Round(font.DescentMetric / font.Size * font.UnitsPerEmMetric)); case Metric.LineSpacing: nfloat lineHeight = 0; lineHeight += font.AscentMetric; lineHeight += font.DescentMetric; lineHeight += font.LeadingMetric; return((int)NMath.Round(lineHeight / font.Size * font.UnitsPerEmMetric)); } return(0); }
public void ApplyDecimalLimits() { XZCellSize = (float)Math.Round(XZCellSize, 2); YCellSize = (float)Math.Round(YCellSize, 2); DetailMaxDeviation = (float)Math.Round(DetailMaxDeviation, 2); DetailSampleDistance = (float)Math.Round(DetailSampleDistance, 2); EdgeMaxDeviation = (float)Math.Round(EdgeMaxDeviation, 2); MaxEdgeLength = (float)Math.Round(MaxEdgeLength, 2); MergeRegionArea = (float)Math.Round(MergeRegionArea, 2); MinRegionArea = (float)Math.Round(MinRegionArea, 2); WalkableHeight = (float)Math.Round(WalkableHeight, 2); WalkableRadius = (float)Math.Round(WalkableRadius, 2); WalkableSlope = (float)Math.Round(WalkableSlope, 2); WalkableStep = (float)Math.Round(WalkableStep, 2); }
/// <summary> /// Gets the memory cache size based on a percentage of the max available VM memory. /// </summary> /// <example>setting percent to 0.2 would set the memory cache to one fifth of the available memory</example> /// <param name="percent">Percent of available app memory to use to size memory cache</param> /// <returns></returns> private static int GetCacheSizeInPercent(float percent) { if (percent < 0.01f || percent > 0.8f) { throw new Exception("GetCacheSizeInPercent - percent must be between 0.01 and 0.8 (inclusive)"); } var context = Android.App.Application.Context.ApplicationContext; var am = (ActivityManager)context.GetSystemService(Context.ActivityService); bool largeHeap = (context.ApplicationInfo.Flags & ApplicationInfoFlags.LargeHeap) != 0; int memoryClass = am.MemoryClass; if (largeHeap && Utils.HasHoneycomb()) { memoryClass = am.LargeMemoryClass; } int availableMemory = 1024 * 1024 * memoryClass; return((int)Math.Round(percent * availableMemory)); }
public static float DeriveDetailSampleDistance( NMGenConfig config , UnityEngine.Vector3 boundsMin , UnityEngine.Vector3 boundsMax) { UnityEngine.Vector3 diff = boundsMax - boundsMin; float maxXZLength = Mathf.Max(diff.x, diff.z); int maxCells = Mathf.CeilToInt(maxXZLength / config.XZCellSize); if (config.TileSize == 0 || maxCells <= MaxCells) { return((float)Math.Round( Mathf.Max(0.9f, maxXZLength / mSampleResolution), 2)); } else { return((float)Math.Round(Mathf.Max(0.9f , config.TileSize * config.XZCellSize / mSampleResolution), 2)); } }
public void Execute(IRocketPlayer caller, params string[] command) { bool hasPerm = false; UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length == 0) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_help_1")); return; } if (command.Length > 0) { if (player.HasPermission("car") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } else { InteractableVehicle veh = player.Player.movement.getVehicle(); switch (command[0].ToLower()) { case "refuel": if (player.HasPermission("car.refuel") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } if (command.Length < 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_help_1")); return; } else { if (veh != null) { VehicleAsset vehi = veh.asset; ushort fuel = vehi.fuel; ushort maxfuel = vehi.fuel; double percent; double truefuel; if (command[1] == "full" || command[1] == "all" || command[1] == "100") { truefuel = (double)fuel - (double)veh.fuel; percent = double.Parse(fuel.ToString()) / (double)maxfuel * 100.00; percent = Math.Round(percent, 2); } else { if (ushort.TryParse(command[1], out fuel)) { if ((((double)veh.fuel / (double)maxfuel * 100.00) + (double)fuel) > 100.00) { truefuel = (double)maxfuel - (double)veh.fuel; } else { truefuel = (double)fuel / 100.00 * (double)maxfuel; } truefuel = Math.Round(truefuel, 0); percent = Math.Round(((double)truefuel / (double)maxfuel) * 100.00, 2); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_error2")); return; } } _ = decimal.Parse("1.3"); decimal.TryParse(LPXRemastered.Instance.Configuration.Instance.FuelPrice.ToString(), out decimal price); if (price != 0.00m) { decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal totalprice = Math.Round(price * (decimal)truefuel / (decimal)10, 2); if (balance < totalprice) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), (totalprice * -1)); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuel_paid", totalprice, Uconomy.Instance.Configuration.Instance.MoneyName, veh.instanceID.ToString(), percent.ToString())); if (bal >= 0.0m) { UnturnedChat.Say(player.CSteamID, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_refuelled_1", percent.ToString())); } veh.askFillFuel((ushort)truefuel); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } } break; case "lock": if (veh != null) { if (command.Length == 1) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()) == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), true); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Locked", veh.instanceID.ToString())); } else { string[] PlayersWithKey = LPXRemastered.Instance.DatabaseCar.GetGivenKeys(veh.instanceID.ToString()); for (int x = 0; x < PlayersWithKey.Length; x++) { if (PlayersWithKey[x].Trim() == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), true); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Locked", veh.instanceID.ToString())); break; } } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } break; case "unlock": if (veh != null) { if (command.Length == 1) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(veh.instanceID.ToString()) == player.Id) { LPXRemastered.Instance.DatabaseCar.AddLockedStatus(veh.instanceID.ToString(), false); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_Unlocked", veh.instanceID.ToString())); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } break; case "key": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_keyhelp")); return; } if (command.Length == 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_keyhelp2")); return; } if (command.Length > 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { UnturnedPlayer PlayerKey = UnturnedPlayer.FromName(command[2]); if (PlayerKey != null) { LPXRemastered.Instance.DatabaseCar.AddGivenKeys(command[1], PlayerKey.Id); UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_key_given", command[1], PlayerKey.CharacterName)); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_playernotfound")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "repair": if (player.HasPermission("car.repair") || player.HasPermission("car.*") || player.HasPermission("*")) { hasPerm = true; } if (!hasPerm && !(caller.IsAdmin)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_no_perm")); return; } if (command.Length == 1) { if (veh != null) { VehicleAsset vehi = veh.asset; int repair; double percent; repair = vehi.health - veh.health; if (repair > 0) { percent = Math.Round(((double)repair / (double)vehi.health) * 100.00, 2); if (LPXRemastered.Instance.Configuration.Instance.RepairPrice == 0) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repaired", veh.instanceID.ToString(), percent)); } else { _ = decimal.Parse("2"); decimal.TryParse(LPXRemastered.Instance.Configuration.Instance.RepairPrice.ToString(), out decimal price); decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal totalprice = Math.Round(price * (decimal)repair / (decimal)6, 2); if (balance < totalprice) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.CSteamID.ToString(), (totalprice * -1)); if (bal >= 0.0m) { UnturnedChat.Say(player.CSteamID, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repaired_price", veh.instanceID.ToString(), percent, totalprice, Uconomy.Instance.Configuration.Instance.MoneyName)); } veh.askRepair((ushort)repair); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_repair_notneeded", veh.instanceID.ToString())); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_error_1")); return; } } break; case "locate": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_locate_help")); return; } if (command.Length == 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { string Status = ""; if (ushort.TryParse(command[1], out ushort index)) { InteractableVehicle vehicle = VehicleManager.getVehicle(index); _ = vehicle.tryRemovePlayer(out _, player.CSteamID, out Vector3 point, out _); if (vehicle.isEmpty) { Status += "It is Empty. "; } if (vehicle.isDrowned) { Status += "It is Drowned. "; } if (vehicle.isDriven) { Status += "It is Being Drove. "; } UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_located", index, Math.Round(point.x, 0), Math.Round(point.y, 0), Math.Round(point.z, 0), Status)); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("lpx_invalid_input")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "rkey": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_help")); return; } if (command.Length == 2) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_help2")); return; } if (command.Length > 2) { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { UnturnedPlayer target; if (LPXRemastered.Instance.DatabaseCar.CheckOwner(command[1]) == player.Id) { target = UnturnedPlayer.FromName(command[2]); if (target == null) { if (LPXRemastered.Instance.DatabaseCar.RemoveGiveKeysCar(command[1], command[2])) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_success", command[2], command[1])); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_keynotfound", command[1])); return; } } else { if (LPXRemastered.Instance.DatabaseCar.RemoveGiveKeysCar(command[1], target.Id)) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_success", target.CharacterName, command[1])); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_rkey_keynotfound", command[1])); return; } } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_commmand_notowner")); return; } } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_found")); return; } } break; case "list": string cars = LPXRemastered.Instance.DatabaseCar.GetAllOwnedCars(player.Id); if (cars == "" || cars == " ") { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_zero_owned")); } else { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_list_all")); } break; case "steal": if (command.Length == 1) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_steal_help")); return; } else { if (LPXRemastered.Instance.DatabaseCar.CheckCarExistInDB(command[1])) { /** La voiture existe **/ decimal[] stealVehPrice = { 100, 100, /**/ 100, 250, 500, /**/ 1000, 1500, 2000, /**/ 2500, 3000, 4000, 10000, /**/ 50000 }; decimal[] lLicencePrice = { 500, 750, /**/ 1000, 1500, 3500, /**/ 1250, 1750, 3750, /**/ 1500, 2000, 4000, 10000, /**/ 90000 }; string strVehID = LPXRemastered.Instance.DatabaseCar.GetCarID(command[1]); int vehID = LPXRemastered.Instance.DatabaseCar.ConvertLicenceToInt(strVehID); if (vehID == -1) { break; } /** Prix vol vehicule **/ decimal vehprice = stealVehPrice[vehID]; if (player.HasPermission("Car_Steal_" + strVehID) || player.HasPermission("Car_Steal_*")) { vehprice = 100; /** Prix pour forcer le vehicule avec autorisation **/ } /** Prix licence **/ decimal licPrice = 0; if (!player.HasPermission("Licence_" + strVehID) && LPXRemastered.Instance.DatabaseCar.CheckLicence(player.Id, strVehID)) { licPrice = lLicencePrice[vehID]; } decimal balance = Uconomy.Instance.Database.GetBalance(player.Id); decimal price = vehprice + licPrice; if (balance < price) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("car_not_enough_currency", Uconomy.Instance.Configuration.Instance.MoneyName)); return; } /** Paiement du vol du vehicule **/ decimal bal = Uconomy.Instance.Database.IncreaseBalance(player.Id, (price * -1)); if (bal >= 0.0m) { UnturnedChat.Say(caller, LPXRemastered.Instance.Translate("new_balance_msg", new object[] { bal, Uconomy.Instance.Configuration.Instance.MoneyName })); } /** Unlocking du vehicule **/ string oldowner = LPXRemastered.Instance.DatabaseCar.GetOwnerName(command[1]); LPXRemastered.Instance.DatabaseCar.RemoveOwnership(command[1]); LPXRemastered.Instance.DatabaseCar.AddOwnership(command[1], player.Id, player.DisplayName); Logger.Log(player.CharacterName + " a vole la voiture numero " + command[1] + " de categorie " + vehID + " appartenant a " + oldowner); } } break; default: break; } } } }
public static double Round(this double num, int fractionalDigits) { return(M.Round(num, fractionalDigits)); }
public void GoldenRatio() { Assert.Equal(1.61803398875, NMath.Round(Numbers.GoldenRatio(), 11)); }
public static float DeriveYCellSize(NMGenConfig config) { return((float)Math.Round(Mathf.Max(0.05f, config.WalkableStep / 3), 2)); }
public static float DeriveXZCellSize(NMGenConfig config) { return((float)Math.Round(Mathf.Max(0.05f, config.WalkableRadius / 2), 2)); }
public static float DeriveDetailMaxDeviation(NMGenConfig config) { return((float)Math.Round(config.YCellSize * mDeviationFactor, 2)); }
public static void Postfix(NumberOption __instance) { __instance.Value = (float)Math.Round(__instance.Value, 2); }