Ejemplo n.º 1
0
        private static IDungeonInfo BuildDungeonInfo(HearthstoneImage image, DungeonKey key, dynamic savesMap)
        {
            var index = DungeonInfoReader.GetKeyIndex(savesMap, (int)key);

            if (index == -1)
            {
                return(null);
            }

            var dungeonMap  = savesMap["valueSlots"][index];
            var dungeonInfo = new DungeonInfo
            {
                Key               = key,
                DeckCards         = DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.DeckList),
                LootOptionBundles = new List <List <int> >
                {
                    DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption1),
                    DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption2),
                    DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption3),
                },
                ChosenLoot       = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.ChosenLoot),
                TreasureOption   = DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.TreasureOption),
                ChosenTreasure   = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.ChosenTreasure),
                RunActive        = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.RunActive),
                SelectedDeck     = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.SelectedDeck),
                StartingTreasure = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.StartingTreasure),
            };

            dungeonInfo.DeckList = DungeonInfoReader.BuildRealDeckList(image, dungeonInfo);

            return(dungeonInfo);
        }
        public SpawnPattern(DungeonRoom pParent, DungeonKey keyDrop, params Tuple <int, int>[] spawnInfo)
        {
            _parent = pParent;

            for (var i = 0; i < spawnInfo.Length; i++)
            {
                this.AddSpawn(spawnInfo[i].Item1, spawnInfo[i].Item2, ((i + 1 == spawnInfo.Length) ? keyDrop : DungeonKey.None));
            }
        }
        public void AddSpawns(DungeonKey pKey, Tuple <int, int> firstGroup, params Tuple <int, int>[] spawnGroups)
        {
            var sg = new SpawnGroup(this, firstGroup.Item1, firstGroup.Item2, pKey);

            for (var i = 0; i < spawnGroups.Length; i++)
            {
                sg.AddSpawn(spawnGroups[i].Item1, spawnGroups[i].Item2);
            }

            _groups.Add(sg);
        }
Ejemplo n.º 4
0
    protected void CheckForDungeonKeyDrop()
    {
        var dungeonKeyRarityChances = DungeonKey.CreateRarityChancesList(Health);

        var position = CollectionsHelper.RandomizeFrequenciesListPosition(dungeonKeyRarityChances);

        // Grant dungeon key after if algorithm didn't roll empty loot.
        if (position != 0)
        {
            var dungeonKey = User.Instance.DungeonKeys.FirstOrDefault(x => x.Rarity == (Rarity)(position - 1));
            dungeonKey.AddItem();
        }
    }
