Exemple #1
0
    public void DestroySlot(Hero hero)
    {
        var targetSlot = HeroSlots.Find(slot => slot.Hero == hero);

        if (targetSlot != null)
        {
            HeroSlots.Remove(targetSlot);
            Destroy(targetSlot.gameObject);
        }
        UpdateCapacity();
    }
Exemple #2
0
    HeroSlot CreateSlot(Hero hero)
    {
        GameObject gameObject = Instantiate(heroSlotTemplate);

        gameObject.transform.SetParent(rosterSlots, false);
        HeroSlot heroSlot = gameObject.GetComponent <HeroSlot>();

        heroSlot.HeroRoster = this;
        heroSlot.Hero       = hero;
        heroSlot.UpdateSlot();
        HeroSlots.Add(heroSlot);
        return(heroSlot);
    }
Exemple #3
0
    public void SortByLevel()
    {
        DarkestSoundManager.PlayOneShot("event:/ui/town/sort_by");

        System.Comparison <Hero> sorting = (x, y) =>
        {
            int result = -x.Resolve.Level.CompareTo(y.Resolve.Level);
            return(result == 0 ? x.Name.CompareTo(y.Name) : result);
        };

        DarkestDungeonManager.Campaign.Heroes.Sort(sorting);
        HeroSlots.Sort((x, y) => sorting(x.Hero, y.Hero));

        for (int i = 0; i < HeroSlots.Count; i++)
        {
            HeroSlots[i].RectTransform.SetSiblingIndex(i);
        }
    }
Exemple #4
0
    public void SortByStress()
    {
        DarkestSoundManager.PlayOneShot("event:/ui/town/sort_by");

        Comparison <Hero> sorting = (x, y) =>
        {
            int result = x.Stress.CurrentValue.CompareTo(y.Stress.CurrentValue);
            return(result == 0 ? string.Compare(x.Name, y.Name, StringComparison.Ordinal) : result);
        };

        DarkestDungeonManager.Campaign.Heroes.Sort(sorting);
        HeroSlots.Sort((x, y) => sorting(x.Hero, y.Hero));

        for (int i = 0; i < HeroSlots.Count; i++)
        {
            HeroSlots[i].RectTransform.SetSiblingIndex(i);
        }
    }