This commit is contained in:
CortexCore 2025-04-28 15:10:49 +08:00
parent 3f9d9f19ce
commit 4c2534a6e9
11 changed files with 72 additions and 5 deletions

View File

@ -25,10 +25,21 @@ namespace Net.Project.B.Dialogue
/// </summary>
public event Func<IDialogueData, UniTask> OnDialogueStart;
public event Action<IDialogueData> OnDynamicDialogueStart;
/// <summary>
/// 动态对话
/// </summary>
public event Func<IDialogueData, UniTask<string>> OnDynamicDialogueStartAsync;
/// <summary>
/// 对话结束
/// </summary>
public event Action<IDialogueData> OnDialogueEnd;
/// <summary>
/// 动态对话结束
/// </summary>
public event Action<IDialogueData,string> OnDynamicDialogueEnd;
/// <summary>
/// 对话选择
@ -48,6 +59,8 @@ namespace Net.Project.B.Dialogue
UniTask CreateDialogue(IDialogueData dialogueData);
UniTask<int> CreateDialogue(IDialogueData dialogueData, IReadOnlyCollection<IDialogueChoice> dialogueChoices);
UniTask<string> CreateDynamicDialogue(IDialogueData dialogueData);
}
public class DialogueService : IDialogueService
@ -55,7 +68,10 @@ namespace Net.Project.B.Dialogue
public IReadOnlyDictionary<int, IDialogueData> Dialogues => _dialogues;
public event Func<IDialogueData, UniTask> OnDialogueStart;
public event Action<IDialogueData> OnDynamicDialogueStart;
public event Func<IDialogueData, UniTask<string>> OnDynamicDialogueStartAsync;
public event Action<IDialogueData> OnDialogueEnd;
public event Action<IDialogueData, string> OnDynamicDialogueEnd;
public event Func<IDialogueData, IReadOnlyCollection<IDialogueChoice>, UniTask<int>> OnDialogueChoose;
public event Action<IDialogueData, IDialogueChoice> OnDialogueChose;
public async UniTask CreateDialogue(IDialogueData dialogueData)
@ -105,6 +121,19 @@ namespace Net.Project.B.Dialogue
return index;
}
public async UniTask<string> CreateDynamicDialogue(IDialogueData dialogueData)
{
if (OnDynamicDialogueStartAsync is null)throw new Exception("OnDynamicDialogueStartAsync is not null");
OnDialogueStart?.Invoke(dialogueData);
var result = await OnDynamicDialogueStartAsync.Invoke(dialogueData);
OnDynamicDialogueEnd?.Invoke(dialogueData,result);
return result;
}
private readonly ConcurrentDictionary<int, IDialogueData> _dialogues = new();
}
}

View File

@ -21,6 +21,7 @@ namespace Net.Project.B.Health
/// </summary>
public interface IKnockedService
{
public bool Enabled { get; set; }
/// <summary>
/// 击倒列表
/// </summary>
@ -56,6 +57,8 @@ namespace Net.Project.B.Health
private int OnHealthPlus(int id, int oldHp, int plus, object sendor)
{
if (Enabled is false) return plus;
if (_entitiesService.TryGetEntity(id, out var entity) is false) return plus;
if (entity.ServiceProvider.GetService<IKnockedComponent>() is null) return plus;
@ -82,7 +85,8 @@ namespace Net.Project.B.Health
_knocked.Add(id);
_onKnocked?.Invoke(id, true);
// _logger.LogInformation($"Entity {id} 被击倒了");
return oldHp-1;
//return 0;
return -Math.Abs(oldHp-1);
}
private void OnHealthChanged(int arg1, int arg2, int arg3, object arg4)
@ -101,6 +105,7 @@ namespace Net.Project.B.Health
private static readonly ConcurrentDictionary<int,int> _knockedHealth = new();
private static event Action<int, bool> _onKnocked;
private static event Action<int, int, int> _onKnockedHealthChanged;
public bool Enabled { get; set; } = true;
public HashSet<int> Knocked=> _knocked;
public IReadOnlyDictionary<int, int> KnockedHealth => _knockedHealth;
public event Action<int, bool> OnKnocked

View File

@ -2,6 +2,7 @@
"name": "Com.Project.B.Interaction",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d750d221812bb1d48baff92e6ef73e28"
],
"includePlatforms": [],

View File

@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using BITKit;
namespace Net.Project.B.Interaction
{
public class DynamicInteractable:IWorldInteractable
{
public bool Enabled => Allow.Allow;
public readonly ValidHandle Allow=new();
public object WorldObject { get; set; }
public int Id { get; set; }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5cb35ec740d0fb4483ab848af4a0f19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -21,7 +21,7 @@ namespace Net.Project.B.Interaction
/// </summary>
public interface IWorldInteractable
{
public IWorldInteractionType InteractionType { get; }
public bool Enabled { get; }
public object WorldObject { get; set; }
public int Id { get; set; }
}

View File

@ -10,7 +10,7 @@ namespace Net.Project.B.Interaction
[Serializable]
public class WorldInteractable : IWorldInteractable,IWorldNode
{
public IWorldInteractionType InteractionType => null;
public bool Enabled { get; set; } = true;
public object WorldObject { get; set; }
public int Id { get; set; }
}

View File

@ -43,6 +43,6 @@ namespace Net.Project.B.PDA.App
public struct Quest:IApp
{
public string PackageName => "com.bndroid.quest";
public string AppName => "人物";
public string AppName => "任务";
}
}

View File

@ -8,5 +8,6 @@ namespace Project.B.Player
public T CancelKey { get; }
public T InventoryKey { get; }
public T ConfirmKey { get; }
public T ChatKey { get; }
}
}

View File

@ -20,7 +20,6 @@ namespace Net.Project.B.UX
event Func<string, string> OnSubtitle;
public string[] SubtitleLanguages { get; set; }
}
public interface IUXInventory : IUXPanel
{
public ItemQuality AutoInspect { get; set; }
@ -53,4 +52,5 @@ namespace Net.Project.B.UX
{
public IReadOnlyCollection<IBuff> SurvivalBuffs { get; set; }
}
public interface IUXChat:IUXPanel{}
}

View File

@ -14,10 +14,15 @@ namespace Net.Project.B.WorldNode
[SerializeField] private float speed;
[SerializeField] private Transform spline;
[SerializeField] private Vector3 offset;
[SerializeField] private Transform frontWheel;
[SerializeField] private Transform backWheel;
public Rigidbody Subway => subway;
public float Speed => speed;
public Transform Spline => spline;
public Vector3 Offset => offset;
public Transform FrontWheel => frontWheel;
public Transform BackWheel => backWheel;
}
}
#endif