Ejemplo n.º 1
0
    private float CalculatePrefferedLogHeight(WeekActivityLog log)
    {
        float height = 100;

        if (log.ReturnRecord != null)
        {
            height += 190 + Mathf.Max(30, TextGenerator.GetPreferredHeight(log.ReturnRecord.Description, PartySettings));
        }

        if (log.HeroRecords.Count > 0)
        {
            height += log.HeroRecords.Sum(t => Mathf.Max(130, TextGenerator.GetPreferredHeight(t.Description, RecordSettings)) * 1.0056f);

            if (log.HeroRecords.Count > 1)
            {
                height += 20 * (log.HeroRecords.Count - 1);
            }
        }

        if (log.EmbarkRecord != null)
        {
            height += 160 + Mathf.Max(30, TextGenerator.GetPreferredHeight(log.EmbarkRecord.Description, PartySettings));
        }
        return(height);
    }
Ejemplo n.º 2
0
    public void UpdateWeekLog(WeekActivityLog weekLog)
    {
        gameObject.SetActive(true);

        WeekLog        = weekLog;
        weekTitle.text = string.Format(LocalizationManager.GetString("str_week"), WeekLog.WeekNumber);

        if (weekLog.ReturnRecord != null)
        {
            raidBanner.rectTransform.parent.gameObject.SetActive(true);
            if (weekLog.ReturnRecord.IsSuccessfull)
            {
                raidBanner.sprite = DarkestDungeonManager.Data.Sprites["raid_success_banner"];
            }
            else
            {
                raidBanner.sprite = DarkestDungeonManager.Data.Sprites["raid_failure_banner"];
            }

            ReturnSlot.UpdatePartyActivity(weekLog.ReturnRecord);
        }
        else
        {
            raidBanner.gameObject.SetActive(false);
            ReturnSlot.ResetPartyActivity();
        }

        int lastRecordIndex = Mathf.Min(SimpleSlots.Count, weekLog.HeroRecords.Count);

        for (int i = 0; i < lastRecordIndex; i++)
        {
            SimpleSlots[i].UpdateActivityRecord(weekLog.HeroRecords[i]);
        }

        for (int i = lastRecordIndex; i < weekLog.HeroRecords.Count; i++)
        {
            var heroSlot = Instantiate(Window.heroActivitySlot).GetComponent <ActivityRecordSlot>();
            heroSlot.rectTransform.SetParent(eventsTransform, false);
            heroSlot.rectTransform.SetAsLastSibling();
            heroSlot.UpdateActivityRecord(weekLog.HeroRecords[i]);
            SimpleSlots.Add(heroSlot);
        }
        for (int i = weekLog.HeroRecords.Count; i < SimpleSlots.Count; i++)
        {
            SimpleSlots[i].ResetActivityRecord();
        }

        if (weekLog.EmbarkRecord != null)
        {
            EmbarkSlot.UpdatePartyActivity(weekLog.EmbarkRecord);
        }
        else
        {
            EmbarkSlot.ResetPartyActivity();
        }
    }