1469 lines
63 KiB
C#
1469 lines
63 KiB
C#
using System;
|
||||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
using TMPro;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Полнофункциональный интерактивный смартфон игрока с приложением АвтоБазар,
|
|||
|
|
/// просмотром объявлений, фото, характеристик, договоренностью о встрече и GPS-навигацией.
|
|||
|
|
/// </summary>
|
|||
|
|
public class SmartphoneUI : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public enum PhoneView
|
|||
|
|
{
|
|||
|
|
Home,
|
|||
|
|
AutoBazarFeed,
|
|||
|
|
AutoBazarDetail,
|
|||
|
|
GpsApp
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[Header("Клавиши управления")]
|
|||
|
|
[SerializeField] private KeyCode primaryToggleKey = KeyCode.P;
|
|||
|
|
[SerializeField] private KeyCode secondaryToggleKey = KeyCode.M;
|
|||
|
|
|
|||
|
|
[Header("Ссылки")]
|
|||
|
|
[SerializeField] private CarMarketManager marketManager;
|
|||
|
|
|
|||
|
|
// Состояния
|
|||
|
|
public bool IsOpen { get; private set; } = false;
|
|||
|
|
private PhoneView currentView = PhoneView.Home;
|
|||
|
|
private CarListing selectedListing;
|
|||
|
|
private string activeFilter = "Все";
|
|||
|
|
|
|||
|
|
// Ссылки на внешние скрипты управления
|
|||
|
|
private PlayerLook playerLook;
|
|||
|
|
|
|||
|
|
// Canvas и корневой интерфейс
|
|||
|
|
private Canvas phoneCanvas;
|
|||
|
|
private RectTransform phoneRoot;
|
|||
|
|
private CanvasGroup phoneGroup;
|
|||
|
|
private Vector2 closedPos = new Vector2(-40f, -950f);
|
|||
|
|
private Vector2 openedPos = new Vector2(-40f, 40f);
|
|||
|
|
|
|||
|
|
// Dynamic Island
|
|||
|
|
private RectTransform dynamicIslandRect;
|
|||
|
|
private TextMeshProUGUI dynamicIslandText;
|
|||
|
|
private float dynamicIslandExpandTimer = 0f;
|
|||
|
|
|
|||
|
|
// Статус-бар
|
|||
|
|
private TextMeshProUGUI clockText;
|
|||
|
|
private CanvasGroup statusBarGroup;
|
|||
|
|
|
|||
|
|
// Экраны
|
|||
|
|
private GameObject homeScreenObj;
|
|||
|
|
private GameObject autoBazarFeedObj;
|
|||
|
|
private GameObject autoBazarDetailObj;
|
|||
|
|
private GameObject gpsAppObj;
|
|||
|
|
|
|||
|
|
// Элементы ленты АвтоБазара
|
|||
|
|
private RectTransform feedContentRect;
|
|||
|
|
private TextMeshProUGUI feedSubtitleText;
|
|||
|
|
private readonly List<GameObject> spawnedFeedCards = new List<GameObject>();
|
|||
|
|
|
|||
|
|
// Элементы детального просмотра объявления
|
|||
|
|
private Image detailPhotoImage;
|
|||
|
|
private TextMeshProUGUI detailTitleText;
|
|||
|
|
private TextMeshProUGUI detailPriceText;
|
|||
|
|
private TextMeshProUGUI detailSpecsText;
|
|||
|
|
private TextMeshProUGUI detailSellerNameText;
|
|||
|
|
private TextMeshProUGUI detailSellerRatingText;
|
|||
|
|
private TextMeshProUGUI detailSellerDescText;
|
|||
|
|
private Button detailArrangeBtn;
|
|||
|
|
private TextMeshProUGUI detailArrangeBtnText;
|
|||
|
|
|
|||
|
|
// GPS приложение
|
|||
|
|
private TextMeshProUGUI gpsStatusText;
|
|||
|
|
private TextMeshProUGUI gpsDistanceText;
|
|||
|
|
|
|||
|
|
// HUD Мини-кнопка открытия телефона
|
|||
|
|
private GameObject hudPhoneButtonObj;
|
|||
|
|
private TextMeshProUGUI hudBadgeText;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
if (marketManager == null)
|
|||
|
|
marketManager = FindAnyObjectByType<CarMarketManager>();
|
|||
|
|
|
|||
|
|
playerLook = FindAnyObjectByType<PlayerLook>();
|
|||
|
|
|
|||
|
|
BuildPhoneCanvas();
|
|||
|
|
BuildHudPhoneButton();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Start()
|
|||
|
|
{
|
|||
|
|
if (marketManager != null)
|
|||
|
|
{
|
|||
|
|
marketManager.OnListingsUpdated += RefreshCurrentView;
|
|||
|
|
marketManager.OnMeetingArranged += (listing) =>
|
|||
|
|
{
|
|||
|
|
TriggerDynamicIslandNotification($"💬 {listing.sellerName}: Договорились! Жду вас на локации. Метка в GPS!");
|
|||
|
|
RefreshCurrentView();
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SwitchView(PhoneView.Home);
|
|||
|
|
phoneRoot.anchoredPosition = closedPos;
|
|||
|
|
phoneGroup.alpha = 0f;
|
|||
|
|
phoneRoot.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Update()
|
|||
|
|
{
|
|||
|
|
// В главном меню и на экране загрузки кнопка телефона скрыта
|
|||
|
|
MainMenuAndBootManager menu = MainMenuAndBootManager.Instance;
|
|||
|
|
bool inMenu = menu != null && !menu.IsPlaying;
|
|||
|
|
if (hudPhoneButtonObj != null && hudPhoneButtonObj.activeSelf == inMenu && !IsOpen)
|
|||
|
|
hudPhoneButtonObj.SetActive(!inMenu);
|
|||
|
|
if (inMenu && !IsOpen) return;
|
|||
|
|
|
|||
|
|
// Открытие/закрытие по кнопке P или M
|
|||
|
|
if ((Input.GetKeyDown(primaryToggleKey) || Input.GetKeyDown(secondaryToggleKey))
|
|||
|
|
&& (IsOpen || !GameInputLock.IsLockedByOther(this)))
|
|||
|
|
{
|
|||
|
|
TogglePhone(!IsOpen);
|
|||
|
|
}
|
|||
|
|
else if (IsOpen && Input.GetKeyDown(KeyCode.Escape))
|
|||
|
|
{
|
|||
|
|
if (currentView == PhoneView.AutoBazarDetail)
|
|||
|
|
SwitchView(PhoneView.AutoBazarFeed);
|
|||
|
|
else if (currentView != PhoneView.Home)
|
|||
|
|
SwitchView(PhoneView.Home);
|
|||
|
|
else
|
|||
|
|
TogglePhone(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Анимация скольжения телефона
|
|||
|
|
Vector2 targetPos = IsOpen ? openedPos : closedPos;
|
|||
|
|
float targetAlpha = IsOpen ? 1f : 0f;
|
|||
|
|
phoneRoot.anchoredPosition = Vector2.Lerp(phoneRoot.anchoredPosition, targetPos, Time.deltaTime * 14f);
|
|||
|
|
phoneGroup.alpha = Mathf.MoveTowards(phoneGroup.alpha, targetAlpha, Time.deltaTime * 8f);
|
|||
|
|
|
|||
|
|
if (!IsOpen && phoneGroup.alpha <= 0.01f && phoneRoot.gameObject.activeSelf)
|
|||
|
|
{
|
|||
|
|
phoneRoot.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Обновление часов
|
|||
|
|
if (clockText != null)
|
|||
|
|
{
|
|||
|
|
DateTime now = DateTime.Now;
|
|||
|
|
clockText.text = $"{now.Hour:D2}:{now.Minute:D2}";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Обновление Dynamic Island и Статус-бара
|
|||
|
|
if (dynamicIslandExpandTimer > 0f)
|
|||
|
|
{
|
|||
|
|
dynamicIslandExpandTimer -= Time.deltaTime;
|
|||
|
|
dynamicIslandRect.sizeDelta = Vector2.Lerp(dynamicIslandRect.sizeDelta, new Vector2(330f, 54f), Time.deltaTime * 14f);
|
|||
|
|
if (dynamicIslandText != null) dynamicIslandText.gameObject.SetActive(true);
|
|||
|
|
if (statusBarGroup != null) statusBarGroup.alpha = Mathf.MoveTowards(statusBarGroup.alpha, 0f, Time.deltaTime * 12f);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dynamicIslandRect.sizeDelta = Vector2.Lerp(dynamicIslandRect.sizeDelta, new Vector2(120f, 28f), Time.deltaTime * 10f);
|
|||
|
|
if (dynamicIslandText != null && dynamicIslandRect.sizeDelta.x < 140f)
|
|||
|
|
dynamicIslandText.gameObject.SetActive(false);
|
|||
|
|
if (statusBarGroup != null) statusBarGroup.alpha = Mathf.MoveTowards(statusBarGroup.alpha, 1f, Time.deltaTime * 8f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Обновление GPS приложения
|
|||
|
|
if (currentView == PhoneView.GpsApp && gpsDistanceText != null)
|
|||
|
|
{
|
|||
|
|
UpdateGpsViewData();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void TogglePhone(bool open)
|
|||
|
|
{
|
|||
|
|
IsOpen = open;
|
|||
|
|
if (IsOpen)
|
|||
|
|
{
|
|||
|
|
if (marketManager != null)
|
|||
|
|
marketManager.EnsureListingsGenerated();
|
|||
|
|
|
|||
|
|
phoneRoot.gameObject.SetActive(true);
|
|||
|
|
PhoneAudioFeedback.Instance.PlayUnlock();
|
|||
|
|
RefreshCurrentView();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GameInputLock.Set(this, IsOpen);
|
|||
|
|
|
|||
|
|
if (playerLook != null)
|
|||
|
|
playerLook.enabled = !IsOpen;
|
|||
|
|
|
|||
|
|
if (hudPhoneButtonObj != null)
|
|||
|
|
hudPhoneButtonObj.SetActive(!IsOpen);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SwitchView(PhoneView newView)
|
|||
|
|
{
|
|||
|
|
currentView = newView;
|
|||
|
|
PhoneAudioFeedback.Instance.PlayTap();
|
|||
|
|
|
|||
|
|
if (homeScreenObj != null) homeScreenObj.SetActive(newView == PhoneView.Home);
|
|||
|
|
if (autoBazarFeedObj != null) autoBazarFeedObj.SetActive(newView == PhoneView.AutoBazarFeed);
|
|||
|
|
if (autoBazarDetailObj != null) autoBazarDetailObj.SetActive(newView == PhoneView.AutoBazarDetail);
|
|||
|
|
if (gpsAppObj != null) gpsAppObj.SetActive(newView == PhoneView.GpsApp);
|
|||
|
|
|
|||
|
|
RefreshCurrentView();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RefreshCurrentView()
|
|||
|
|
{
|
|||
|
|
switch (currentView)
|
|||
|
|
{
|
|||
|
|
case PhoneView.Home:
|
|||
|
|
break;
|
|||
|
|
case PhoneView.AutoBazarFeed:
|
|||
|
|
PopulateFeedCards();
|
|||
|
|
break;
|
|||
|
|
case PhoneView.AutoBazarDetail:
|
|||
|
|
PopulateDetailData();
|
|||
|
|
break;
|
|||
|
|
case PhoneView.GpsApp:
|
|||
|
|
UpdateGpsViewData();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (hudBadgeText != null && marketManager != null)
|
|||
|
|
{
|
|||
|
|
hudBadgeText.text = $"{marketManager.Listings.Count}";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void TriggerDynamicIslandNotification(string text)
|
|||
|
|
{
|
|||
|
|
if (dynamicIslandText != null)
|
|||
|
|
dynamicIslandText.text = text;
|
|||
|
|
|
|||
|
|
dynamicIslandExpandTimer = 4.5f;
|
|||
|
|
PhoneAudioFeedback.Instance.PlayNotification();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ЛЕНТА ОБЪЯВЛЕНИЙ АВТОБАЗАРА
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void PopulateFeedCards()
|
|||
|
|
{
|
|||
|
|
if (feedContentRect == null || marketManager == null) return;
|
|||
|
|
|
|||
|
|
foreach (var c in spawnedFeedCards)
|
|||
|
|
{
|
|||
|
|
if (c != null) Destroy(c);
|
|||
|
|
}
|
|||
|
|
spawnedFeedCards.Clear();
|
|||
|
|
|
|||
|
|
List<CarListing> list = marketManager.Listings;
|
|||
|
|
int matchCount = 0;
|
|||
|
|
|
|||
|
|
for (int i = 0; i < list.Count; i++)
|
|||
|
|
{
|
|||
|
|
CarListing item = list[i];
|
|||
|
|
|
|||
|
|
// Фильтрация
|
|||
|
|
if (activeFilter == "До $4,000" && item.price > 4000) continue;
|
|||
|
|
if (activeFilter == "Полный привод" && item.driveType != DriveType.AWD) continue;
|
|||
|
|
if (activeFilter == "Без дефектов" && (item.defectsSummary.rustedPartsCount > 0 || item.defectsSummary.missingBodyPartsCount > 0)) continue;
|
|||
|
|
if (activeFilter == "Проекты" && (item.defectsSummary.rustedPartsCount == 0 && item.defectsSummary.missingBodyPartsCount == 0)) continue;
|
|||
|
|
|
|||
|
|
matchCount++;
|
|||
|
|
CreateFeedCard(item, i);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (feedSubtitleText != null)
|
|||
|
|
feedSubtitleText.text = $"Найдено {matchCount} предложений от частников";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CreateFeedCard(CarListing item, int index)
|
|||
|
|
{
|
|||
|
|
GameObject cardObj = new GameObject($"ListingCard_{item.id}");
|
|||
|
|
cardObj.transform.SetParent(feedContentRect, false);
|
|||
|
|
spawnedFeedCards.Add(cardObj);
|
|||
|
|
|
|||
|
|
RectTransform cardRt = cardObj.AddComponent<RectTransform>();
|
|||
|
|
cardRt.sizeDelta = new Vector2(334f, 130f);
|
|||
|
|
|
|||
|
|
Image cardBg = cardObj.AddComponent<Image>();
|
|||
|
|
cardBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.12f, 0.14f, 0.18f, 0.95f), new Color(0.22f, 0.26f, 0.33f), 1.5f, 16);
|
|||
|
|
cardBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button cardBtn = cardObj.AddComponent<Button>();
|
|||
|
|
ColorBlock cb = cardBtn.colors;
|
|||
|
|
cb.highlightedColor = new Color(0.18f, 0.22f, 0.28f, 1f);
|
|||
|
|
cb.pressedColor = new Color(0.10f, 0.12f, 0.15f, 1f);
|
|||
|
|
cardBtn.colors = cb;
|
|||
|
|
cardBtn.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
selectedListing = item;
|
|||
|
|
SwitchView(PhoneView.AutoBazarDetail);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 1. Фотография машины слева
|
|||
|
|
GameObject photoObj = new GameObject("Photo");
|
|||
|
|
photoObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform photoRt = photoObj.AddComponent<RectTransform>();
|
|||
|
|
photoRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
photoRt.anchorMax = new Vector2(0f, 0.5f);
|
|||
|
|
photoRt.pivot = new Vector2(0f, 0.5f);
|
|||
|
|
photoRt.anchoredPosition = new Vector2(10f, 0f);
|
|||
|
|
photoRt.sizeDelta = new Vector2(130f, 85f);
|
|||
|
|
|
|||
|
|
Image photoImg = photoObj.AddComponent<Image>();
|
|||
|
|
photoImg.sprite = item.photo;
|
|||
|
|
photoImg.preserveAspect = true;
|
|||
|
|
photoImg.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// 2. Блок информации справа
|
|||
|
|
float textX = 148f;
|
|||
|
|
|
|||
|
|
// Цена
|
|||
|
|
GameObject priceObj = new GameObject("Price");
|
|||
|
|
priceObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform priceRt = priceObj.AddComponent<RectTransform>();
|
|||
|
|
priceRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
priceRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
priceRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
priceRt.anchoredPosition = new Vector2(textX, -10f);
|
|||
|
|
priceRt.sizeDelta = new Vector2(175f, 26f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI priceT = priceObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
priceT.fontSize = 18f;
|
|||
|
|
priceT.fontStyle = FontStyles.Bold;
|
|||
|
|
priceT.color = new Color(0.10f, 0.85f, 0.45f);
|
|||
|
|
priceT.text = $"${item.price:N0}";
|
|||
|
|
priceT.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Название и год
|
|||
|
|
GameObject titleObj = new GameObject("Title");
|
|||
|
|
titleObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform titleRt = titleObj.AddComponent<RectTransform>();
|
|||
|
|
titleRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
titleRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
titleRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
titleRt.anchoredPosition = new Vector2(textX, -34f);
|
|||
|
|
titleRt.sizeDelta = new Vector2(175f, 20f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI titleT = titleObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
titleT.fontSize = 13f;
|
|||
|
|
titleT.fontStyle = FontStyles.Bold;
|
|||
|
|
titleT.color = Color.white;
|
|||
|
|
titleT.text = $"{item.catalogItem.carTitle} • {item.year}";
|
|||
|
|
titleT.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Характеристики (Пробег, привод)
|
|||
|
|
GameObject specObj = new GameObject("Specs");
|
|||
|
|
specObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform specRt = specObj.AddComponent<RectTransform>();
|
|||
|
|
specRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
specRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
specRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
specRt.anchoredPosition = new Vector2(textX, -56f);
|
|||
|
|
specRt.sizeDelta = new Vector2(175f, 18f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI specT = specObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
specT.fontSize = 11f;
|
|||
|
|
specT.color = new Color(0.7f, 0.75f, 0.82f);
|
|||
|
|
specT.text = $"{item.mileageKm:N0} км • {FormatDriveShort(item.driveType)}";
|
|||
|
|
specT.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Бейдж состояния / дефектов
|
|||
|
|
GameObject badgeObj = new GameObject("ConditionBadge");
|
|||
|
|
badgeObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform badgeRt = badgeObj.AddComponent<RectTransform>();
|
|||
|
|
badgeRt.anchorMin = new Vector2(0f, 0f);
|
|||
|
|
badgeRt.anchorMax = new Vector2(0f, 0f);
|
|||
|
|
badgeRt.pivot = new Vector2(0f, 0f);
|
|||
|
|
badgeRt.anchoredPosition = new Vector2(textX, 10f);
|
|||
|
|
badgeRt.sizeDelta = new Vector2(175f, 20f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI badgeT = badgeObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
badgeT.fontSize = 10f;
|
|||
|
|
badgeT.fontStyle = FontStyles.Bold;
|
|||
|
|
|
|||
|
|
if (item.isMeetingArranged)
|
|||
|
|
{
|
|||
|
|
badgeT.color = new Color(0.1f, 0.95f, 0.55f);
|
|||
|
|
badgeT.text = "[GPS] ВСТРЕЧА НАЗНАЧЕНА";
|
|||
|
|
}
|
|||
|
|
else if (item.defectsSummary.rustedPartsCount == 0 && item.defectsSummary.missingBodyPartsCount == 0)
|
|||
|
|
{
|
|||
|
|
badgeT.color = new Color(0.3f, 0.85f, 1f);
|
|||
|
|
badgeT.text = "Без рыжиков (Идеал)";
|
|||
|
|
}
|
|||
|
|
else if (item.defectsSummary.missingBodyPartsCount > 0)
|
|||
|
|
{
|
|||
|
|
badgeT.color = new Color(1f, 0.45f, 0.35f);
|
|||
|
|
badgeT.text = $"Сняты детали ({item.defectsSummary.missingBodyPartsCount} шт.)";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
badgeT.color = new Color(1f, 0.75f, 0.25f);
|
|||
|
|
badgeT.text = $"Рыжики: {item.defectsSummary.rustedPartsCount} эл.";
|
|||
|
|
}
|
|||
|
|
badgeT.raycastTarget = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ДЕТАЛЬНАЯ КАРТОЧКА АВТОМОБИЛЯ
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void PopulateDetailData()
|
|||
|
|
{
|
|||
|
|
if (selectedListing == null)
|
|||
|
|
{
|
|||
|
|
SwitchView(PhoneView.AutoBazarFeed);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CarListing item = selectedListing;
|
|||
|
|
|
|||
|
|
if (detailPhotoImage != null) detailPhotoImage.sprite = item.photo;
|
|||
|
|
if (detailTitleText != null) detailTitleText.text = $"{item.catalogItem.carTitle} ({item.year} г.)";
|
|||
|
|
if (detailPriceText != null) detailPriceText.text = $"${item.price:N0}";
|
|||
|
|
|
|||
|
|
if (detailSpecsText != null)
|
|||
|
|
{
|
|||
|
|
string rustDesc = item.defectsSummary.rustedPartsCount > 0 ? $"{item.defectsSummary.rustedPartsCount} деталей" : "Отсутствует (Идеал)";
|
|||
|
|
string wheelDesc = item.defectsSummary.missingWheelsCount > 0 ? "Нет колеса" : (item.defectsSummary.flatTiresCount > 0 ? "Спущено колесо" : "В норме");
|
|||
|
|
|
|||
|
|
detailSpecsText.text =
|
|||
|
|
$"<b>Привод:</b> {FormatDrive(item.driveType)}\n" +
|
|||
|
|
$"<b>Пробег:</b> {item.mileageKm:N0} км\n" +
|
|||
|
|
$"<b>Цвет кузова:</b> {item.bodyColorName}\n" +
|
|||
|
|
$"<b>Коррозия кузова:</b> {rustDesc}\n" +
|
|||
|
|
$"<b>Состояние колес:</b> {wheelDesc}";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (detailSellerNameText != null) detailSellerNameText.text = item.sellerName;
|
|||
|
|
if (detailSellerRatingText != null) detailSellerRatingText.text = $"<color=#fbbf24>★ Рейтинг: {item.sellerRating:F1}</color> • {item.sellerPhone}";
|
|||
|
|
if (detailSellerDescText != null) detailSellerDescText.text = $"«{item.sellerDescription}»";
|
|||
|
|
|
|||
|
|
if (detailArrangeBtnText != null)
|
|||
|
|
{
|
|||
|
|
detailArrangeBtnText.text = item.isMeetingArranged ? "[GPS] Встреча уже назначена (Открыть карту)" : "Договориться о встрече";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnArrangeMeetingClicked()
|
|||
|
|
{
|
|||
|
|
if (selectedListing == null || marketManager == null) return;
|
|||
|
|
|
|||
|
|
marketManager.ArrangeMeeting(selectedListing);
|
|||
|
|
PopulateDetailData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// GPS ПРИЛОЖЕНИЕ НА ТЕЛЕФОНЕ
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void UpdateGpsViewData()
|
|||
|
|
{
|
|||
|
|
if (marketManager == null || gpsStatusText == null || gpsDistanceText == null) return;
|
|||
|
|
|
|||
|
|
CarListing active = marketManager.ActiveMeetingListing;
|
|||
|
|
if (active != null && active.spawnedInstance != null)
|
|||
|
|
{
|
|||
|
|
Camera cam = Camera.main ?? FindAnyObjectByType<Camera>();
|
|||
|
|
float dist = cam != null ? Vector3.Distance(cam.transform.position, active.spawnedInstance.transform.position) : 0f;
|
|||
|
|
|
|||
|
|
gpsStatusText.text = $"<b>Назначена встреча:</b>\n{active.catalogItem.carTitle} ({active.year})\nПродавец: {active.sellerName}";
|
|||
|
|
gpsDistanceText.text = $"Расстояние до автомобиля: <color=#10b981><b>{dist:F0} м</b></color>";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
gpsStatusText.text = "Маршрут не построен.\nВыберите понравившуюся машину на АвтоБазаре и нажмите <b>«Договориться о встрече»</b>.";
|
|||
|
|
gpsDistanceText.text = "Метка на карте не установлена";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ПОСТРОЕНИЕ ИЕРАРХИИ UI СМАРТФОНА
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildPhoneCanvas()
|
|||
|
|
{
|
|||
|
|
GameObject cObj = new GameObject("SmartphoneCanvas");
|
|||
|
|
phoneCanvas = cObj.AddComponent<Canvas>();
|
|||
|
|
phoneCanvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
|||
|
|
phoneCanvas.sortingOrder = 100;
|
|||
|
|
|
|||
|
|
CanvasScaler scaler = cObj.AddComponent<CanvasScaler>();
|
|||
|
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|||
|
|
scaler.referenceResolution = new Vector2(1920, 1080);
|
|||
|
|
scaler.matchWidthOrHeight = 0.5f;
|
|||
|
|
|
|||
|
|
cObj.AddComponent<GraphicRaycaster>();
|
|||
|
|
|
|||
|
|
// Корневой фрейм телефона
|
|||
|
|
GameObject phoneObj = new GameObject("SmartphoneRoot");
|
|||
|
|
phoneObj.transform.SetParent(phoneCanvas.transform, false);
|
|||
|
|
phoneRoot = phoneObj.AddComponent<RectTransform>();
|
|||
|
|
phoneRoot.anchorMin = new Vector2(1f, 0f);
|
|||
|
|
phoneRoot.anchorMax = new Vector2(1f, 0f);
|
|||
|
|
phoneRoot.pivot = new Vector2(1f, 0f);
|
|||
|
|
phoneRoot.anchoredPosition = closedPos;
|
|||
|
|
phoneRoot.sizeDelta = new Vector2(370f, 720f);
|
|||
|
|
|
|||
|
|
phoneGroup = phoneObj.AddComponent<CanvasGroup>();
|
|||
|
|
|
|||
|
|
// Металлический корпус смартфона
|
|||
|
|
Image phoneChassis = phoneObj.AddComponent<Image>();
|
|||
|
|
phoneChassis.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.08f, 0.09f, 0.11f, 0.98f), new Color(0.24f, 0.27f, 0.32f), 3f, 44);
|
|||
|
|
phoneChassis.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
// Внутреннее защитное стекло дисплея
|
|||
|
|
GameObject screenObj = new GameObject("ScreenDisplay");
|
|||
|
|
screenObj.transform.SetParent(phoneObj.transform, false);
|
|||
|
|
RectTransform screenRt = screenObj.AddComponent<RectTransform>();
|
|||
|
|
screenRt.anchorMin = Vector2.zero;
|
|||
|
|
screenRt.anchorMax = Vector2.one;
|
|||
|
|
screenRt.offsetMin = new Vector2(8f, 8f);
|
|||
|
|
screenRt.offsetMax = new Vector2(-8f, -8f);
|
|||
|
|
|
|||
|
|
Image screenImg = screenObj.AddComponent<Image>();
|
|||
|
|
screenImg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.05f, 0.06f, 0.08f, 1f), null, 0f, 38);
|
|||
|
|
screenImg.type = Image.Type.Sliced;
|
|||
|
|
screenObj.AddComponent<RectMask2D>(); // Маскирует содержимое внутри закругленного дисплея
|
|||
|
|
|
|||
|
|
// Dynamic Island вверху
|
|||
|
|
BuildDynamicIsland(screenObj);
|
|||
|
|
|
|||
|
|
// Статус-бар (Время, Wi-Fi, Батарея)
|
|||
|
|
BuildStatusBar(screenObj);
|
|||
|
|
|
|||
|
|
// Контейнер экранов приложений
|
|||
|
|
GameObject screensContainer = new GameObject("AppsContainer");
|
|||
|
|
screensContainer.transform.SetParent(screenObj.transform, false);
|
|||
|
|
RectTransform scRt = screensContainer.AddComponent<RectTransform>();
|
|||
|
|
scRt.anchorMin = Vector2.zero;
|
|||
|
|
scRt.anchorMax = Vector2.one;
|
|||
|
|
scRt.offsetMin = new Vector2(0f, 26f); // Отступ под нижний жест-бар
|
|||
|
|
scRt.offsetMax = new Vector2(0f, -40f); // Отступ под статус-бар
|
|||
|
|
|
|||
|
|
BuildHomeScreen(screensContainer);
|
|||
|
|
BuildAutoBazarFeedScreen(screensContainer);
|
|||
|
|
BuildAutoBazarDetailScreen(screensContainer);
|
|||
|
|
BuildGpsAppScreen(screensContainer);
|
|||
|
|
|
|||
|
|
// Нижняя полоса жестов (Home Bar)
|
|||
|
|
BuildHomeBar(screenObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BuildDynamicIsland(GameObject parent)
|
|||
|
|
{
|
|||
|
|
GameObject diObj = new GameObject("DynamicIsland");
|
|||
|
|
diObj.transform.SetParent(parent.transform, false);
|
|||
|
|
dynamicIslandRect = diObj.AddComponent<RectTransform>();
|
|||
|
|
dynamicIslandRect.anchorMin = new Vector2(0.5f, 1f);
|
|||
|
|
dynamicIslandRect.anchorMax = new Vector2(0.5f, 1f);
|
|||
|
|
dynamicIslandRect.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
dynamicIslandRect.anchoredPosition = new Vector2(0f, -8f);
|
|||
|
|
dynamicIslandRect.sizeDelta = new Vector2(120f, 28f);
|
|||
|
|
|
|||
|
|
Image diBg = diObj.AddComponent<Image>();
|
|||
|
|
diBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(Color.black, new Color(0.18f, 0.20f, 0.24f), 1f, 14);
|
|||
|
|
diBg.type = Image.Type.Sliced;
|
|||
|
|
diBg.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Текст уведомления продавца внутри Dynamic Island
|
|||
|
|
GameObject textObj = new GameObject("NotificationText");
|
|||
|
|
textObj.transform.SetParent(diObj.transform, false);
|
|||
|
|
RectTransform tRt = textObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = Vector2.zero;
|
|||
|
|
tRt.anchorMax = Vector2.one;
|
|||
|
|
tRt.offsetMin = new Vector2(14f, 4f);
|
|||
|
|
tRt.offsetMax = new Vector2(-14f, -4f);
|
|||
|
|
|
|||
|
|
dynamicIslandText = textObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
dynamicIslandText.fontSize = 11f;
|
|||
|
|
dynamicIslandText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
dynamicIslandText.color = Color.white;
|
|||
|
|
dynamicIslandText.raycastTarget = false;
|
|||
|
|
dynamicIslandText.gameObject.SetActive(false);
|
|||
|
|
diObj.transform.SetAsLastSibling();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BuildStatusBar(GameObject parent)
|
|||
|
|
{
|
|||
|
|
GameObject sbObj = new GameObject("StatusBar");
|
|||
|
|
sbObj.transform.SetParent(parent.transform, false);
|
|||
|
|
statusBarGroup = sbObj.AddComponent<CanvasGroup>();
|
|||
|
|
RectTransform sbRt = sbObj.AddComponent<RectTransform>();
|
|||
|
|
sbRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
sbRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
sbRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
sbRt.anchoredPosition = Vector2.zero;
|
|||
|
|
sbRt.sizeDelta = new Vector2(0f, 38f);
|
|||
|
|
|
|||
|
|
// Часы слева
|
|||
|
|
GameObject clockObj = new GameObject("Clock");
|
|||
|
|
clockObj.transform.SetParent(sbObj.transform, false);
|
|||
|
|
RectTransform clockRt = clockObj.AddComponent<RectTransform>();
|
|||
|
|
clockRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
clockRt.anchorMax = new Vector2(0f, 0.5f);
|
|||
|
|
clockRt.pivot = new Vector2(0f, 0.5f);
|
|||
|
|
clockRt.anchoredPosition = new Vector2(24f, -4f);
|
|||
|
|
clockRt.sizeDelta = new Vector2(70f, 22f);
|
|||
|
|
|
|||
|
|
clockText = clockObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
clockText.fontSize = 12f;
|
|||
|
|
clockText.fontStyle = FontStyles.Bold;
|
|||
|
|
clockText.color = Color.white;
|
|||
|
|
clockText.alignment = TextAlignmentOptions.Left;
|
|||
|
|
clockText.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Иконки сети и батареи справа
|
|||
|
|
GameObject iconsObj = new GameObject("RightIcons");
|
|||
|
|
iconsObj.transform.SetParent(sbObj.transform, false);
|
|||
|
|
RectTransform iRt = iconsObj.AddComponent<RectTransform>();
|
|||
|
|
iRt.anchorMin = new Vector2(1f, 0.5f);
|
|||
|
|
iRt.anchorMax = new Vector2(1f, 0.5f);
|
|||
|
|
iRt.pivot = new Vector2(1f, 0.5f);
|
|||
|
|
iRt.anchoredPosition = new Vector2(-20f, -4f);
|
|||
|
|
iRt.sizeDelta = new Vector2(90f, 20f);
|
|||
|
|
|
|||
|
|
// Сигнал сети
|
|||
|
|
GameObject sigObj = new GameObject("Signal");
|
|||
|
|
sigObj.transform.SetParent(iconsObj.transform, false);
|
|||
|
|
RectTransform sigRt = sigObj.AddComponent<RectTransform>();
|
|||
|
|
sigRt.anchoredPosition = new Vector2(-60f, 0f);
|
|||
|
|
sigRt.sizeDelta = new Vector2(18f, 14f);
|
|||
|
|
Image sigImg = sigObj.AddComponent<Image>();
|
|||
|
|
sigImg.sprite = ProceduralUISprites.GetSignalBarsIcon(20, 14, Color.white, 4);
|
|||
|
|
|
|||
|
|
// Wi-Fi
|
|||
|
|
GameObject wifiObj = new GameObject("Wifi");
|
|||
|
|
wifiObj.transform.SetParent(iconsObj.transform, false);
|
|||
|
|
RectTransform wifiRt = wifiObj.AddComponent<RectTransform>();
|
|||
|
|
wifiRt.anchoredPosition = new Vector2(-35f, 0f);
|
|||
|
|
wifiRt.sizeDelta = new Vector2(16f, 16f);
|
|||
|
|
Image wifiImg = wifiObj.AddComponent<Image>();
|
|||
|
|
wifiImg.sprite = ProceduralUISprites.GetWifiIcon(32, Color.white);
|
|||
|
|
|
|||
|
|
// Батарея
|
|||
|
|
GameObject battObj = new GameObject("Battery");
|
|||
|
|
battObj.transform.SetParent(iconsObj.transform, false);
|
|||
|
|
RectTransform battRt = battObj.AddComponent<RectTransform>();
|
|||
|
|
battRt.anchoredPosition = new Vector2(-5f, 0f);
|
|||
|
|
battRt.sizeDelta = new Vector2(24f, 12f);
|
|||
|
|
Image battImg = battObj.AddComponent<Image>();
|
|||
|
|
battImg.sprite = ProceduralUISprites.GetBatteryIcon(26, 14, Color.white, new Color(0.2f, 0.95f, 0.45f), 0.88f);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BuildHomeBar(GameObject parent)
|
|||
|
|
{
|
|||
|
|
GameObject barObj = new GameObject("HomeIndicatorBar");
|
|||
|
|
barObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform barRt = barObj.AddComponent<RectTransform>();
|
|||
|
|
barRt.anchorMin = new Vector2(0.5f, 0f);
|
|||
|
|
barRt.anchorMax = new Vector2(0.5f, 0f);
|
|||
|
|
barRt.pivot = new Vector2(0.5f, 0f);
|
|||
|
|
barRt.anchoredPosition = new Vector2(0f, 8f);
|
|||
|
|
barRt.sizeDelta = new Vector2(130f, 5f);
|
|||
|
|
|
|||
|
|
Image barImg = barObj.AddComponent<Image>();
|
|||
|
|
barImg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(1f, 1f, 1f, 0.75f), null, 0f, 3);
|
|||
|
|
barImg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button barBtn = barObj.AddComponent<Button>();
|
|||
|
|
barBtn.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
if (currentView != PhoneView.Home)
|
|||
|
|
SwitchView(PhoneView.Home);
|
|||
|
|
else
|
|||
|
|
TogglePhone(false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ЭКРАН 0: РАБОЧИЙ СТОЛ ТЕЛЕФОНА (HOME SCREEN)
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildHomeScreen(GameObject parent)
|
|||
|
|
{
|
|||
|
|
homeScreenObj = new GameObject("HomeScreen");
|
|||
|
|
homeScreenObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform hsRt = homeScreenObj.AddComponent<RectTransform>();
|
|||
|
|
hsRt.anchorMin = Vector2.zero;
|
|||
|
|
hsRt.anchorMax = Vector2.one;
|
|||
|
|
hsRt.offsetMin = Vector2.zero;
|
|||
|
|
hsRt.offsetMax = Vector2.zero;
|
|||
|
|
|
|||
|
|
// Градиентные обои рабочего стола
|
|||
|
|
Image hsBg = homeScreenObj.AddComponent<Image>();
|
|||
|
|
hsBg.sprite = ProceduralUISprites.GetGradient(64, 128, new Color(0.08f, 0.12f, 0.22f), new Color(0.03f, 0.04f, 0.07f));
|
|||
|
|
hsBg.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Виджет даты и города
|
|||
|
|
GameObject widgetObj = new GameObject("ClockWidget");
|
|||
|
|
widgetObj.transform.SetParent(homeScreenObj.transform, false);
|
|||
|
|
RectTransform wRt = widgetObj.AddComponent<RectTransform>();
|
|||
|
|
wRt.anchorMin = new Vector2(0.5f, 1f);
|
|||
|
|
wRt.anchorMax = new Vector2(0.5f, 1f);
|
|||
|
|
wRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
wRt.anchoredPosition = new Vector2(0f, -30f);
|
|||
|
|
wRt.sizeDelta = new Vector2(300f, 100f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI wText = widgetObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
wText.fontSize = 38f;
|
|||
|
|
wText.fontStyle = FontStyles.Bold;
|
|||
|
|
wText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
wText.color = Color.white;
|
|||
|
|
wText.text = "17:30\n<size=14><color=#94a3b8>Пятница, 24 октября • +18°C</color></size>";
|
|||
|
|
|
|||
|
|
// Сетка иконок приложений
|
|||
|
|
GameObject gridObj = new GameObject("AppsGrid");
|
|||
|
|
gridObj.transform.SetParent(homeScreenObj.transform, false);
|
|||
|
|
RectTransform gRt = gridObj.AddComponent<RectTransform>();
|
|||
|
|
gRt.anchorMin = new Vector2(0.5f, 0.5f);
|
|||
|
|
gRt.anchorMax = new Vector2(0.5f, 0.5f);
|
|||
|
|
gRt.pivot = new Vector2(0.5f, 0.5f);
|
|||
|
|
gRt.anchoredPosition = new Vector2(0f, -20f);
|
|||
|
|
gRt.sizeDelta = new Vector2(300f, 260f);
|
|||
|
|
|
|||
|
|
// Иконка 1: 🚘 АвтоБазар (Главное приложение)
|
|||
|
|
CreateAppIcon(gridObj, new Vector2(-75f, 60f), "АвтоБазар",
|
|||
|
|
ProceduralUISprites.GetCarIcon(64, Color.white),
|
|||
|
|
new Color(0.05f, 0.65f, 0.40f),
|
|||
|
|
() => SwitchView(PhoneView.AutoBazarFeed),
|
|||
|
|
"6");
|
|||
|
|
|
|||
|
|
// Иконка 2: 🗺️ GPS Карта
|
|||
|
|
CreateAppIcon(gridObj, new Vector2(75f, 60f), "GPS Карта",
|
|||
|
|
ProceduralUISprites.GetMapPinIcon(64, Color.white),
|
|||
|
|
new Color(0.15f, 0.45f, 0.85f),
|
|||
|
|
() => SwitchView(PhoneView.GpsApp));
|
|||
|
|
|
|||
|
|
// Иконка 3: 💬 Сообщения
|
|||
|
|
CreateAppIcon(gridObj, new Vector2(-75f, -60f), "Сообщения",
|
|||
|
|
ProceduralUISprites.GetSlicedRoundedRect(Color.white, null, 0, 8),
|
|||
|
|
new Color(0.55f, 0.25f, 0.75f),
|
|||
|
|
() =>
|
|||
|
|
{
|
|||
|
|
TriggerDynamicIslandNotification("💬 Сообщения от продавцов активны");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// Иконка 4: ⚙️ Настройки
|
|||
|
|
CreateAppIcon(gridObj, new Vector2(75f, -60f), "Настройки",
|
|||
|
|
ProceduralUISprites.GetCircle(64, Color.white),
|
|||
|
|
new Color(0.35f, 0.38f, 0.45f),
|
|||
|
|
() =>
|
|||
|
|
{
|
|||
|
|
TriggerDynamicIslandNotification("⚙️ Телефон перекупа • Версия 2.6");
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CreateAppIcon(GameObject parent, Vector2 pos, string appName, Sprite iconSprite, Color bgColor, Action onClick, string badgeText = null)
|
|||
|
|
{
|
|||
|
|
GameObject appObj = new GameObject($"App_{appName}");
|
|||
|
|
appObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform rt = appObj.AddComponent<RectTransform>();
|
|||
|
|
rt.anchoredPosition = pos;
|
|||
|
|
rt.sizeDelta = new Vector2(80f, 90f);
|
|||
|
|
|
|||
|
|
// Кнопка-иконка
|
|||
|
|
GameObject btnObj = new GameObject("IconBtn");
|
|||
|
|
btnObj.transform.SetParent(appObj.transform, false);
|
|||
|
|
RectTransform btnRt = btnObj.AddComponent<RectTransform>();
|
|||
|
|
btnRt.anchoredPosition = new Vector2(0f, 12f);
|
|||
|
|
btnRt.sizeDelta = new Vector2(60f, 60f);
|
|||
|
|
|
|||
|
|
Image btnBg = btnObj.AddComponent<Image>();
|
|||
|
|
btnBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(bgColor, null, 0f, 16);
|
|||
|
|
btnBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button btn = btnObj.AddComponent<Button>();
|
|||
|
|
btn.onClick.AddListener(() => onClick?.Invoke());
|
|||
|
|
|
|||
|
|
// Символ внутри
|
|||
|
|
GameObject symbolObj = new GameObject("Symbol");
|
|||
|
|
symbolObj.transform.SetParent(btnObj.transform, false);
|
|||
|
|
RectTransform symRt = symbolObj.AddComponent<RectTransform>();
|
|||
|
|
symRt.sizeDelta = new Vector2(34f, 34f);
|
|||
|
|
Image symImg = symbolObj.AddComponent<Image>();
|
|||
|
|
symImg.sprite = iconSprite;
|
|||
|
|
symImg.preserveAspect = true;
|
|||
|
|
symImg.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Красный бейдж уведомления (если есть)
|
|||
|
|
if (!string.IsNullOrEmpty(badgeText))
|
|||
|
|
{
|
|||
|
|
GameObject bObj = new GameObject("Badge");
|
|||
|
|
bObj.transform.SetParent(btnObj.transform, false);
|
|||
|
|
RectTransform bRt = bObj.AddComponent<RectTransform>();
|
|||
|
|
bRt.anchorMin = new Vector2(1f, 1f);
|
|||
|
|
bRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
bRt.pivot = new Vector2(1f, 1f);
|
|||
|
|
bRt.anchoredPosition = new Vector2(6f, 6f);
|
|||
|
|
bRt.sizeDelta = new Vector2(22f, 22f);
|
|||
|
|
|
|||
|
|
Image bImg = bObj.AddComponent<Image>();
|
|||
|
|
bImg.sprite = ProceduralUISprites.GetCircle(24, new Color(0.95f, 0.2f, 0.25f));
|
|||
|
|
|
|||
|
|
GameObject bTextObj = new GameObject("Text");
|
|||
|
|
bTextObj.transform.SetParent(bObj.transform, false);
|
|||
|
|
RectTransform btRt = bTextObj.AddComponent<RectTransform>();
|
|||
|
|
btRt.anchorMin = Vector2.zero;
|
|||
|
|
btRt.anchorMax = Vector2.one;
|
|||
|
|
|
|||
|
|
TextMeshProUGUI bt = bTextObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
bt.fontSize = 11f;
|
|||
|
|
bt.fontStyle = FontStyles.Bold;
|
|||
|
|
bt.color = Color.white;
|
|||
|
|
bt.alignment = TextAlignmentOptions.Center;
|
|||
|
|
bt.text = badgeText;
|
|||
|
|
bt.raycastTarget = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Подпись под иконкой
|
|||
|
|
GameObject labelObj = new GameObject("Label");
|
|||
|
|
labelObj.transform.SetParent(appObj.transform, false);
|
|||
|
|
RectTransform lRt = labelObj.AddComponent<RectTransform>();
|
|||
|
|
lRt.anchoredPosition = new Vector2(0f, -28f);
|
|||
|
|
lRt.sizeDelta = new Vector2(85f, 18f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI label = labelObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
label.fontSize = 12f;
|
|||
|
|
label.alignment = TextAlignmentOptions.Center;
|
|||
|
|
label.color = Color.white;
|
|||
|
|
label.text = appName;
|
|||
|
|
label.raycastTarget = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ЭКРАН 1: ЛЕНТА АВТОБАЗАРА (FEED VIEW)
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildAutoBazarFeedScreen(GameObject parent)
|
|||
|
|
{
|
|||
|
|
autoBazarFeedObj = new GameObject("AutoBazarFeedScreen");
|
|||
|
|
autoBazarFeedObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform rt = autoBazarFeedObj.AddComponent<RectTransform>();
|
|||
|
|
rt.anchorMin = Vector2.zero;
|
|||
|
|
rt.anchorMax = Vector2.one;
|
|||
|
|
rt.offsetMin = Vector2.zero;
|
|||
|
|
rt.offsetMax = Vector2.zero;
|
|||
|
|
|
|||
|
|
Image bg = autoBazarFeedObj.AddComponent<Image>();
|
|||
|
|
bg.color = new Color(0.07f, 0.08f, 0.10f, 1f);
|
|||
|
|
|
|||
|
|
// Верхний бар приложения
|
|||
|
|
GameObject headerObj = new GameObject("AppHeader");
|
|||
|
|
headerObj.transform.SetParent(autoBazarFeedObj.transform, false);
|
|||
|
|
RectTransform hRt = headerObj.AddComponent<RectTransform>();
|
|||
|
|
hRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
hRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
hRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
hRt.sizeDelta = new Vector2(0f, 85f);
|
|||
|
|
|
|||
|
|
// Кнопка "Назад" на рабочий стол
|
|||
|
|
GameObject backBtnObj = new GameObject("BackBtn");
|
|||
|
|
backBtnObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform bRt = backBtnObj.AddComponent<RectTransform>();
|
|||
|
|
bRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
bRt.anchorMax = new Vector2(0f, 1f);
|
|||
|
|
bRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
bRt.anchoredPosition = new Vector2(14f, -10f);
|
|||
|
|
bRt.sizeDelta = new Vector2(36f, 32f);
|
|||
|
|
|
|||
|
|
Button backBtn = backBtnObj.AddComponent<Button>();
|
|||
|
|
backBtn.onClick.AddListener(() => SwitchView(PhoneView.Home));
|
|||
|
|
|
|||
|
|
TextMeshProUGUI backText = backBtnObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
backText.fontSize = 20f;
|
|||
|
|
backText.color = new Color(0.10f, 0.85f, 0.45f);
|
|||
|
|
backText.text = "<b><</b>";
|
|||
|
|
backText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
|
|||
|
|
// Заголовок "АвтоБазар"
|
|||
|
|
GameObject titleObj = new GameObject("AppTitle");
|
|||
|
|
titleObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform tRt = titleObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
tRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
tRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
tRt.anchoredPosition = new Vector2(54f, -8f);
|
|||
|
|
tRt.sizeDelta = new Vector2(280f, 24f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI title = titleObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
title.fontSize = 18f;
|
|||
|
|
title.fontStyle = FontStyles.Bold;
|
|||
|
|
title.color = Color.white;
|
|||
|
|
title.text = "<b>АвтоБазар</b>";
|
|||
|
|
|
|||
|
|
// Подзаголовок
|
|||
|
|
GameObject subObj = new GameObject("Subtitle");
|
|||
|
|
subObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform subRt = subObj.AddComponent<RectTransform>();
|
|||
|
|
subRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
subRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
subRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
subRt.anchoredPosition = new Vector2(54f, -32f);
|
|||
|
|
subRt.sizeDelta = new Vector2(280f, 16f);
|
|||
|
|
|
|||
|
|
feedSubtitleText = subObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
feedSubtitleText.fontSize = 11f;
|
|||
|
|
feedSubtitleText.color = new Color(0.6f, 0.65f, 0.72f);
|
|||
|
|
feedSubtitleText.text = "Найдено 6 предложений от частников";
|
|||
|
|
|
|||
|
|
// Полоса быстрых фильтров
|
|||
|
|
GameObject filterRow = new GameObject("FilterChipsRow");
|
|||
|
|
filterRow.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform frRt = filterRow.AddComponent<RectTransform>();
|
|||
|
|
frRt.anchorMin = new Vector2(0f, 0f);
|
|||
|
|
frRt.anchorMax = new Vector2(1f, 0f);
|
|||
|
|
frRt.pivot = new Vector2(0.5f, 0f);
|
|||
|
|
frRt.sizeDelta = new Vector2(0f, 32f);
|
|||
|
|
|
|||
|
|
CreateFilterChip(filterRow, new Vector2(40f, 16f), "Все");
|
|||
|
|
CreateFilterChip(filterRow, new Vector2(115f, 16f), "До $4,000");
|
|||
|
|
CreateFilterChip(filterRow, new Vector2(215f, 16f), "Полный привод");
|
|||
|
|
CreateFilterChip(filterRow, new Vector2(305f, 16f), "Проекты");
|
|||
|
|
|
|||
|
|
// ScrollRect для ленты
|
|||
|
|
GameObject scrollObj = new GameObject("FeedScrollView");
|
|||
|
|
scrollObj.transform.SetParent(autoBazarFeedObj.transform, false);
|
|||
|
|
RectTransform scrollRt = scrollObj.AddComponent<RectTransform>();
|
|||
|
|
scrollRt.anchorMin = Vector2.zero;
|
|||
|
|
scrollRt.anchorMax = Vector2.one;
|
|||
|
|
scrollRt.offsetMin = new Vector2(8f, 0f);
|
|||
|
|
scrollRt.offsetMax = new Vector2(-8f, -90f);
|
|||
|
|
|
|||
|
|
ScrollRect sr = scrollObj.AddComponent<ScrollRect>();
|
|||
|
|
sr.horizontal = false;
|
|||
|
|
sr.vertical = true;
|
|||
|
|
sr.scrollSensitivity = 25f;
|
|||
|
|
|
|||
|
|
scrollObj.AddComponent<RectMask2D>();
|
|||
|
|
|
|||
|
|
// Content
|
|||
|
|
GameObject contentObj = new GameObject("Content");
|
|||
|
|
contentObj.transform.SetParent(scrollObj.transform, false);
|
|||
|
|
feedContentRect = contentObj.AddComponent<RectTransform>();
|
|||
|
|
feedContentRect.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
feedContentRect.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
feedContentRect.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
feedContentRect.anchoredPosition = Vector2.zero;
|
|||
|
|
feedContentRect.sizeDelta = new Vector2(0f, 850f);
|
|||
|
|
|
|||
|
|
VerticalLayoutGroup vlg = contentObj.AddComponent<VerticalLayoutGroup>();
|
|||
|
|
vlg.spacing = 10f;
|
|||
|
|
vlg.padding = new RectOffset(4, 4, 8, 20);
|
|||
|
|
vlg.childForceExpandWidth = true;
|
|||
|
|
vlg.childForceExpandHeight = false;
|
|||
|
|
vlg.childControlWidth = true;
|
|||
|
|
vlg.childControlHeight = false;
|
|||
|
|
|
|||
|
|
ContentSizeFitter csf = contentObj.AddComponent<ContentSizeFitter>();
|
|||
|
|
csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
|||
|
|
|
|||
|
|
sr.content = feedContentRect;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CreateFilterChip(GameObject parent, Vector2 pos, string label)
|
|||
|
|
{
|
|||
|
|
GameObject chipObj = new GameObject($"Chip_{label}");
|
|||
|
|
chipObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform cRt = chipObj.AddComponent<RectTransform>();
|
|||
|
|
cRt.anchoredPosition = pos;
|
|||
|
|
cRt.sizeDelta = new Vector2(65f, 24f);
|
|||
|
|
|
|||
|
|
Image img = chipObj.AddComponent<Image>();
|
|||
|
|
img.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.14f, 0.16f, 0.22f), new Color(0.25f, 0.28f, 0.36f), 1f, 12);
|
|||
|
|
img.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button b = chipObj.AddComponent<Button>();
|
|||
|
|
b.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
activeFilter = label;
|
|||
|
|
PhoneAudioFeedback.Instance.PlayTap();
|
|||
|
|
PopulateFeedCards();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
GameObject tObj = new GameObject("Text");
|
|||
|
|
tObj.transform.SetParent(chipObj.transform, false);
|
|||
|
|
RectTransform tRt = tObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = Vector2.zero;
|
|||
|
|
tRt.anchorMax = Vector2.one;
|
|||
|
|
|
|||
|
|
TextMeshProUGUI t = tObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
t.fontSize = 10f;
|
|||
|
|
t.color = Color.white;
|
|||
|
|
t.alignment = TextAlignmentOptions.Center;
|
|||
|
|
t.text = label;
|
|||
|
|
t.raycastTarget = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ЭКРАН 2: ПОЛНОРАЗМЕРНАЯ КАРТОЧКА ОБЪЯВЛЕНИЯ (DETAIL VIEW)
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildAutoBazarDetailScreen(GameObject parent)
|
|||
|
|
{
|
|||
|
|
autoBazarDetailObj = new GameObject("AutoBazarDetailScreen");
|
|||
|
|
autoBazarDetailObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform rt = autoBazarDetailObj.AddComponent<RectTransform>();
|
|||
|
|
rt.anchorMin = Vector2.zero;
|
|||
|
|
rt.anchorMax = Vector2.one;
|
|||
|
|
rt.offsetMin = Vector2.zero;
|
|||
|
|
rt.offsetMax = Vector2.zero;
|
|||
|
|
|
|||
|
|
Image bg = autoBazarDetailObj.AddComponent<Image>();
|
|||
|
|
bg.color = new Color(0.07f, 0.08f, 0.10f, 1f);
|
|||
|
|
|
|||
|
|
// Верхний бар
|
|||
|
|
GameObject headerObj = new GameObject("DetailHeader");
|
|||
|
|
headerObj.transform.SetParent(autoBazarDetailObj.transform, false);
|
|||
|
|
RectTransform hRt = headerObj.AddComponent<RectTransform>();
|
|||
|
|
hRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
hRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
hRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
hRt.sizeDelta = new Vector2(0f, 44f);
|
|||
|
|
|
|||
|
|
GameObject backBtnObj = new GameObject("BackBtn");
|
|||
|
|
backBtnObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform bRt = backBtnObj.AddComponent<RectTransform>();
|
|||
|
|
bRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.anchorMax = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.pivot = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.anchoredPosition = new Vector2(14f, 0f);
|
|||
|
|
bRt.sizeDelta = new Vector2(100f, 32f);
|
|||
|
|
|
|||
|
|
Button backBtn = backBtnObj.AddComponent<Button>();
|
|||
|
|
backBtn.onClick.AddListener(() => SwitchView(PhoneView.AutoBazarFeed));
|
|||
|
|
|
|||
|
|
TextMeshProUGUI backText = backBtnObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
backText.fontSize = 14f;
|
|||
|
|
backText.fontStyle = FontStyles.Bold;
|
|||
|
|
backText.color = new Color(0.10f, 0.85f, 0.45f);
|
|||
|
|
backText.text = "<b>< К списку</b>";
|
|||
|
|
backText.alignment = TextAlignmentOptions.Left;
|
|||
|
|
|
|||
|
|
// Контейнер с прокруткой для страницы объявления
|
|||
|
|
GameObject scrollObj = new GameObject("DetailScrollView");
|
|||
|
|
scrollObj.transform.SetParent(autoBazarDetailObj.transform, false);
|
|||
|
|
RectTransform scrollRt = scrollObj.AddComponent<RectTransform>();
|
|||
|
|
scrollRt.anchorMin = Vector2.zero;
|
|||
|
|
scrollRt.anchorMax = Vector2.one;
|
|||
|
|
scrollRt.offsetMin = new Vector2(10f, 65f); // Отступ под нижнюю кнопку встречи
|
|||
|
|
scrollRt.offsetMax = new Vector2(-10f, -44f);
|
|||
|
|
|
|||
|
|
ScrollRect sr = scrollObj.AddComponent<ScrollRect>();
|
|||
|
|
sr.horizontal = false;
|
|||
|
|
sr.vertical = true;
|
|||
|
|
sr.scrollSensitivity = 25f;
|
|||
|
|
scrollObj.AddComponent<RectMask2D>();
|
|||
|
|
|
|||
|
|
GameObject contentObj = new GameObject("DetailContent");
|
|||
|
|
contentObj.transform.SetParent(scrollObj.transform, false);
|
|||
|
|
RectTransform dcRt = contentObj.AddComponent<RectTransform>();
|
|||
|
|
dcRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
dcRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
dcRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
dcRt.sizeDelta = new Vector2(0f, 540f);
|
|||
|
|
|
|||
|
|
sr.content = dcRt;
|
|||
|
|
|
|||
|
|
// 1. Большая фотография автомобиля
|
|||
|
|
GameObject photoObj = new GameObject("DetailPhoto");
|
|||
|
|
photoObj.transform.SetParent(contentObj.transform, false);
|
|||
|
|
RectTransform pRt = photoObj.AddComponent<RectTransform>();
|
|||
|
|
pRt.anchorMin = new Vector2(0.5f, 1f);
|
|||
|
|
pRt.anchorMax = new Vector2(0.5f, 1f);
|
|||
|
|
pRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
pRt.anchoredPosition = new Vector2(0f, -8f);
|
|||
|
|
pRt.sizeDelta = new Vector2(330f, 185f);
|
|||
|
|
|
|||
|
|
detailPhotoImage = photoObj.AddComponent<Image>();
|
|||
|
|
detailPhotoImage.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.12f, 0.14f, 0.18f), null, 0, 16);
|
|||
|
|
detailPhotoImage.preserveAspect = true;
|
|||
|
|
|
|||
|
|
// 2. Название и цена
|
|||
|
|
GameObject titleObj = new GameObject("DetailTitle");
|
|||
|
|
titleObj.transform.SetParent(contentObj.transform, false);
|
|||
|
|
RectTransform tRt = titleObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
tRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
tRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
tRt.anchoredPosition = new Vector2(4f, -202f);
|
|||
|
|
tRt.sizeDelta = new Vector2(320f, 26f);
|
|||
|
|
|
|||
|
|
detailTitleText = titleObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailTitleText.fontSize = 18f;
|
|||
|
|
detailTitleText.fontStyle = FontStyles.Bold;
|
|||
|
|
detailTitleText.color = Color.white;
|
|||
|
|
|
|||
|
|
GameObject priceObj = new GameObject("DetailPrice");
|
|||
|
|
priceObj.transform.SetParent(contentObj.transform, false);
|
|||
|
|
RectTransform prRt = priceObj.AddComponent<RectTransform>();
|
|||
|
|
prRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
prRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
prRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
prRt.anchoredPosition = new Vector2(4f, -228f);
|
|||
|
|
prRt.sizeDelta = new Vector2(320f, 30f);
|
|||
|
|
|
|||
|
|
detailPriceText = priceObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailPriceText.fontSize = 24f;
|
|||
|
|
detailPriceText.fontStyle = FontStyles.Bold;
|
|||
|
|
detailPriceText.color = new Color(0.10f, 0.85f, 0.45f);
|
|||
|
|
|
|||
|
|
// 3. Блок характеристик
|
|||
|
|
GameObject specsBox = new GameObject("SpecsBox");
|
|||
|
|
specsBox.transform.SetParent(contentObj.transform, false);
|
|||
|
|
RectTransform sbRt = specsBox.AddComponent<RectTransform>();
|
|||
|
|
sbRt.anchorMin = new Vector2(0.5f, 1f);
|
|||
|
|
sbRt.anchorMax = new Vector2(0.5f, 1f);
|
|||
|
|
sbRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
sbRt.anchoredPosition = new Vector2(0f, -266f);
|
|||
|
|
sbRt.sizeDelta = new Vector2(330f, 105f);
|
|||
|
|
|
|||
|
|
Image sbBg = specsBox.AddComponent<Image>();
|
|||
|
|
sbBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.11f, 0.13f, 0.17f), new Color(0.20f, 0.24f, 0.30f), 1f, 14);
|
|||
|
|
sbBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
GameObject specsTextObj = new GameObject("Text");
|
|||
|
|
specsTextObj.transform.SetParent(specsBox.transform, false);
|
|||
|
|
RectTransform stRt = specsTextObj.AddComponent<RectTransform>();
|
|||
|
|
stRt.anchorMin = Vector2.zero;
|
|||
|
|
stRt.anchorMax = Vector2.one;
|
|||
|
|
stRt.offsetMin = new Vector2(12f, 8f);
|
|||
|
|
stRt.offsetMax = new Vector2(-12f, -8f);
|
|||
|
|
|
|||
|
|
detailSpecsText = specsTextObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailSpecsText.fontSize = 12f;
|
|||
|
|
detailSpecsText.color = new Color(0.85f, 0.88f, 0.92f);
|
|||
|
|
detailSpecsText.lineSpacing = 15f;
|
|||
|
|
|
|||
|
|
// 4. Карточка продавца
|
|||
|
|
GameObject sellerBox = new GameObject("SellerBox");
|
|||
|
|
sellerBox.transform.SetParent(contentObj.transform, false);
|
|||
|
|
RectTransform selRt = sellerBox.AddComponent<RectTransform>();
|
|||
|
|
selRt.anchorMin = new Vector2(0.5f, 1f);
|
|||
|
|
selRt.anchorMax = new Vector2(0.5f, 1f);
|
|||
|
|
selRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
selRt.anchoredPosition = new Vector2(0f, -380f);
|
|||
|
|
selRt.sizeDelta = new Vector2(330f, 140f);
|
|||
|
|
|
|||
|
|
Image selBg = sellerBox.AddComponent<Image>();
|
|||
|
|
selBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.12f, 0.14f, 0.18f), new Color(0.22f, 0.26f, 0.32f), 1f, 14);
|
|||
|
|
selBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
// Имя продавца
|
|||
|
|
GameObject sNameObj = new GameObject("SellerName");
|
|||
|
|
sNameObj.transform.SetParent(sellerBox.transform, false);
|
|||
|
|
RectTransform snRt = sNameObj.AddComponent<RectTransform>();
|
|||
|
|
snRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
snRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
snRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
snRt.anchoredPosition = new Vector2(14f, -10f);
|
|||
|
|
snRt.sizeDelta = new Vector2(300f, 20f);
|
|||
|
|
|
|||
|
|
detailSellerNameText = sNameObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailSellerNameText.fontSize = 14f;
|
|||
|
|
detailSellerNameText.fontStyle = FontStyles.Bold;
|
|||
|
|
detailSellerNameText.color = Color.white;
|
|||
|
|
|
|||
|
|
// Рейтинг
|
|||
|
|
GameObject sRateObj = new GameObject("SellerRating");
|
|||
|
|
sRateObj.transform.SetParent(sellerBox.transform, false);
|
|||
|
|
RectTransform srRt = sRateObj.AddComponent<RectTransform>();
|
|||
|
|
srRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
srRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
srRt.pivot = new Vector2(0f, 1f);
|
|||
|
|
srRt.anchoredPosition = new Vector2(14f, -28f);
|
|||
|
|
srRt.sizeDelta = new Vector2(300f, 18f);
|
|||
|
|
|
|||
|
|
detailSellerRatingText = sRateObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailSellerRatingText.fontSize = 11f;
|
|||
|
|
detailSellerRatingText.color = new Color(1f, 0.8f, 0.3f);
|
|||
|
|
|
|||
|
|
// Описание продавца (цитата)
|
|||
|
|
GameObject sDescObj = new GameObject("SellerDesc");
|
|||
|
|
sDescObj.transform.SetParent(sellerBox.transform, false);
|
|||
|
|
RectTransform sdRt = sDescObj.AddComponent<RectTransform>();
|
|||
|
|
sdRt.anchorMin = new Vector2(0f, 0f);
|
|||
|
|
sdRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
sdRt.offsetMin = new Vector2(14f, 10f);
|
|||
|
|
sdRt.offsetMax = new Vector2(-14f, -48f);
|
|||
|
|
|
|||
|
|
detailSellerDescText = sDescObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailSellerDescText.fontSize = 11f;
|
|||
|
|
detailSellerDescText.color = new Color(0.8f, 0.85f, 0.9f);
|
|||
|
|
detailSellerDescText.lineSpacing = 12f;
|
|||
|
|
|
|||
|
|
// 5. Нижняя закрепленная кнопка "Договориться о встрече"
|
|||
|
|
GameObject arrangeBtnObj = new GameObject("ArrangeMeetingButton");
|
|||
|
|
arrangeBtnObj.transform.SetParent(autoBazarDetailObj.transform, false);
|
|||
|
|
RectTransform abRt = arrangeBtnObj.AddComponent<RectTransform>();
|
|||
|
|
abRt.anchorMin = new Vector2(0.5f, 0f);
|
|||
|
|
abRt.anchorMax = new Vector2(0.5f, 0f);
|
|||
|
|
abRt.pivot = new Vector2(0.5f, 0f);
|
|||
|
|
abRt.anchoredPosition = new Vector2(0f, 10f);
|
|||
|
|
abRt.sizeDelta = new Vector2(330f, 48f);
|
|||
|
|
|
|||
|
|
Image abBg = arrangeBtnObj.AddComponent<Image>();
|
|||
|
|
abBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.06f, 0.75f, 0.42f), new Color(0.2f, 1f, 0.6f), 1f, 16);
|
|||
|
|
abBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
detailArrangeBtn = arrangeBtnObj.AddComponent<Button>();
|
|||
|
|
detailArrangeBtn.onClick.AddListener(OnArrangeMeetingClicked);
|
|||
|
|
|
|||
|
|
GameObject abTextObj = new GameObject("Text");
|
|||
|
|
abTextObj.transform.SetParent(arrangeBtnObj.transform, false);
|
|||
|
|
RectTransform abtRt = abTextObj.AddComponent<RectTransform>();
|
|||
|
|
abtRt.anchorMin = Vector2.zero;
|
|||
|
|
abtRt.anchorMax = Vector2.one;
|
|||
|
|
|
|||
|
|
detailArrangeBtnText = abTextObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
detailArrangeBtnText.fontSize = 14f;
|
|||
|
|
detailArrangeBtnText.fontStyle = FontStyles.Bold;
|
|||
|
|
detailArrangeBtnText.color = Color.white;
|
|||
|
|
detailArrangeBtnText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
detailArrangeBtnText.text = "🤝 Договориться о встрече";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// ЭКРАН 3: GPS НАВИГАТОР В ТЕЛЕФОНЕ
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildGpsAppScreen(GameObject parent)
|
|||
|
|
{
|
|||
|
|
gpsAppObj = new GameObject("GpsAppScreen");
|
|||
|
|
gpsAppObj.transform.SetParent(parent.transform, false);
|
|||
|
|
RectTransform rt = gpsAppObj.AddComponent<RectTransform>();
|
|||
|
|
rt.anchorMin = Vector2.zero;
|
|||
|
|
rt.anchorMax = Vector2.one;
|
|||
|
|
rt.offsetMin = Vector2.zero;
|
|||
|
|
rt.offsetMax = Vector2.zero;
|
|||
|
|
|
|||
|
|
Image bg = gpsAppObj.AddComponent<Image>();
|
|||
|
|
bg.color = new Color(0.06f, 0.08f, 0.12f, 1f);
|
|||
|
|
|
|||
|
|
// Верхний бар
|
|||
|
|
GameObject headerObj = new GameObject("GpsHeader");
|
|||
|
|
headerObj.transform.SetParent(gpsAppObj.transform, false);
|
|||
|
|
RectTransform hRt = headerObj.AddComponent<RectTransform>();
|
|||
|
|
hRt.anchorMin = new Vector2(0f, 1f);
|
|||
|
|
hRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
hRt.pivot = new Vector2(0.5f, 1f);
|
|||
|
|
hRt.sizeDelta = new Vector2(0f, 50f);
|
|||
|
|
|
|||
|
|
GameObject backBtnObj = new GameObject("BackBtn");
|
|||
|
|
backBtnObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform bRt = backBtnObj.AddComponent<RectTransform>();
|
|||
|
|
bRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.anchorMax = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.pivot = new Vector2(0f, 0.5f);
|
|||
|
|
bRt.anchoredPosition = new Vector2(14f, 0f);
|
|||
|
|
bRt.sizeDelta = new Vector2(80f, 32f);
|
|||
|
|
|
|||
|
|
Button backBtn = backBtnObj.AddComponent<Button>();
|
|||
|
|
backBtn.onClick.AddListener(() => SwitchView(PhoneView.Home));
|
|||
|
|
|
|||
|
|
TextMeshProUGUI backText = backBtnObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
backText.fontSize = 16f;
|
|||
|
|
backText.fontStyle = FontStyles.Bold;
|
|||
|
|
backText.color = new Color(0.2f, 0.6f, 1f);
|
|||
|
|
backText.text = "<b>< Меню</b>";
|
|||
|
|
backText.alignment = TextAlignmentOptions.Left;
|
|||
|
|
|
|||
|
|
GameObject titleObj = new GameObject("Title");
|
|||
|
|
titleObj.transform.SetParent(headerObj.transform, false);
|
|||
|
|
RectTransform tRt = titleObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
tRt.anchorMax = new Vector2(1f, 0.5f);
|
|||
|
|
tRt.offsetMin = new Vector2(90f, 0f);
|
|||
|
|
tRt.offsetMax = new Vector2(-14f, 0f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI title = titleObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
title.fontSize = 16f;
|
|||
|
|
title.fontStyle = FontStyles.Bold;
|
|||
|
|
title.color = Color.white;
|
|||
|
|
title.text = "<b>GPS Навигатор</b>";
|
|||
|
|
|
|||
|
|
// Карточка маршрута
|
|||
|
|
GameObject cardObj = new GameObject("GpsCard");
|
|||
|
|
cardObj.transform.SetParent(gpsAppObj.transform, false);
|
|||
|
|
RectTransform cRt = cardObj.AddComponent<RectTransform>();
|
|||
|
|
cRt.anchorMin = new Vector2(0.5f, 0.5f);
|
|||
|
|
cRt.anchorMax = new Vector2(0.5f, 0.5f);
|
|||
|
|
cRt.pivot = new Vector2(0.5f, 0.5f);
|
|||
|
|
cRt.sizeDelta = new Vector2(320f, 240f);
|
|||
|
|
|
|||
|
|
Image cBg = cardObj.AddComponent<Image>();
|
|||
|
|
cBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.10f, 0.14f, 0.20f), new Color(0.20f, 0.35f, 0.60f), 1.5f, 18);
|
|||
|
|
cBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
// Статус
|
|||
|
|
GameObject statObj = new GameObject("StatusText");
|
|||
|
|
statObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform stRt = statObj.AddComponent<RectTransform>();
|
|||
|
|
stRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
stRt.anchorMax = new Vector2(1f, 1f);
|
|||
|
|
stRt.offsetMin = new Vector2(20f, 0f);
|
|||
|
|
stRt.offsetMax = new Vector2(-20f, -20f);
|
|||
|
|
|
|||
|
|
gpsStatusText = statObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
gpsStatusText.fontSize = 13f;
|
|||
|
|
gpsStatusText.color = Color.white;
|
|||
|
|
gpsStatusText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
|
|||
|
|
// Дистанция
|
|||
|
|
GameObject distObj = new GameObject("DistanceText");
|
|||
|
|
distObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform dtRt = distObj.AddComponent<RectTransform>();
|
|||
|
|
dtRt.anchorMin = new Vector2(0f, 0f);
|
|||
|
|
dtRt.anchorMax = new Vector2(1f, 0.5f);
|
|||
|
|
dtRt.offsetMin = new Vector2(20f, 60f);
|
|||
|
|
dtRt.offsetMax = new Vector2(-20f, 0f);
|
|||
|
|
|
|||
|
|
gpsDistanceText = distObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
gpsDistanceText.fontSize = 15f;
|
|||
|
|
gpsDistanceText.fontStyle = FontStyles.Bold;
|
|||
|
|
gpsDistanceText.color = new Color(0.10f, 0.85f, 0.45f);
|
|||
|
|
gpsDistanceText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
|
|||
|
|
// Кнопка сброса маршрута
|
|||
|
|
GameObject cancelBtnObj = new GameObject("CancelMeetingBtn");
|
|||
|
|
cancelBtnObj.transform.SetParent(cardObj.transform, false);
|
|||
|
|
RectTransform cbRt = cancelBtnObj.AddComponent<RectTransform>();
|
|||
|
|
cbRt.anchorMin = new Vector2(0.5f, 0f);
|
|||
|
|
cbRt.anchorMax = new Vector2(0.5f, 0f);
|
|||
|
|
cbRt.pivot = new Vector2(0.5f, 0f);
|
|||
|
|
cbRt.anchoredPosition = new Vector2(0f, 15f);
|
|||
|
|
cbRt.sizeDelta = new Vector2(220f, 36f);
|
|||
|
|
|
|||
|
|
Image cbBg = cancelBtnObj.AddComponent<Image>();
|
|||
|
|
cbBg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.6f, 0.15f, 0.18f), null, 0, 12);
|
|||
|
|
cbBg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button cb = cancelBtnObj.AddComponent<Button>();
|
|||
|
|
cb.onClick.AddListener(() =>
|
|||
|
|
{
|
|||
|
|
if (marketManager != null)
|
|||
|
|
marketManager.ClearActiveMeeting();
|
|||
|
|
UpdateGpsViewData();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
GameObject cbtObj = new GameObject("Text");
|
|||
|
|
cbtObj.transform.SetParent(cancelBtnObj.transform, false);
|
|||
|
|
RectTransform cbtRt = cbtObj.AddComponent<RectTransform>();
|
|||
|
|
cbtRt.anchorMin = Vector2.zero;
|
|||
|
|
cbtRt.anchorMax = Vector2.one;
|
|||
|
|
|
|||
|
|
TextMeshProUGUI cbt = cbtObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
cbt.fontSize = 12f;
|
|||
|
|
cbt.color = Color.white;
|
|||
|
|
cbt.alignment = TextAlignmentOptions.Center;
|
|||
|
|
cbt.text = "Сбросить маршрут встречи";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// =========================================================================
|
|||
|
|
// HUD МИНИ-КНОПКА ТЕЛЕФОНА В УГЛУ ЭКРАНА
|
|||
|
|
// =========================================================================
|
|||
|
|
|
|||
|
|
private void BuildHudPhoneButton()
|
|||
|
|
{
|
|||
|
|
Canvas hudCanvas = FindAnyObjectByType<Canvas>();
|
|||
|
|
if (hudCanvas == null) return;
|
|||
|
|
|
|||
|
|
hudPhoneButtonObj = new GameObject("HUD_PhoneButton");
|
|||
|
|
hudPhoneButtonObj.transform.SetParent(hudCanvas.transform, false);
|
|||
|
|
RectTransform rt = hudPhoneButtonObj.AddComponent<RectTransform>();
|
|||
|
|
rt.anchorMin = new Vector2(1f, 0f);
|
|||
|
|
rt.anchorMax = new Vector2(1f, 0f);
|
|||
|
|
rt.pivot = new Vector2(1f, 0f);
|
|||
|
|
rt.anchoredPosition = new Vector2(-30f, 30f);
|
|||
|
|
rt.sizeDelta = new Vector2(230f, 46f);
|
|||
|
|
|
|||
|
|
Image bg = hudPhoneButtonObj.AddComponent<Image>();
|
|||
|
|
bg.sprite = ProceduralUISprites.GetSlicedRoundedRect(new Color(0.08f, 0.10f, 0.14f, 0.88f), new Color(0.12f, 0.75f, 0.45f, 0.7f), 1.5f, 16);
|
|||
|
|
bg.type = Image.Type.Sliced;
|
|||
|
|
|
|||
|
|
Button btn = hudPhoneButtonObj.AddComponent<Button>();
|
|||
|
|
btn.onClick.AddListener(() => TogglePhone(true));
|
|||
|
|
|
|||
|
|
// Иконка
|
|||
|
|
GameObject iconObj = new GameObject("Icon");
|
|||
|
|
iconObj.transform.SetParent(hudPhoneButtonObj.transform, false);
|
|||
|
|
RectTransform iRt = iconObj.AddComponent<RectTransform>();
|
|||
|
|
iRt.anchorMin = new Vector2(0f, 0.5f);
|
|||
|
|
iRt.anchorMax = new Vector2(0f, 0.5f);
|
|||
|
|
iRt.pivot = new Vector2(0f, 0.5f);
|
|||
|
|
iRt.anchoredPosition = new Vector2(12f, 0f);
|
|||
|
|
iRt.sizeDelta = new Vector2(24f, 24f);
|
|||
|
|
|
|||
|
|
Image iconImg = iconObj.AddComponent<Image>();
|
|||
|
|
iconImg.sprite = ProceduralUISprites.GetCarIcon(64, new Color(0.1f, 0.95f, 0.55f));
|
|||
|
|
iconImg.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Текст подсказки
|
|||
|
|
GameObject textObj = new GameObject("Text");
|
|||
|
|
textObj.transform.SetParent(hudPhoneButtonObj.transform, false);
|
|||
|
|
RectTransform tRt = textObj.AddComponent<RectTransform>();
|
|||
|
|
tRt.anchorMin = Vector2.zero;
|
|||
|
|
tRt.anchorMax = Vector2.one;
|
|||
|
|
tRt.offsetMin = new Vector2(42f, 0f);
|
|||
|
|
tRt.offsetMax = new Vector2(-36f, 0f);
|
|||
|
|
|
|||
|
|
TextMeshProUGUI t = textObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
t.fontSize = 13f;
|
|||
|
|
t.fontStyle = FontStyles.Bold;
|
|||
|
|
t.color = Color.white;
|
|||
|
|
t.alignment = TextAlignmentOptions.Left;
|
|||
|
|
t.text = "<b>[P]</b> АвтоБазар";
|
|||
|
|
t.raycastTarget = false;
|
|||
|
|
|
|||
|
|
// Круглый бейдж счетчика объявлений
|
|||
|
|
GameObject bObj = new GameObject("Badge");
|
|||
|
|
bObj.transform.SetParent(hudPhoneButtonObj.transform, false);
|
|||
|
|
RectTransform bRt = bObj.AddComponent<RectTransform>();
|
|||
|
|
bRt.anchorMin = new Vector2(1f, 0.5f);
|
|||
|
|
bRt.anchorMax = new Vector2(1f, 0.5f);
|
|||
|
|
bRt.pivot = new Vector2(1f, 0.5f);
|
|||
|
|
bRt.anchoredPosition = new Vector2(-10f, 0f);
|
|||
|
|
bRt.sizeDelta = new Vector2(24f, 24f);
|
|||
|
|
|
|||
|
|
Image bImg = bObj.AddComponent<Image>();
|
|||
|
|
bImg.sprite = ProceduralUISprites.GetCircle(24, new Color(0.06f, 0.75f, 0.42f));
|
|||
|
|
|
|||
|
|
GameObject btObj = new GameObject("BadgeText");
|
|||
|
|
btObj.transform.SetParent(bObj.transform, false);
|
|||
|
|
RectTransform btRt = btObj.AddComponent<RectTransform>();
|
|||
|
|
btRt.anchorMin = Vector2.zero;
|
|||
|
|
btRt.anchorMax = Vector2.one;
|
|||
|
|
|
|||
|
|
hudBadgeText = btObj.AddComponent<TextMeshProUGUI>();
|
|||
|
|
hudBadgeText.fontSize = 12f;
|
|||
|
|
hudBadgeText.fontStyle = FontStyles.Bold;
|
|||
|
|
hudBadgeText.color = Color.white;
|
|||
|
|
hudBadgeText.alignment = TextAlignmentOptions.Center;
|
|||
|
|
hudBadgeText.text = "6";
|
|||
|
|
hudBadgeText.raycastTarget = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string FormatDrive(DriveType dt)
|
|||
|
|
{
|
|||
|
|
return dt switch
|
|||
|
|
{
|
|||
|
|
DriveType.FWD => "Передний (FWD)",
|
|||
|
|
DriveType.RWD => "Задний (RWD)",
|
|||
|
|
DriveType.AWD => "Полный (AWD)",
|
|||
|
|
_ => dt.ToString()
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string FormatDriveShort(DriveType dt)
|
|||
|
|
{
|
|||
|
|
return dt switch
|
|||
|
|
{
|
|||
|
|
DriveType.FWD => "FWD",
|
|||
|
|
DriveType.RWD => "RWD",
|
|||
|
|
DriveType.AWD => "AWD",
|
|||
|
|
_ => dt.ToString()
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|