This commit is contained in:
CortexCore
2024-11-20 11:36:36 +08:00
parent 99253854e8
commit 6cc53eb9dc
383 changed files with 21233 additions and 112159 deletions

View File

@@ -16,8 +16,11 @@ using Microsoft.Extensions.Hosting.Unity;
using Microsoft.Extensions.Logging;
using Net.Like.Xue.Tokyo.GameService;
using Net.Like.Xue.Tokyo.UX;
using Net.Project.B.Dialogue;
using Net.Project.B.Health;
using Net.Project.B.Interaction;
using Net.Project.B.Quest;
using Net.Project.B.UX;
using Net.Project.B.WorldNode;
using Project.B.Animation;
using Project.B.CharacterController;
@@ -42,7 +45,7 @@ namespace Net.Like.Xue.Tokyo
var source = new CancellationTokenSource();
destroyCancellationToken.Register(source.Cancel);
var serviceCollection = new ServiceCollection();
var serviceCollection = BITApp.ServiceCollection= new ServiceCollection();
serviceCollection.AddSingleton<IServiceCollection>(serviceCollection);
@@ -107,11 +110,20 @@ namespace Net.Like.Xue.Tokyo
serviceCollection.AddSingleton<UXMenu>();
serviceCollection.AddSingleton<UXConsole>();
serviceCollection.AddSingleton<UXDialogue>();
//生成玩家
serviceCollection.AddSingleton<GameSpawnPlayerService>();
//任务
serviceCollection.AddSingleton<IQuestService, QuestService>();
//对话
serviceCollection.AddSingleton<IDialogueService, DialogueService>();
serviceCollection.AddSingleton<DialogueMiddlewareNodeCanvasDialogueTree>();
//获取服务提供者
var serviceProvider = serviceCollection.BuildServiceProvider();
await using var serviceProvider = BITApp.ServiceProvider = serviceCollection.BuildServiceProvider();
if (serviceProvider is IDisposable disposable)
{
@@ -155,6 +167,10 @@ namespace Net.Like.Xue.Tokyo
serviceProvider.GetRequiredService<WorldHighlightService>();
serviceProvider.GetRequiredService<UXConsole>();
serviceProvider.GetRequiredService<DialogueMiddlewareNodeCanvasDialogueTree>();
serviceProvider.GetRequiredService<UXDialogue>().Initialize(serviceProvider.GetRequiredService<UXHud>());
YooAssets.LoadAssetSync("MyShaderVariants").AssetObject.As<ShaderVariantCollection>().WarmUp();

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using NodeCanvas.Framework;
using Pinwheel.Jupiter;
using UnityEngine;
namespace Net.Like.Xue.Tokyo
{
public class SetDayTime:MonoBehaviour
{
private JDayNightCycle _cycle;
private void Start()
{
_cycle = GetComponent<JDayNightCycle>();
Data.AddListener<float>("Time",OnSetTime);
destroyCancellationToken.Register(Dispose);
}
private void Dispose()
{
Data.RemoveListender<float>("Time",OnSetTime);
}
private void Update()
{
Data.Set("Time", _cycle.Time);
}
private void OnSetTime(float obj)
{
_cycle.Time = obj;
}
}
}

View File

@@ -9,7 +9,8 @@
"GUID:c469c0b0902774247810f42d61a18bd7",
"GUID:12c795c5ebfb7b245a0399e28b4015e8",
"GUID:e527b3ce3106f974585be5134b6200e9",
"GUID:d750d221812bb1d48baff92e6ef73e28"
"GUID:d750d221812bb1d48baff92e6ef73e28",
"GUID:b93d14745ae2c064fb21541ca62ad9de"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -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;
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Animancer;
@@ -58,6 +59,8 @@ namespace Net.Like.Xue.Tokyo
_waitPlayerStart.TrySetResult(infoPlayerStart);
}
public IReadOnlyDictionary<int, IEntity> Entities => _entities.ToDictionary(x => x.entity.Id, x => x.entity);
public async UniTask<IEntity> CreateAsync(string addressablePath)
{
await UniTask.SwitchToMainThread();