1
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
"GUID:c469c0b0902774247810f42d61a18bd7",
|
||||
"GUID:12c795c5ebfb7b245a0399e28b4015e8",
|
||||
"GUID:e527b3ce3106f974585be5134b6200e9",
|
||||
"GUID:d750d221812bb1d48baff92e6ef73e28"
|
||||
"GUID:d750d221812bb1d48baff92e6ef73e28",
|
||||
"GUID:b93d14745ae2c064fb21541ca62ad9de"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -2,10 +2,12 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Mod;
|
||||
using BITKit.UX;
|
||||
using BITKit.WorldNode;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Net.Project.B.Interaction;
|
||||
using Net.Project.B.Quest;
|
||||
using Project.B.Map;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@@ -18,15 +20,29 @@ namespace Net.Like.Xue.Tokyo.UX
|
||||
private readonly IGameMapService _gameMapService;
|
||||
private readonly IWorldInteractionService _interactionService;
|
||||
private readonly WorldInfoNodeService _worldInfoNodeService;
|
||||
public UXHud(IUXService uxService, IGameMapService gameMapService, IWorldInteractionService interactionService, WorldInfoNodeService worldInfoNodeService) : base(uxService)
|
||||
private readonly IQuestService _questService;
|
||||
public UXHud(IUXService uxService, IGameMapService gameMapService, IWorldInteractionService interactionService, WorldInfoNodeService worldInfoNodeService, IQuestService questService) : base(uxService)
|
||||
{
|
||||
_gameMapService = gameMapService;
|
||||
_interactionService = interactionService;
|
||||
_worldInfoNodeService = worldInfoNodeService;
|
||||
_questService = questService;
|
||||
|
||||
_gameMapService.OnMapChanged += OnMapChanged;
|
||||
|
||||
_interactionService.OnInteraction += OnInteraction;
|
||||
|
||||
|
||||
Data.AddListener<float>("Time",x=>
|
||||
{
|
||||
_timeSlider?.SetValueWithoutNotify(x);
|
||||
});
|
||||
|
||||
_questService.OnQuestCreatedOrUpdated +=(x,y,z)=>_questQueue.Enqueue(new(x,y,z));
|
||||
foreach (var (index,quest) in _questService.Quests)
|
||||
{
|
||||
_questQueue.Enqueue(new(quest,QuestState.Inactive,quest.CurrentState));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInteraction(object arg1, IWorldInteractable arg2, WorldInteractionProcess arg3, object arg4)
|
||||
@@ -58,9 +74,19 @@ namespace Net.Like.Xue.Tokyo.UX
|
||||
private VisualElement _miniPlayer;
|
||||
[UXBindPath("interaction-tips")]
|
||||
private Label _interactionTips;
|
||||
[UXBindPath("time-slider")]
|
||||
private Slider _timeSlider;
|
||||
[UXBindPath("quest-container")]
|
||||
private VisualElement _questContainer;
|
||||
|
||||
private Camera _minimapCamera;
|
||||
private Camera _mainCamera;
|
||||
|
||||
private VisualTreeAsset _questTemplate;
|
||||
|
||||
private readonly Queue<(IQuestData questData, QuestState oldQuestState, QuestState newQuestState)> _questQueue =
|
||||
new();
|
||||
|
||||
public override async UniTask EntryAsync()
|
||||
{
|
||||
await base.EntryAsync();
|
||||
@@ -72,6 +98,13 @@ namespace Net.Like.Xue.Tokyo.UX
|
||||
{
|
||||
UXService.Entry<UXMap>();
|
||||
});
|
||||
|
||||
_timeSlider.RegisterValueChangedCallback(x => { Data.Set("Time", x.newValue); });
|
||||
_questContainer.Clear();
|
||||
|
||||
_questTemplate =await ModService.LoadAsset<VisualTreeAsset>("ux_quest_template");
|
||||
|
||||
_timeSlider.value = Data.Get<float>("Time");
|
||||
}
|
||||
|
||||
public override void OnTick(float deltaTime)
|
||||
@@ -94,6 +127,17 @@ namespace Net.Like.Xue.Tokyo.UX
|
||||
|
||||
_miniPlayer.style.left = _minimapContainer.layout.width * point.x - _miniPlayer.layout.width / 2;
|
||||
_miniPlayer.style.top = _minimapContainer.layout.height * (1-point.y) - _miniPlayer.layout.height / 2;
|
||||
|
||||
|
||||
if (_questContainer is not null && _questTemplate!=null)
|
||||
{
|
||||
while (_questQueue.TryDequeue(out var quest))
|
||||
{
|
||||
var visualElement = _questContainer.Create(_questTemplate);
|
||||
visualElement.Get<Label>(0).text = quest.questData.Name;
|
||||
visualElement.Get<Label>(1).text = quest.questData.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user