public static void Execute() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Console.WriteLine("Day 2: INT Code"); var baseInput = Utilz.ParseIntCsv("Day2/input.csv"); int targetOutput = 19690720; for (int n = 0; n < 100; n++) { for (int v = 0; v < 100; v++) { var curInput = new int[baseInput.Length]; Array.Copy(baseInput, curInput, baseInput.Length); if (ExecuteCode(curInput, n, v) == targetOutput) { Console.WriteLine(100 * n + v); stopwatch.Stop(); Console.WriteLine($"{stopwatch.ElapsedMilliseconds}ms Elapsed"); return; } } } }
public Armor(StatsSet set) : base(set) { Type = Utilz.GetEnumFromString(set.GetString("armor_type", "none"), ArmorTypeId.None); AvoidModifier = set.GetInt("avoid_modify"); Pdef = set.GetInt("p_def"); Mdef = set.GetInt("m_def"); MpBonus = set.GetInt("mp_bonus"); HpBonus = set.GetInt("hp_bonus"); int bodyPart = BodyPart; if ((bodyPart == SlotNeck) || (bodyPart == SlotFace) || (bodyPart == SlotHair) || (bodyPart == SlotHairall) || ((bodyPart & SlotREar) != 0) || ((bodyPart & SlotLFinger) != 0) || ((bodyPart & SlotBack) != 0)) { Type1 = Type1WeaponRingEarringNecklace; Type2 = Type2Accessory; } else { if ((Type == ArmorType.None.Id) && (BodyPart == SlotLHand)) // retail define shield as NONE { Type = ArmorType.Shield.Id; } Type1 = Type1ShieldArmor; Type2 = Type2ShieldArmor; } }
public oMap(string filepath) { List <string> alll = System.IO.File.ReadAllLines(filepath).ToList(); SaveReader sr = new SaveReader(alll); //first line is save file format version string strVersion = sr.ReadLine(); while (true) { //first step is read the next object to add to the map. //second step is read the properties of that object. we knows in which order properties are written string newitem = sr.ReadLine(); if (newitem == "exit") { break; } if (newitem == "belt") { string strBeltOutput = sr.ReadLine(); MapObject mo = new MapObject(MOType.Belt, Utilz.GetFOTypeAssociatedToString(strBeltOutput)); mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); } if (newitem == "machine") { string strRecipe = sr.ReadLine(); MapObject mo = new MapObject(MOType.Machine, Utilz.GetFOTypeAssociatedToString(strRecipe)); mo.NeedCoal = sr.ReadLine() == "true"; mo.vpos.X = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); mo.vpos.Y = Convert.ToSingle(sr.ReadLine().Replace(".", ",")); this.listMO.Add(mo); } } }
public ActionResult <string> Apagar([FromBody] dynamic pp) { Registro filtro = new Registro(pp); Tabela tabela = new Tabela(filtro); string status; tabela = Utilz.Logar(tabela); if (tabela.Status != "OK") { return(tabela.GetJSON()); } var db = new Banco(); var p = db.Apagar(filtro, out status); if (p == false) { tabela.Status = status; } else { tabela.Status = "OK"; } return(tabela.GetJSON()); }
private void CreateNewButtonBoth(FOType ft) { Bitmap img = Utilz.GetAssociatedIcon(ft); this.CreateNewButtonBelt(img, ft); this.CreateNewButtonMachine(img, ft); }
private void RefreshSize() { this.TextBelt.Top = 15; // 15 this.TextBelt.Left = 5; // 5 this.TextBelt.AutoSize = true; this.TextAssembler.Top = 55; // 55 this.TextAssembler.Left = 5; // 5 this.TextAssembler.AutoSize = true; int StartLeft = 70; // 70 Size buttonsize = new Size(40, 40); // 40 40 int actualleft = StartLeft; foreach (Button b in this.listButtonBelt) { MOType mt = (MOType)(((object[])(b.Tag))[0]); FOType ft = (FOType)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool isbelt = Utilz.IsBeltable(ft); if (!isbelt) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } actualleft = StartLeft; foreach (Button b in this.listButtonMachine) { MOType mt = (MOType)(((object[])(b.Tag))[0]); FOType ft = (FOType)(((object[])(b.Tag))[1]); b.Left = actualleft; b.Top = 1 + buttonsize.Height + 2; b.Size = buttonsize; //back color //// couleur d'arrière plan b.BackColor = Color.Gainsboro; bool ismachine = Utilz.IsRecipe(ft); if (!ismachine) { b.BackColor = Color.Crimson; } //next iteration actualleft += b.Width + 1; } }
private void PerformMove(bool forceUpdate = false) { //await ValidateWaterZones(); if (!IsMoving) { return; } if (!CanMove()) { NotifyStopMove(); return; } long currentTime = DateTime.UtcNow.Ticks; float elapsedSeconds = (currentTime - _movementLastTime) / (float)TimeSpan.TicksPerSecond; // TODO: move to config if (!forceUpdate && elapsedSeconds < 0.05f) // 50 ms, skip run if last run was less then 50ms ago { return; } if (_attackTarget != null) // if we have target then update destination coordinates { DestinationX = _attackTarget.X; DestinationY = _attackTarget.Y; DestinationZ = _attackTarget.Z; } float distance = (float)Utilz.Length(DestinationX - _x, DestinationY - _y); // vector to destination with length = 1 float vectorX = (DestinationX - _x) / distance; float vectorY = (DestinationY - _y) / distance; int dx = (int)(vectorX * _character.CharacterStat.MoveSpeed * elapsedSeconds); int dy = (int)(vectorY * _character.CharacterStat.MoveSpeed * elapsedSeconds); double ddistance = Utilz.Length(dx, dy); Heading = (int)(Math.Atan2(-vectorX, -vectorY) * 10430.378 + short.MaxValue); if (ddistance >= distance || distance < 1) { _x = DestinationX; _y = DestinationY; NotifyArrived(); return; } _movementLastTime = currentTime; _x += (int)(vectorX * _character.CharacterStat.MoveSpeed * elapsedSeconds); _y += (int)(vectorY * _character.CharacterStat.MoveSpeed * elapsedSeconds); }
public void Initialize() { Type[] typelist = Utilz.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "L2dotNET.Commands.Admin"); foreach (Type t in typelist) { Register(Activator.CreateInstance(t)); } Log.Info($"AdminAccess: loaded {_commands.Count} commands."); }
public static void Execute() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Console.WriteLine("Day 1: Fuel Caluclation"); Console.WriteLine(GetFuelRequirement(Utilz.ParseIntArray("Day1/input.txt"))); stopwatch.Stop(); Console.WriteLine($"{stopwatch.ElapsedMilliseconds}ms Elapsed"); }
public bool NeedCoal = true; //if this is a furnace, indicate if this need coal //// si this est une furnace, indique si this a besoin de coal public Bitmap GetImage() { if (this.MapType == MOType.Belt) { return(Utilz.GetAssociatedIcon(this.BeltOutput)); } if (this.MapType == MOType.Machine) { return(Utilz.GetAssociatedIcon(this.TheRecipe)); } return(FactorioOrganizer.Properties.Resources.fish); }
private void AnyButton_MosueDown(object sender, MouseEventArgs e) { Button btn = (Button)sender; btn.Focus(); MOType mt = (MOType)(((object[])(btn.Tag))[0]); FOType ft = (FOType)(((object[])(btn.Tag))[1]); if (e.Button == MouseButtons.Left) { if (mt == MOType.Belt) { if (Utilz.IsBeltable(ft)) //we set addmode only if the item can be a belt { MapObject newmo = new MapObject(mt, ft); this.Editer.StartAddMode(newmo); } } if (mt == MOType.Machine) //we set addmode only if the item can be a machine { if (Utilz.IsRecipe(ft)) { MapObject newmo = new MapObject(mt, ft); this.Editer.StartAddMode(newmo); } } } if (e.Button == MouseButtons.Right) { FOType[] arrayOutputs = Utilz.GetRecipeOutputs(ft); FOType[] arrayInputs = Utilz.GetRecipeInputs(ft); oRightClick3 rc = new oRightClick3(); //rc.Width = 200; rc.AddChoice(ft.ToString()); rc.AddSeparator(); rc.AddSeparator(); //add every outputs and inputs for the user rc.AddChoice("Outputs :"); foreach (FOType subft in arrayOutputs) { rc.AddChoice("-" + subft.ToString()); } rc.AddChoice(""); rc.AddChoice("Inputs :"); foreach (FOType subft in arrayInputs) { rc.AddChoice("-" + subft.ToString()); } rc.ShowDialog(); } }
//public MapObject(MOType StartMapType, FOType[] StartOutputs) //{ // this.MapType = StartMapType; // this.SetOutput(StartOutputs); // if (this.MapType == MOType.Machine) // { // this.SetRecipe(StartOutputs[0]); // } //} //define inputs and outputs according to the recipe //// défini les input et output qui vont avec la recette spécifié public void SetRecipe(FOType Recipe) { if (this.MapType == MOType.Belt) { this.SetOutput(Recipe); } if (this.MapType == MOType.Machine) { this.TheRecipe = Recipe; this.Outputs = Utilz.GetRecipeOutputs(Recipe); this.Inputs = Utilz.GetRecipeInputs(Recipe); this.IsFurnace = Utilz.IsRecipeMadeInFurnace(Recipe); } }
//define inputs and outputs according to the recipe //// défini les input et output qui vont avec la recette spécifié public void SetRecipe(FOType Recipe) { if (this.MapType == MOType.Belt) //SetRecipe is usually not called for belts { this.BeltOutput = Recipe; } if (this.MapType == MOType.Machine) { //set the recipe and set everything this.TheRecipe = Recipe; this.Outputs = Utilz.GetRecipeOutputs(Recipe); this.Inputs = Utilz.GetRecipeInputs(Recipe); this.IsFurnace = Utilz.IsRecipeMadeInFurnace(Recipe); } }
public ActionResult <string> Consultar([FromBody] dynamic pp) { Registro filtro = new Registro(pp); Tabela tabela = new Tabela(filtro); tabela = Utilz.Logar(tabela); if (tabela.Status != "OK") { return(tabela.GetJSON()); } var db = new Banco(); tabela = db.Consulta(filtro, tabela); return(tabela.GetJSON()); }
public void Initialise() { if (Initialised) { return; } IEnumerable <Type> typelist = Utilz.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "L2dotNET.Commands.Admin"); foreach (Type t in typelist) { Register(Activator.CreateInstance(t, _serviceProvider)); } Log.Info($"Loaded {_commands.Count} commands."); Initialised = true; }
public static void Execute() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Console.WriteLine("Day 7: Amplification Circuit "); var cpu = new IntCodeV2(); var code = Utilz.ParseIntCsv("Day7/input.csv"); var ex1 = new int[] { 3, 26, 1001, 26, -4, 26, 3, 27, 1002, 27, 2, 27, 1, 27, 26, 27, 4, 27, 1001, 28, -1, 28, 1005, 28, 6, 99, 0, 0, 5 }; var ex2 = new int[] { 3, 52, 1001, 52, -5, 52, 3, 53, 1, 52, 56, 54, 1007, 54, 5, 55, 1005, 55, 26, 1001, 54, -5, 54, 1105, 1, 12, 1, 53, 54, 53, 1008, 54, 0, 55, 1001, 55, 1, 55, 2, 53, 55, 53, 4, 53, 1001, 56, -1, 56, 1005, 56, 6, 99, 0, 0, 0, 0, 10 }; int output = int.MinValue; int min = 5; int max = 10; for (int i = min; i < max; i++) { for (int j = min; j < max; j++) { for (int k = min; k < max; k++) { for (int l = min; l < max; l++) { for (int m = min; m < max; m++) { var result = RunFeedback(code, new int[] { i, j, k, l, m }); if (output < result) { Console.WriteLine($"{i},{j},{k},{l},{m}"); output = result; } } } } } } Console.WriteLine($"Puzzle {output}"); stopwatch.Stop(); Console.WriteLine($"{stopwatch.ElapsedMilliseconds}ms Elapsed"); }
public Weapon(StatsSet set) : base(set) { Type = Utilz.GetEnumFromString(set.GetString("weaponType", "none"), WeaponTypeId.None); SoulshotCount = set.GetInt("soulshots"); SpiritshotCount = set.GetInt("spiritshots"); PDam = set.GetInt("p_dam"); RndDam = set.GetInt("rnd_dam"); Critical = set.GetInt("critical"); HitModifier = set.GetDouble("hit_modify"); AvoidModifier = set.GetInt("avoid_modify"); ShieldDef = set.GetInt("shield_def"); ShieldDefRate = set.GetDouble("shield_def_rate"); AtkSpeed = set.GetInt("atk_speed"); AtkReuse = set.GetInt("atk_reuse", Type == WeaponTypeId.Bow ? 1500 : 0); MpConsume = set.GetInt("mp_consume"); MDam = set.GetInt("m_dam"); }
public override async Task RunImpl() { await Task.Run(() => { L2Player player = _client.CurrentPlayer; L2Object obj = null; if (_objectId == player.ObjId) { obj = player; } else { if (L2World.Instance.GetObject(_objectId) != null) { obj = L2World.Instance.GetObject(_objectId); } } //fixed nullreference exception when obj is null Log.Debug($"Action Requested with { Utilz.GetTypeLower(obj).ToString() } of ID : { _objectId.ToString()}"); if (obj == null) { Log.Debug("Action Requested Failed"); player.SendActionFailedAsync(); return; } switch (_actionId) { case 0: obj.OnActionAsync(player); break; case 1: obj.OnActionShiftAsync(player); break; default: player.SendActionFailedAsync(); break; } }); }
protected internal override void write() { writeC(0xfe); writeH(0xac); writeD(Utilz.CurrentSeconds()); writeD(list.Count); foreach (MailMessage mm in list) { writeD(mm.MailID); writeS(mm.Title); writeS(mm.ReceiverName); writeD(mm.Trade); writeD(mm.getExpirationSeconds()); writeD(mm.NotOpend); writeD(0x01); writeD(mm.WithItem); } }
protected internal override void write() { writeC(0xfe); writeH(0xaa); writeD(Utilz.CurrentSeconds()); writeD(list.Count); foreach (MailMessage Mail in list) { writeD(Mail.MailID); writeS(Mail.Title); writeS(Mail.SenderName); writeD(Mail.Trade); writeD(Mail.getExpirationSeconds()); writeD(Mail.NotOpend); writeD(Mail.ReturnAble); writeD(Mail.WithItem); writeD(Mail.SentBySystem); writeD(Mail._news); //?? writeD(0); } }
private void LoadEtcItemModels() { Dictionary <int, EtcItemModel> etcItemModels = ItemService.GetAllEtcItemModelsDict(); foreach (KeyValuePair <int, EtcItemModel> modelPair in etcItemModels) { StatsSet set = new StatsSet(); EtcItemModel model = modelPair.Value; EtcItem etcItem = new EtcItem(set) { Type = Utilz.GetEnumFromString(model.ItemType, EtcItemTypeId.None), ItemId = model.ItemId, Name = model.Name, Sellable = model.Sellable, Dropable = model.Dropable, Destroyable = model.Destroyable, Tradable = model.Tradeable, Weight = model.Weight, Duration = model.Duration }; EtcItems.Add(modelPair.Key, etcItem); } }
public void UpdatePosition(int x, int y, int z) { if (!IsMoving || !CanMove()) { return; } bool slowDown = Utilz.DistanceSq(x, y, DestinationX, DestinationY) > Utilz.DistanceSq(_x, _y, DestinationX, DestinationY); int dx = x - _x; int dy = y - _y; double distance = Utilz.Length(dx, dy); long currentTime = DateTime.UtcNow.Ticks; // TODO: move to config const int maxSpeedUpPerSecondUnsync = 20; int distanceAllowedUnsync = (int)((slowDown ? _character.CharacterStat.MoveSpeed : maxSpeedUpPerSecondUnsync) * (currentTime - _movementUpdateTime) / TimeSpan.TicksPerSecond); if (distance <= distanceAllowedUnsync) { _x = x; _y = y; } else { _x += (int)(dx / distance * distanceAllowedUnsync); _y += (int)(dy / distance * distanceAllowedUnsync); } Z = z; _movementUpdateTime = currentTime; }
private void LoadWeaponModels() { Dictionary <int, WeaponModel> weaponModels = ItemService.GetAllWeaponModelsDict(); foreach (KeyValuePair <int, WeaponModel> modelPair in weaponModels) { StatsSet set = new StatsSet(); WeaponModel model = modelPair.Value; Weapon weapon = new Weapon(set) { Type = Utilz.GetEnumFromString(model.WeaponType, WeaponTypeId.None), ItemId = model.ItemId, Name = model.Name, BodyPart = Slots[model.BodyPart], Sellable = model.Sellable, Dropable = model.Dropable, Destroyable = model.Destroyable, Tradable = model.Tradeable, Weight = model.Weight, Duration = model.Duration, ReferencePrice = model.Price, SpiritshotCount = model.Spiritshots, SoulshotCount = model.Soulshots, PDam = model.Pdam, RndDam = model.RndDam, Critical = model.Critical, HitModifier = model.HitModify, AvoidModifier = model.AvoidModify, ShieldDef = model.ShieldDef, ShieldDefRate = model.ShieldDefRate, AtkSpeed = model.AtkSpeed, MpConsume = model.MpConsume, MDam = model.Mdam }; Weapons.Add(modelPair.Key, weapon); } }
private void LoadArmorModels() { Dictionary <int, ArmorModel> armorsModels = ItemService.GetAllArmorModelsDict(); foreach (KeyValuePair <int, ArmorModel> modelPair in armorsModels) { StatsSet set = new StatsSet(); ArmorModel model = modelPair.Value; Armor armor = new Armor(set) { Type = Utilz.GetEnumFromString(model.ArmorType, ArmorTypeId.None), ItemId = model.ItemId, Name = model.Name, BodyPart = Slots[model.BodyPart], Sellable = model.Sellable, Dropable = model.Dropable, Destroyable = model.Destroyable, Tradable = model.Tradeable, Weight = model.Weight, Duration = model.Duration }; Armors.Add(modelPair.Key, armor); } }
private void ImageBox_MouseUp(object sender, MouseEventArgs e) { PointF mvpos = this.MouseVirtualPos; //this.ConvertUiToVirtual(this.MousePos.X, this.MousePos.Y); if (e.Button == MouseButtons.Left) { if (this.IsDragAndDrop) { this.StopDragAndDrop(); } if (this.IsDragAndDropMO) { this.StopDragAndDropMO(); } if (this.IsAddMode) { this.StopAddMode(); } } if (e.Button == MouseButtons.Right) { if (!this.IsAddMode && !this.IsDragAndDrop && !this.IsDragAndDropMO) { MapObject mo = this.Map.GetObjThatTouch(mvpos.X, mvpos.Y); if (mo != null) { string optToggleNeedCoal = "Toggle Need Coal"; string optRemove = "Remove"; oRightClick3 rc = new oRightClick3(); //rc.Width = 300; rc.AddChoice(optToggleNeedCoal); rc.AddSeparator(); rc.AddChoice(optRemove); //ajoute les inputs et output if (mo.MapType == MOType.Machine) { rc.AddSeparator(); rc.AddSeparator(); rc.AddChoice("Outputs :"); foreach (FOType ft in mo.Outputs) { rc.AddChoice("-" + ft.ToString()); } rc.AddChoice(""); rc.AddChoice("Inputs :"); foreach (FOType ft in mo.Inputs) { rc.AddChoice("-" + ft.ToString()); } } string rep = rc.GetChoice(); if (rep == optToggleNeedCoal) { mo.NeedCoal = !mo.NeedCoal; } if (rep == optRemove) { try { this.Map.listMO.Remove(mo); } catch { } } //check the one who correspond to the click FOType, if there is one //// check si ca correspond à un FOType if (mo.MapType == MOType.Machine) { List <FOType> allft = Utilz.GetListOfAllFOType(); foreach (FOType ft in allft) { if (ft.ToString() == rep.Replace("-", string.Empty).Trim()) { MapObject newmo = new MapObject(MOType.Belt, ft); this.StartAddMode(newmo); break; } } } this.RefreshImage(); } } } }
static public void CMDCheck() { // Get the values of the command line in an array // Index Discription // 0 Full path of executing prograsm with program name // 1 First switch in command in your example string[] clArgs = Environment.GetCommandLineArgs(); if (clArgs.Count() < 4 || clArgs.Count() > 5) { Console.WriteLine("Usage: eldorado_dat -d path/to/file.dat path/to/outputfolder"); Console.WriteLine("Optional: --debug"); Console.WriteLine("Example: eldorado_dat -d O:/RamBox/video.dat O:/RamBox/_extracted"); } else { Console.WriteLine("Starting..."); //set working path Me_WorkingPath = AppDomain.CurrentDomain.BaseDirectory; //check input -p followed by it's path int ac = 0; foreach (var arg in clArgs) { if (arg == "-d") { In_FilePath = clArgs[ac + 1]; Out_FolderPath = clArgs[ac + 2]; break; } if (arg == "--debug") { flag_debug = true; } ac += 1; } if (In_FilePath == "" || Out_FolderPath == "") { Console.WriteLine("Error check input arguments!"); return; } //filechecks I/O if (!(File.Exists(In_FilePath))) { //maybe its in the working folder if (File.Exists(Path.Combine(Me_WorkingPath, In_FilePath))) { In_FilePath = Path.Combine(Me_WorkingPath, In_FilePath); } else { In_FilePath = string.Empty; Console.WriteLine("Error Input file doesn't seem to exist!"); return; } } else { //working folder In_FilePath = Path.Combine(Me_WorkingPath, In_FilePath); } try { Utilz.CreatePath(Out_FolderPath); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); return; } if (System.IO.Path.IsPathRooted(Out_FolderPath) != true) { Out_FolderPath = Path.Combine(Me_WorkingPath, Out_FolderPath); } Console.WriteLine("----------------------------------------------------------------------------"); Console.WriteLine("InputFile: " + Path.GetFileName(In_FilePath)); Console.WriteLine("InputFilePath: " + In_FilePath); Console.WriteLine("ExportPath: " + Out_FolderPath); //Pass to class object to export VText(""); myDAT = new DAT(In_FilePath, Out_FolderPath, flag_debug); //Call export and finish bool result = myDAT.ParseExport(); if (result != true) { PError("An error has occurred somewhere during the export processs."); } else { Console.WriteLine("Export completed()"); } } }
public EtcItem(StatsSet set) : base(set) { Type = Utilz.GetEnumFromString(set.GetString("item_type", "None"), EtcItemTypeId.None); }