void InitVault() { var vaultChestPosition = new List <IntPoint>(); var spawn = new IntPoint(0, 0); var w = Map.Width; var h = Map.Height; for (var y = 0; y < h; y++) { for (var x = 0; x < w; x++) { var tile = Map[x, y]; switch (tile.Region) { case TileRegion.Spawn: spawn = new IntPoint(x, y); break; case TileRegion.Vault: vaultChestPosition.Add(new IntPoint(x, y)); break; } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); for (var i = 0; i < _client.Account.VaultCount && vaultChestPosition.Count > 0; i++) { var vaultChest = new DbVaultSingle(_client.Account, i); var con = new Container(_client.Manager, 0x0504, null, false, vaultChest); con.BagOwners = new int[] { _client.Account.AccountId }; con.Inventory.SetItems(vaultChest.Items); con.Inventory.InventoryChanged += (sender, e) => SaveChest(((Inventory)sender).Parent); con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaults.AddFirst(con); } foreach (var i in vaultChestPosition) { var x = new ClosedVaultChest(_client.Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }
void InitVault() { var vaultChestPosition = new List <IntPoint>(); var giftChestPosition = new List <IntPoint>(); var spawn = new IntPoint(0, 0); var w = Map.Width; var h = Map.Height; for (var y = 0; y < h; y++) { for (var x = 0; x < w; x++) { var tile = Map[x, y]; switch (tile.Region) { case TileRegion.Spawn: spawn = new IntPoint(x, y); break; case TileRegion.Vault: vaultChestPosition.Add(new IntPoint(x, y)); break; case TileRegion.Gifting_Chest: giftChestPosition.Add(new IntPoint(x, y)); break; } } } vaultChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); giftChestPosition.Sort((x, y) => Comparer <int> .Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); for (var i = 0; i < _client.Account.VaultCount && vaultChestPosition.Count > 0; i++) { var vaultChest = new DbVaultSingle(_client.Account, i); var con = new Container(_client.Manager, 0x0504, null, false, vaultChest); con.BagOwners = new int[] { _client.Account.AccountId }; con.Inventory.SetItems(vaultChest.Items); con.Inventory.InventoryChanged += (sender, e) => SaveChest(((Inventory)sender).Parent); con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); EnterWorld(con); vaultChestPosition.RemoveAt(0); vaults.AddFirst(con); } foreach (var i in vaultChestPosition) { var x = new ClosedVaultChest(_client.Manager, 0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } var gifts = _client.Account.Gifts.ToList(); while (gifts.Count > 0 && giftChestPosition.Count > 0) { var c = Math.Min(8, gifts.Count); var items = gifts.GetRange(0, c); gifts.RemoveRange(0, c); if (c < 8) { items.AddRange(Enumerable.Repeat(ushort.MaxValue, 8 - c)); } var con = new GiftChest(_client.Manager, 0x0744, null, false); con.BagOwners = new int[] { _client.Account.AccountId }; con.Inventory.SetItems(items); con.Move(giftChestPosition[0].X + 0.5f, giftChestPosition[0].Y + 0.5f); EnterWorld(con); giftChestPosition.RemoveAt(0); } foreach (var i in giftChestPosition) { var x = new StaticObject(_client.Manager, 0x0743, null, true, false, false); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } // devon roach if (_client.Account.Name.Equals("Devon")) { var e = new Enemy(Manager, 0x12C); e.Move(38, 68); EnterWorld(e); } }