Files
MVP1/Assets/Scripts/Meta/Panels/QuestsPanel.cs
T
AlexanderandClaude Opus 5.5 0ebbf56306 Синие кристаллы (регламент 05.11, пп. 1 и 3): не сверх 50 и без потерь, ожидание наград (не больше 2), задания -- 1-2 кристалла
- CrystalRewards (без Unity) + 6 тестов из раздела 6 регламента
- Задания: сколько помещается, остаток ждёт в задании («Забрать»); третья не помещающаяся награда не выдаётся
- Остальные награды: не поместившееся -- письмом «Кристаллы ждут места», из письма -- сколько помещается
- Награды заданий 1-2 вместо 20-250, ежедневные -- без кристаллов

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 18:29:31 +01:00

88 lines
4.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
// ЗАДАНИЯ: две вкладки -- основная цепочка и ежедневные (сброс в полночь).
// Прогресс считается сам из игры: сбор ресурсов, стройка, Ратуша, бои, войска, герой, арена.
public class QuestsPanel : BasePanel
{
int tab;
TextMeshProUGUI resetTimer;
protected override void Build(RectTransform root)
{
var col = UIKit.Card(root, new Color(0, 0, 0, 0), 0, 12);
UIKit.Stretch(col);
UIKit.Tabs(col, new[] { "Основные", "Ежедневные" }, tab, i => { tab = i; RequestRebuild(); });
bool daily = tab == 1;
resetTimer = null;
if (daily)
{
resetTimer = UIKit.Text(col, "", 26, UIKit.Theme.TextDim, TextAlignmentOptions.Center, 40);
Tick();
}
var holder = UIKit.Make("ListHolder", col);
UIKit.Size(holder, -1, -1).flexibleHeight = 1;
var list = ScrollList(holder);
var source = daily ? GameData.DailyQuests : GameData.MainQuests;
var shown = new List<QuestDef>();
int claimedCount = 0;
// Сначала кристаллы, которые ждут места (регламент 05.11), потом готовые к получению, потом в процессе.
// В основных -- не больше 6 активных.
foreach (var q in source) if (GP.IsQuestClaimed(q, daily) && GP.QuestGemsWaiting(q, daily) > 0) shown.Add(q);
foreach (var q in source) if (!GP.IsQuestClaimed(q, daily) && GP.IsQuestDone(q, daily)) shown.Add(q);
foreach (var q in source)
{
if (GP.IsQuestClaimed(q, daily)) { claimedCount++; continue; }
if (GP.IsQuestDone(q, daily)) continue;
if (!daily && shown.Count >= 6) continue;
shown.Add(q);
}
foreach (var q in shown) QuestCard(list, q, daily);
if (shown.Count == 0)
UIKit.Text(list, daily ? "Все ежедневные задания выполнены! Приходите завтра." : "Все задания выполнены! Скоро будут новые.",
30, UIKit.Theme.Gold, TextAlignmentOptions.Center, 120);
UIKit.Text(list, "Выполнено: " + claimedCount + " из " + source.Count, 26, UIKit.Theme.TextDim, TextAlignmentOptions.Center, 50);
}
void QuestCard(Transform parent, QuestDef q, bool daily)
{
bool done = GP.IsQuestDone(q, daily);
int progress = Mathf.Min(GP.QuestProgress(q, daily), q.target);
var card = UIKit.Card(parent, done ? UIKit.Theme.CardDone : UIKit.Theme.Card);
var title = UIKit.Text(card, q.title, 32);
title.fontStyle = FontStyles.Bold;
UIKit.Bar(card, (float)progress / q.target, done ? UIKit.Theme.Green : UIKit.Theme.Gold, 30, progress + " / " + q.target);
var row = UIKit.Row(card, 80, 12);
int waiting = GP.QuestGemsWaiting(q, daily);
if (waiting > 0)
{
// Награда получена, кроме кристаллов: им не было места (хранилище 50). Ждут, не сгорают
var wait = UIKit.Text(row, $"Ждут места: {waiting} кристаллов (хранилище {GameProgress.GemsHave:0} / {GameProgress.GemsCap:0})", 24, UIKit.Theme.Gold);
UIKit.Size(wait, -1, -1, 1);
UIKit.Button(row, "Забрать", UIKit.Theme.Green, () => GP.ClaimQuest(q, daily), 220, 80);
return;
}
var reward = UIKit.Text(row, "Награда: " + GameData.RewardsText(q.rewards) + ", " + q.xp + " опыта", 24, UIKit.Theme.TextDim);
UIKit.Size(reward, -1, -1, 1);
var b = UIKit.Button(row, done ? "Забрать" : "В процессе", done ? UIKit.Theme.Green : UIKit.Theme.Gray,
() => GP.ClaimQuest(q, daily), 220, 80);
b.interactable = done;
}
protected override void Tick()
{
if (resetTimer != null) resetTimer.text = "Обновление через " + GameData.FormatTime(GameProgress.SecondsToNextDay);
}
}