Ejemplo n.º 5
0
    public override DungeonKey CopyItem(int quantity)
    {
        var copy = new DungeonKey
        {
            Id          = Id,
            Name        = Name,
            Rarity      = Rarity,
            Value       = Value,
            Description = Description,
            Quantity    = quantity
        };

        return(copy);
    }
    private void AddNewObjectButton_Click(object sender, RoutedEventArgs e)
    {
        Save();

        var nextId = (GameAssets.DungeonKeys.Max(x => x.Id as int?) ?? 0) + 1;

        _dataContext = new DungeonKey
        {
            Id = nextId
        };
        ContentSelectionBox.SelectedIndex = -1;
        RefreshStaticValuesPanel();

        DeleteObjectButton.Visibility = Visibility.Visible;
    }
    private void ContentSelectionBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var selectedName = (e.Source as ComboBox)?.SelectedValue?.ToString();

        if (selectedName is null)
        {
            return;
        }

        if (_dataContext is not null)
        {
            Save();
        }

        _dataContext = GameAssets.DungeonKeys.FirstOrDefault(x => x.Name == selectedName);
        RefreshStaticValuesPanel();
        DeleteObjectButton.Visibility = Visibility.Visible;
    }
        public List <Creature> SpawnCreature(int pClass, int pAmount, DungeonKey pDropKey = DungeonKey.None)
        {
            var             rnd        = RandomProvider.Get();
            List <Creature> spawns     = new List <Creature>();
            var             keyDropped = false;

            for (var i = 0; i < pAmount; i++)
            {
                int x        = (int)rnd.Next(this.Center.X - 900, this.Center.X + 900);
                int y        = (int)rnd.Next(this.Center.Y - 900, this.Center.Y + 900);
                var creature = ChannelServer.Instance.ScriptManager.Spawn(pClass, this.Floor.Region.Id, x, y, -1, true, true);
                if (pDropKey != DungeonKey.None && !keyDropped)
                {
                    creature.Drops.Add((int)pDropKey, 100f);
                    keyDropped = true;
                }
                var cPos = creature.GetPosition();
                Send.SpawnEffect(SpawnEffect.Monster, this.Floor.Region.Id, cPos.X, cPos.Y, creature);
                spawns.Add(creature);
            }

            return(spawns);
        }
    private void DeleteObjectButton_Click(object sender, RoutedEventArgs e)
    {
        Save();

        var objectToDelete = GameAssets.DungeonKeys.FirstOrDefault(x => x.Id == int.Parse((_controls["IdBox"] as TextBox).Text));

        var result = MessageBox.Show($"Are you sure you want to delete {objectToDelete.Name}? This action will close ContentManager, check Logs directory (for missing references after deleting).", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question);

        if (result == MessageBoxResult.No)
        {
            return;
        }

        GameAssets.DungeonKeys.Remove(objectToDelete);

        PopulateContentSelectionBox();
        ContentSelectionBox.SelectedIndex = -1;
        _currentPanel.Children.Clear();
        DeleteObjectButton.Visibility = Visibility.Hidden;
        _dataContext = null;

        Application.Current.MainWindow.Close();
    }
        public static IDungeonInfo BuildDungeonInfo(HearthstoneImage image, DungeonKey key, dynamic savesMap)
        {
            var index = DungeonInfoReader.GetKeyIndex(savesMap, (int)key);

            if (index == -1)
            {
                return(null);
            }

            var dungeonMap  = savesMap["valueSlots"][index];
            var deckDbfId   = DungeonInfoReader.ExtractDeckDbfId(image, dungeonMap, key);
            var dungeonInfo = new DungeonInfo
            {
                Key               = key,
                DeckCards         = DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.DeckList),
                LootOptionBundles = new List <DungeonOptionBundle>
                {
                    BuildOptionBundle(DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption1)),
                    BuildOptionBundle(DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption2)),
                    BuildOptionBundle(DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.LootOption3)),
                },
                ChosenLoot        = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.ChosenLoot),
                TreasureOption    = DungeonInfoReader.ExtractValues(dungeonMap, (int)DungeonFieldKey.TreasureOption),
                ChosenTreasure    = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.ChosenTreasure),
                RunActive         = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.RunActive),
                SelectedDeck      = deckDbfId,
                StartingTreasure  = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.StartingTreasure),
                StartingHeroPower = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.StartingHeroPower),
                PlayerClass       = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.PlayerClass),
                ScenarioId        = DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.ScenarioId),
            };

            dungeonInfo.DeckList = DungeonInfoReader.BuildRealDeckList(image, dungeonInfo);

            return(dungeonInfo);
        }
 public bool TryGetValue(DungeonKey key, out IDungeonInfo value) =>
 this.internalDictionary.TryGetValue(key, out value);
 public bool ContainsKey(DungeonKey key) => this.internalDictionary.ContainsKey(key);
 public IDungeonInfo this[DungeonKey key] => this.internalDictionary[key];
 public void AddSpawn(int pSpawnClass, int pAmount, DungeonKey pKey = DungeonKey.None)
 {
     _groups.Add(new SpawnGroup(this, pSpawnClass, pAmount, pKey));
 }
 public void AddSpawnGroup(DungeonRoom pRoom, DungeonKey pKeyDrop, Tuple <int, int> pFirstGroup, params Tuple <int, int>[] pSpawns)
 {
     pRoom.Spawns.AddSpawns(pKeyDrop, pFirstGroup, pSpawns);
 }
 public SpawnGroup(SpawnPattern pParent, int pSpawnClass, int pAmount, DungeonKey pKey = DungeonKey.None)
 {
     this.Parent = pParent;
     this.Spawns.Add(Tuple.Create(pSpawnClass, pAmount));
     this._key = pKey;
 }
        private static int ExtractDeckDbfId(HearthstoneImage image, dynamic dungeonMap, DungeonKey key)
        {
            switch (key)
            {
            case DungeonKey.BookOfHeroes:
                return(DungeonInfoReader.ExtractDeckDbfIdForBoH(image, dungeonMap));

            default:
                return(DungeonInfoReader.ExtractValue(dungeonMap, (int)DungeonFieldKey.SelectedDeck));
            }
        }