예제 #1
0
    public void Refresh()
    {
        if (Task.Task == null)
        {
            return;
        }

        var ct = ConfigManager.Get <ConfigText>((int)TextForMatType.PetTrainText);

        Util.SetText(title, Task.Task.name);
        if (Task.LimitCount == 0)
        {
            Util.SetText(count, ConfigText.GetDefalutString(TextForMatType.PetTrainText, 24));
        }
        else
        {
            Util.SetText(count, Util.Format(ct[8], $"{Task.LimitCount - Task.Count}/{Task.LimitCount}"));
        }
        count.color = ColorGroup.GetColor(ColorManagerType.TimesUseUp, Task.TimesUseUp);
        Util.SetText(levelLimit, Util.Format(ct[7], Task.Task.minlv));
        AtlasHelper.SetPetMission(taskIcon, Task.Task.icon);
        Util.ClearChildren(itemGroup);
        for (var i = 0; i < Task.Task.previewRewardItemId.Length; i++)
        {
            var itemData = Task.Task.previewRewardItemId[i];
            var propInfo = ConfigManager.Get <PropItemInfo>(itemData);
            if (propInfo == null)
            {
                continue;
            }
            var t = itemGroup.AddNewChild(item);
            t.SafeSetActive(true);
            Util.SetItemInfoSimple(t, propInfo);

            var button = t.GetComponent <Button>();
            if (button)
            {
                button.onClick.AddListener(() => Module_Global.instance.UpdateGlobalTip((ushort)itemData, true));
            }
        }

        speedUp.SafeSetActive(Task.State == (int)PetTaskState.Training);
        cancel.SafeSetActive(Task.State == (int)PetTaskState.Training);
        hourglass.SafeSetActive(Task.State == (int)PetTaskState.Training);
        gotAward.SafeSetActive(Task.State == (int)PetTaskState.Success || Task.State == (int)PetTaskState.Defeat);
        startTrain.SafeSetActive(Task.State == (int)PetTaskState.None && !Task.TimesUseUp);
        completeImage.SafeSetActive(Task.State == (int)PetTaskState.Success);
        defeatImage.SafeSetActive(Task.State == (int)PetTaskState.Defeat);
        over.SafeSetActive(Task.TimesUseUp && Task.State == (int)PetTaskState.None);

        if (over.gameObject.activeInHierarchy)
        {
            Util.SetText(overText, ConfigText.GetDefalutString(TextForMatType.PetTrainText, Task.IsWeekTask ? 29 : 26));
        }

        if (Task.State == (int)PetTaskState.None && !Task.TimesUseUp)
        {
            var a = Task.Task.costTime;
            var t = new TimeSpan(a * TimeSpan.TicksPerMinute);
            Util.SetText(timeremaining, Util.Format(ct[6], $"{(int)t.TotalHours:00}:{t.Minutes:00}:{t.Seconds:00}"));
        }
        else
        {
            Util.SetText(timeremaining, string.Empty);
        }

        prtListRoot.SafeSetActive(Task.GetTrainingPetCount() > 0);
        for (var i = 0; i < petList.Length; i++)
        {
            var petId   = Task.GetTrainingPet(i);
            var petInfo = petId != 0 ? Module_Pet.instance.GetPet(petId) : null;
            if (petId == 0 || petInfo == null)
            {
                petList[i].SafeSetActive(false);
            }
            else
            {
                AtlasHelper.SetPetIcon(petList[i], petInfo.UpGradeInfo.icon);
                petList[i].SafeSetActive(true);
            }
        }

        taskTypeColor.color = ColorGroup.GetColor(ColorManagerType.TaskType, Task.Task.type);
    }