mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
提交Cue案例
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using GAS.General;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Cue 处理
|
||||
/// </summary>
|
||||
public abstract partial class AbilitySystemComponent : IAbilitySystemComponent, IPool
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// AbilitySpec 唯一Id
|
||||
/// </summary>
|
||||
private Dictionary<AbilitySpec, int> AbilitySpecId = new();
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了持续型Cue的添加
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueAssetLocation">Cue资源地址</param>
|
||||
/// <param name="durationTime">持续时间</param>
|
||||
/// <returns></returns>
|
||||
public int OnCueAdd(AbilitySpec abilitySpec, string cueAssetLocation, int durationTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了持续型Cue的移除
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueClipIndex"></param>
|
||||
public void OnCueRemove(AbilitySpec abilitySpec, int cueClipIndex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了瞬时Cue的触发
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueAssetLocations"></param>
|
||||
public void OnCueExecute(AbilitySpec abilitySpec, string[] cueAssetLocations)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd84ebd1383e4e009578ebd2daae3200
|
||||
timeCreated: 1729704061
|
@@ -341,6 +341,29 @@ namespace GAS.Runtime
|
||||
/// <param name="geSpec"></param>
|
||||
public abstract void OnGERelease(GameplayEffectSpec geSpec);
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了持续型Cue的添加
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueAssetLocation">Cue资源地址</param>
|
||||
/// <param name="durationTime">持续时间</param>
|
||||
/// <returns></returns>
|
||||
public abstract int OnCueAdd(AbilitySpec abilitySpec, string cueAssetLocation, int durationTime);
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了持续型Cue的移除
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueClipIndex"></param>
|
||||
public abstract void OnCueRemove(AbilitySpec abilitySpec, int cueClipIndex);
|
||||
|
||||
/// <summary>
|
||||
/// Ability的Timeline轨道触发了瞬时Cue的触发
|
||||
/// </summary>
|
||||
/// <param name="abilitySpec"></param>
|
||||
/// <param name="cueAssetLocations"></param>
|
||||
public abstract void OnCueExecute(AbilitySpec abilitySpec, string[] cueAssetLocations);
|
||||
|
||||
/// <summary>
|
||||
/// Ability结束激活
|
||||
/// </summary>
|
||||
|
@@ -30,6 +30,15 @@ namespace GAS.Runtime
|
||||
return durationalCue;
|
||||
}
|
||||
|
||||
public GameplayCueDurationalSpec ApplyFrom(params object[] customArguments)
|
||||
{
|
||||
var durationalCue = CreateSpec(new GameplayCueParameters
|
||||
{
|
||||
customArguments = customArguments
|
||||
});
|
||||
return durationalCue;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public virtual void OnEditorPreview(UnityEngine.GameObject previewObject, int frameIndex, int startFrame, int endFrame)
|
||||
{
|
||||
@@ -49,6 +58,7 @@ namespace GAS.Runtime
|
||||
public abstract void OnGameplayEffectActivate();
|
||||
public abstract void OnGameplayEffectDeactivate();
|
||||
public abstract void OnTick(int frame,int startFrame,int endFrame);
|
||||
public abstract void OnTick(int deltaTime);
|
||||
}
|
||||
|
||||
public abstract class GameplayCueDurationalSpec<T> : GameplayCueDurationalSpec where T : GameplayCueDurational
|
||||
|
@@ -1,3 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace GAS.Runtime
|
||||
{
|
||||
public struct GameplayCueParameters
|
||||
|
@@ -415,6 +415,7 @@ namespace GAS.Runtime
|
||||
if (frame >= cueClip.startFrame && frame <= cueClip.endFrame)
|
||||
{
|
||||
cueClip.cueSpec.OnTick(frame,cueClip.startFrame,cueClip.endFrame);
|
||||
cueClip.cueSpec.OnTick(deltaTime);
|
||||
}
|
||||
|
||||
if (frame == cueClip.endFrame)
|
||||
|
@@ -25,6 +25,8 @@ namespace JNGame.Sync.Entity
|
||||
|
||||
public T GetComponent<T>() where T : JNComponent;
|
||||
|
||||
public T GetSystem<T>() where T : SLogicSystem;
|
||||
|
||||
}
|
||||
|
||||
public abstract class JNEntity : Entitas.Entity,IJNEntity,IComparable
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Entitas;
|
||||
using JNGame.Runtime.Util;
|
||||
using JNGame.Sync;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.System;
|
||||
@@ -73,7 +74,7 @@ namespace JNGame.Runtime.Sync
|
||||
|
||||
public override Systems Add(ISystem system)
|
||||
{
|
||||
(system as SLogicSystem)?.OnSyncStart();
|
||||
(system as IJNSyncCycle)?.OnSyncStart();
|
||||
return base.Add(system);
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using HotScripts.JNGame.Runtime.Sync.System.Logic;
|
||||
using JNGame.Sync.Frame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.System.Data
|
||||
{
|
||||
@@ -12,10 +15,6 @@ namespace JNGame.Sync.System.Data
|
||||
public abstract class SEventDataSystem : SDataSystemBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 服务器事件
|
||||
/// </summary>
|
||||
private Queue<SEvent> ServerEvents = new();
|
||||
/// <summary>
|
||||
/// 客户端事件
|
||||
/// </summary>
|
||||
@@ -39,35 +38,60 @@ namespace JNGame.Sync.System.Data
|
||||
}
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
|
||||
while (WaitUBytes.Count > 0)
|
||||
{
|
||||
OnUByteUpdate(WaitUBytes.Dequeue());
|
||||
}
|
||||
|
||||
if (isServer)
|
||||
JNEventSystem Event = GetSystem<JNEventSystem>();
|
||||
|
||||
if (Event is null)
|
||||
{
|
||||
if (ServerEvents.Count <= 0) return;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
Debug.LogWarning("请保证逻辑层有 JNEventSystem 系统");
|
||||
return;
|
||||
}
|
||||
|
||||
//如果是帧同步系统则直接保存
|
||||
if (Sync is JNSyncFrameService)
|
||||
{
|
||||
while (Event.ViewEvent.Count > 0)
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(ms))
|
||||
{
|
||||
int count = ServerEvents.Count;
|
||||
//写入数量
|
||||
writer.Write(count);
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
{
|
||||
var data = ServerEvents.Dequeue().ToByteArray();
|
||||
//写入数据大小
|
||||
writer.Write(data.Length);
|
||||
//写入数据
|
||||
writer.Write(data);
|
||||
}
|
||||
}
|
||||
// 发送完整的字节数组
|
||||
OnSendUBytes(ms.ToArray());
|
||||
ClientEvents.Enqueue(Event.ViewEvent.Dequeue());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (WaitUBytes.Count > 0)
|
||||
{
|
||||
OnUByteUpdate(WaitUBytes.Dequeue());
|
||||
}
|
||||
|
||||
if (isServer)
|
||||
{
|
||||
if (Event.ViewEvent.Count <= 0) return;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (BinaryWriter writer = new BinaryWriter(ms))
|
||||
{
|
||||
int count = Event.ViewEvent.Count;
|
||||
//写入数量
|
||||
writer.Write(count);
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
{
|
||||
var data = Event.ViewEvent.Dequeue().ToByteArray();
|
||||
//写入数据大小
|
||||
writer.Write(data.Length);
|
||||
//写入数据
|
||||
writer.Write(data);
|
||||
}
|
||||
}
|
||||
// 发送完整的字节数组
|
||||
OnSendUBytes(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//触发事件
|
||||
while (ClientEvents.Count > 0)
|
||||
{
|
||||
ReceiveEvent(ClientEvents.Dequeue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,6 +101,11 @@ namespace JNGame.Sync.System.Data
|
||||
/// <param name="bytes"></param>
|
||||
/// <returns>是否清空UBytes</returns>
|
||||
public abstract void OnSendUBytes(byte[] bytes);
|
||||
|
||||
/// <summary>
|
||||
/// 接收事件 实现
|
||||
/// </summary>
|
||||
protected abstract void ReceiveEvent(SEvent @event);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -110,19 +139,6 @@ namespace JNGame.Sync.System.Data
|
||||
}
|
||||
}
|
||||
|
||||
public void AddEvent(int type,byte[] data)
|
||||
{
|
||||
//只有服务器才可以添加事件
|
||||
if (isServer)
|
||||
{
|
||||
ServerEvents.Enqueue(new SEvent()
|
||||
{
|
||||
Type = type,
|
||||
Data = data,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SEvent
|
||||
{
|
||||
/// <summary>
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using JNGame.Sync.Frame;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.System.Data
|
||||
@@ -90,6 +91,14 @@ namespace JNGame.Sync.System.Data
|
||||
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
|
||||
|
||||
//如果是帧同步系统则直接保存
|
||||
if (Sync is JNSyncFrameService)
|
||||
{
|
||||
Data = GetLatest();
|
||||
return;
|
||||
}
|
||||
|
||||
while (WaitUBytes.Count > 0)
|
||||
{
|
||||
|
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.System.Data;
|
||||
|
||||
namespace HotScripts.JNGame.Runtime.Sync.System.Logic
|
||||
{
|
||||
public class JNEventSystem : SLogicSystem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 渲染层 专用事件
|
||||
/// </summary>
|
||||
public Queue<SEventDataSystem.SEvent> ViewEvent = new();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加数据层事件(用于通知渲染层)
|
||||
/// </summary>
|
||||
public void AddViewEvent(int type,byte[] data)
|
||||
{
|
||||
ViewEvent.Enqueue(new SEventDataSystem.SEvent()
|
||||
{
|
||||
Type = type,
|
||||
Data = data,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1116c94f10954a2084f93bc6e8a61ece
|
||||
timeCreated: 1729876016
|
@@ -61,7 +61,7 @@ namespace JNGame.Sync.View
|
||||
}
|
||||
foreach (var delete in deletes)
|
||||
{
|
||||
ViewRemove(views[delete].Data);
|
||||
ViewRemove(delete,views[delete].Data);
|
||||
views.Remove(delete);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace JNGame.Sync.View
|
||||
public abstract GameObject NewView(T data);
|
||||
public abstract ConcurrentDictionary<ulong, T> GetData();
|
||||
|
||||
public abstract void ViewRemove(GameObject view);
|
||||
public abstract void ViewRemove(ulong id,GameObject view);
|
||||
|
||||
public T GetService<T>() where T : SBaseSystem
|
||||
{
|
||||
|
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 1549551891, guid: 74721b9f0af448f5ae2e91102a1a5edd, type: 3}
|
||||
m_Name: GlobalSerializationConfig
|
||||
m_EditorClassIdentifier:
|
||||
HideSerializationCautionaryMessage: 0
|
||||
HideSerializationCautionaryMessage: 1
|
||||
HidePrefabCautionaryMessage: 0
|
||||
HideOdinSerializeAttributeWarningMessages: 0
|
||||
HideNonSerializedShowInInspectorWarningMessages: 0
|
||||
|
@@ -266,13 +266,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 28019073}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &1449950258
|
||||
GameObject:
|
||||
@@ -297,6 +297,7 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1449950258}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
@@ -304,7 +305,6 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 1872085155}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1745439352
|
||||
GameObject:
|
||||
@@ -335,6 +335,64 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0c3aa2f58b904ebe9fc64cc367c63d68, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects:
|
||||
- {fileID: 11400000, guid: 0a77e9c8e20008944a99814e0b5a4aed, type: 2}
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes:
|
||||
- Name: CuesDurational
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[GAS.Runtime.GameplayCueDurational,
|
||||
JNGame.Runtime]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
||||
mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: GCueDurational_PlayerDemo
|
||||
- Name: $v
|
||||
Entry: 10
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: CuesInstant
|
||||
Entry: 7
|
||||
Data: 2|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[GAS.Runtime.GameplayCueInstant,
|
||||
JNGame.Runtime]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 9
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
World: {fileID: 2144549411}
|
||||
Box: {fileID: 7403693568755579174, guid: 2e5d0c510b71c714aaccc714aca99afc, type: 3}
|
||||
Preset: {fileID: 11400000, guid: 7692a8d07949a5c46b6b5325ebb9a422, type: 2}
|
||||
@@ -349,13 +407,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1745439352}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &1872085155 stripped
|
||||
Transform:
|
||||
@@ -446,13 +504,13 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2104190881}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2144549411
|
||||
GameObject:
|
||||
@@ -477,11 +535,20 @@ Transform:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2144549411}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 28019075}
|
||||
- {fileID: 1449950259}
|
||||
- {fileID: 1745439354}
|
||||
- {fileID: 2104190884}
|
||||
- {fileID: 2144549412}
|
||||
|
Binary file not shown.
@@ -27,7 +27,10 @@ MonoBehaviour:
|
||||
frameCount: 60
|
||||
durationalCues:
|
||||
- trackName: "\u6301\u7EEDGameplayCue\u8F68\u9053"
|
||||
clipEvents: []
|
||||
clipEvents:
|
||||
- startFrame: 11
|
||||
durationFrame: 37
|
||||
cue: {fileID: 11400000, guid: 0a77e9c8e20008944a99814e0b5a4aed, type: 2}
|
||||
instantCues:
|
||||
- trackName: "\u5373\u65F6Cue\u8F68\u9053"
|
||||
markEvents: []
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using JNGame.Runtime.System;
|
||||
using JNGame.Util;
|
||||
|
||||
namespace GASSamples.Scripts
|
||||
{
|
||||
@@ -6,6 +7,8 @@ namespace GASSamples.Scripts
|
||||
{
|
||||
|
||||
public static readonly JNGResService Resource = new JNGResService();
|
||||
|
||||
public static readonly EventDispatcher Event = new EventDispatcher();
|
||||
|
||||
public static SystemBase[] AllSystem()
|
||||
{
|
||||
|
@@ -1,6 +1,9 @@
|
||||
using GAS.Runtime;
|
||||
using DG.Tweening;
|
||||
using GAS.Runtime;
|
||||
using GASSamples.Scripts.Game.GAS;
|
||||
using JNGame.Math;
|
||||
using JNGame.Runtime.GAS.Runtime;
|
||||
using JNGame.Runtime.Util;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -26,10 +29,10 @@ namespace Demo.Scripts.GAS.GameplayCue
|
||||
{
|
||||
Debug.Log($"GameplayCueDurational_PlayerDemo01 {previewObject} {frameIndex}");
|
||||
|
||||
if (frameIndex >= startFrame && frameIndex <= endFrame)
|
||||
{
|
||||
previewObject.transform.position = Vector3.Lerp(start.ToVector3(), end.ToVector3(), (float)(frameIndex - startFrame) / endFrame);
|
||||
}
|
||||
// if (frameIndex >= startFrame && frameIndex <= endFrame)
|
||||
// {
|
||||
// previewObject.transform.position = Vector3.Lerp(start.ToVector3(), end.ToVector3(), (float)(frameIndex - startFrame) / endFrame);
|
||||
// }
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -39,6 +42,8 @@ namespace Demo.Scripts.GAS.GameplayCue
|
||||
public class GameplayCueDurational_PlayerDemo01_Spec : GameplayCueDurationalSpec<GameplayCueDurational_PlayerDemo01>
|
||||
{
|
||||
|
||||
private int TotalTime = 0;
|
||||
|
||||
public GameplayCueDurational_PlayerDemo01_Spec(GameplayCueDurational_PlayerDemo01 cue, GameplayCueParameters parameters) : base(cue, parameters)
|
||||
{
|
||||
}
|
||||
@@ -66,10 +71,24 @@ namespace Demo.Scripts.GAS.GameplayCue
|
||||
public override void OnTick(int frame,int startFrame,int endFrame)
|
||||
{
|
||||
|
||||
Debug.Log($"GameplayCueDurational_PlayerDemo01_Spec OnTick {frame}");
|
||||
((GAbilitySystemComponent)Owner).Entity.Transform.Position = LVector3.Lerp(cue.start, cue.end, (LFloat)(frame - startFrame) / endFrame);
|
||||
// Debug.Log($"GameplayCueDurational_PlayerDemo01_Spec OnTick {frame}");
|
||||
// ((GAbilitySystemComponent)Owner).Entity.Transform.Position = LVector3.Lerp(cue.start, cue.end, (LFloat)(frame - startFrame) / endFrame);
|
||||
|
||||
}
|
||||
|
||||
public override void OnTick(int deltaTime)
|
||||
{
|
||||
TotalTime += deltaTime;
|
||||
|
||||
var view = _parameters.customArguments[0] as GameObject;
|
||||
var durationTime = ((int)_parameters.customArguments[1]) * JexGasManager.TimeLineAbilityTickTime;
|
||||
|
||||
UnityMainThreadDispatcher.Instance.Enqueue(() =>
|
||||
{
|
||||
// view.transform.localScale = new Vector3((float)TotalTime / durationTime,(float)TotalTime / durationTime,(float)TotalTime / durationTime);
|
||||
view.transform.DOScale(new Vector3((float)TotalTime / durationTime,(float)TotalTime / durationTime,(float)TotalTime / durationTime),0.15f);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -13,5 +13,15 @@ namespace GASSamples.Scripts.Game.Logic.Data
|
||||
{
|
||||
OnInsertUBytes(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收到逻辑层分发的事件
|
||||
/// </summary>
|
||||
/// <param name="event"></param>
|
||||
protected override void ReceiveEvent(SEvent @event)
|
||||
{
|
||||
App.Event.Dispatch<byte[]>($"GEvent_{@event.Type}",@event.Data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -47,6 +47,7 @@ namespace GASSamples.Scripts.Game.Logic.Data
|
||||
{
|
||||
DataCache.TryAdd(entity.Id,new JNGASBoxData()
|
||||
{
|
||||
Id = entity.Id,
|
||||
Value = new ()
|
||||
{
|
||||
Position = NDataLVector3.Build(entity.Position),
|
||||
|
10
JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GameEvent.cs
Normal file
10
JNFrame2/Assets/Scripts/GASSamples/Scripts/Game/GameEvent.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace GASSamples.Scripts.Game
|
||||
{
|
||||
public enum GameEvent : int
|
||||
{
|
||||
OnCueAdd = 0,
|
||||
OnCueRemove = 1,
|
||||
OnCueExecute = 2,
|
||||
OnAbilityEnd = 3,
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05e3b97105e14200997f5910e5e0c90e
|
||||
timeCreated: 1729876692
|
@@ -1,5 +1,8 @@
|
||||
using GAS.Runtime;
|
||||
using GASSamples.Scripts.Game.Logic.Data;
|
||||
using HotScripts.JNGame.Runtime.Sync.System.Logic;
|
||||
using JNGame.Runtime.Sync.System.Logic;
|
||||
using JNGame.Serialization;
|
||||
using JNGame.Sync.Entity;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,6 +14,8 @@ namespace GASSamples.Scripts.Game.GAS
|
||||
|
||||
|
||||
public IJNEntity Entity { get; protected set; }
|
||||
|
||||
private int CueClipIndex = 0;
|
||||
|
||||
public GAbilitySystemComponent(IJNEntity entity)
|
||||
{
|
||||
@@ -48,6 +53,33 @@ namespace GASSamples.Scripts.Game.GAS
|
||||
Debug.Log("OnGERelease");
|
||||
}
|
||||
|
||||
public override int OnCueAdd(AbilitySpec abilitySpec, string cueAssetLocation, int durationTime)
|
||||
{
|
||||
Debug.Log("OnCueAdd");
|
||||
int cueId = CueClipIndex++;
|
||||
Serializer data = new Serializer();
|
||||
data.Write(cueAssetLocation);
|
||||
data.Write(durationTime);
|
||||
data.Write(cueId);
|
||||
data.Write(Entity.Id);
|
||||
Entity.GetSystem<JNEventSystem>().AddViewEvent((int)GameEvent.OnCueAdd,data.Data);
|
||||
return cueId;
|
||||
}
|
||||
|
||||
public override void OnCueRemove(AbilitySpec abilitySpec, int cueClipIndex)
|
||||
{
|
||||
Serializer data = new Serializer();
|
||||
data.Write(cueClipIndex);
|
||||
data.Write(Entity.Id);
|
||||
Entity.GetSystem<JNEventSystem>().AddViewEvent((int)GameEvent.OnCueRemove,data.Data);
|
||||
Debug.Log("OnCueRemove");
|
||||
}
|
||||
|
||||
public override void OnCueExecute(AbilitySpec abilitySpec, string[] cueAssetLocations)
|
||||
{
|
||||
Debug.Log("OnCueExecute");
|
||||
}
|
||||
|
||||
public override void OnAbilityEnd(AbilitySpec abilitySpec)
|
||||
{
|
||||
Debug.Log("OnAbilityEnd");
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using GAS.Runtime;
|
||||
using System.Collections.Generic;
|
||||
using GAS.Runtime;
|
||||
using GASSamples.Scripts;
|
||||
using JNGame.Sync.System;
|
||||
|
||||
@@ -16,6 +17,10 @@ namespace Game.Logic.System.Usual
|
||||
public byte[] Ability { get; private set; }
|
||||
public byte[] GE { get; private set; }
|
||||
public byte[] ASC { get; private set; }
|
||||
|
||||
|
||||
public Dictionary<string,GameplayCueDurational> CuesDurational { get; private set; }
|
||||
public Dictionary<string,GameplayCueInstant> CuesInstant { get; private set; }
|
||||
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
@@ -26,6 +31,9 @@ namespace Game.Logic.System.Usual
|
||||
Ability = App.Resource.Ability;
|
||||
GE = App.Resource.GE;
|
||||
ASC = App.Resource.ASC;
|
||||
|
||||
CuesDurational = App.Resource.CuesDurational;
|
||||
CuesInstant = App.Resource.CuesInstant;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,68 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using Game.Logic.System.Usual;
|
||||
using GAS.Runtime;
|
||||
using JNGame.Serialization;
|
||||
using JNGame.Sync.System;
|
||||
|
||||
namespace GASSamples.Scripts.Game.View
|
||||
{
|
||||
/// <summary>
|
||||
/// 视图层 - GeCue系统
|
||||
/// </summary>
|
||||
public class DGeCueSystem : SViewSystem
|
||||
{
|
||||
|
||||
private DDataSystem Resource => GetSystem<DDataSystem>();
|
||||
private DViewSystem View => GetSystem<DViewSystem>();
|
||||
|
||||
private ConcurrentDictionary<int, GameplayCueDurationalSpec> CueMap = new();
|
||||
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
base.OnSyncStart();
|
||||
|
||||
//监听逻辑层事件
|
||||
App.Event.AddListener<byte[]>($"GEvent_{(int)GameEvent.OnCueAdd}",OnCueAdd);
|
||||
App.Event.AddListener<byte[]>($"GEvent_{(int)GameEvent.OnCueRemove}",OnCueRemove);
|
||||
}
|
||||
|
||||
private void OnCueAdd(byte[] data)
|
||||
{
|
||||
|
||||
var reader = new Deserializer(data);
|
||||
var cueAssetLocation = reader.ReadString();
|
||||
var durationTime = reader.ReadInt32();
|
||||
var cueId = reader.ReadInt32();
|
||||
var entityId = reader.ReadUInt64();
|
||||
|
||||
CueMap.TryAdd(cueId,Resource.CuesDurational[cueAssetLocation].ApplyFrom(View.ViewObject[entityId],durationTime));
|
||||
|
||||
}
|
||||
|
||||
private void OnCueRemove(byte[] data)
|
||||
{
|
||||
|
||||
var reader = new Deserializer(data);
|
||||
var cueClipIndex = reader.ReadInt32();
|
||||
var entityId = reader.ReadInt32();
|
||||
CueMap.TryRemove(cueClipIndex,out var spec);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
base.OnSyncUpdate(dt);
|
||||
foreach (var spec in CueMap.Values)
|
||||
{
|
||||
spec.OnTick(dt);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSyncDestroy()
|
||||
{
|
||||
base.OnSyncDestroy();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a977f079c3944e698f134d56eb2d844
|
||||
timeCreated: 1729873738
|
@@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using GASSamples.Scripts.Game.View.Entity;
|
||||
using JNGame.Runtime.Util;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.View;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GASSamples.Scripts.Game.View
|
||||
{
|
||||
@@ -10,6 +12,9 @@ namespace GASSamples.Scripts.Game.View
|
||||
|
||||
private readonly IViewData[] views;
|
||||
|
||||
//视图层 GameObject <实体Id,视图对象>
|
||||
public Dictionary<ulong, GameObject> ViewObject = new();
|
||||
|
||||
public DViewSystem()
|
||||
{
|
||||
views = new IViewData[] {
|
||||
|
@@ -11,6 +11,8 @@ namespace GASSamples.Scripts.Game.View.Entity
|
||||
{
|
||||
public GameObject World => App.Resource.World;
|
||||
public GameObject Box => App.Resource.Box;
|
||||
|
||||
public DViewSystem View => Root as DViewSystem;
|
||||
|
||||
public VDBox(SViewSystem root) : base(root)
|
||||
{
|
||||
@@ -19,13 +21,14 @@ namespace GASSamples.Scripts.Game.View.Entity
|
||||
public override void ViewUpdate(JNGASBoxData data, GameObject view)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(),0.5f);
|
||||
view.transform.DOScale(data.Value.Scale.ToVector3(),0.5f);
|
||||
// view.transform.DOScale(data.Value.Scale.ToVector3(),0.5f);
|
||||
}
|
||||
|
||||
public override GameObject NewView(JNGASBoxData data)
|
||||
{
|
||||
var view = Object.Instantiate(Box, World.transform);
|
||||
view.name = $"Box_{data.Id}";
|
||||
View.ViewObject.Add(data.Id,view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -34,8 +37,9 @@ namespace GASSamples.Scripts.Game.View.Entity
|
||||
return GetService<JNGASBoxDataSystem>().Data;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
public override void ViewRemove(ulong id,GameObject view)
|
||||
{
|
||||
View.ViewObject.Remove(id);
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using GAS.Runtime;
|
||||
using JNGame.Network;
|
||||
@@ -24,6 +25,9 @@ namespace GASSamples.Scripts
|
||||
public byte[] GE;
|
||||
public byte[] ASC;
|
||||
|
||||
public Dictionary<string,GameplayCueDurational> CuesDurational;
|
||||
public Dictionary<string,GameplayCueInstant> CuesInstant;
|
||||
|
||||
public override Task OnInit()
|
||||
{
|
||||
return base.OnInit();
|
||||
|
@@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DefaultNamespace;
|
||||
using GAS.Runtime;
|
||||
using JNGame.Runtime;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GASSamples.Scripts
|
||||
{
|
||||
public class Main : MonoBehaviour
|
||||
public class Main : SerializedMonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject World;
|
||||
@@ -17,6 +20,9 @@ namespace GASSamples.Scripts
|
||||
public TextAsset GEAsset;
|
||||
public TextAsset ASCAsset;
|
||||
|
||||
public Dictionary<string,GameplayCueDurational> CuesDurational;
|
||||
public Dictionary<string,GameplayCueInstant> CuesInstant;
|
||||
|
||||
|
||||
private JNGASFrameSystem _frameSystem;
|
||||
private int _totalTime;
|
||||
@@ -35,6 +41,9 @@ namespace GASSamples.Scripts
|
||||
App.Resource.GE = GEAsset.bytes;
|
||||
App.Resource.ASC = ASCAsset.bytes;
|
||||
|
||||
App.Resource.CuesDurational = CuesDurational;
|
||||
App.Resource.CuesInstant = CuesInstant;
|
||||
|
||||
|
||||
|
||||
_frameSystem = new JNGASFrameSystem();
|
||||
|
@@ -6,6 +6,7 @@ using GASSamples.Scripts.Game.GAS;
|
||||
using GASSamples.Scripts.Game.Logic.Data;
|
||||
using GASSamples.Scripts.Game.Logic.System;
|
||||
using GASSamples.Scripts.Game.View;
|
||||
using HotScripts.JNGame.Runtime.Sync.System.Logic;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame;
|
||||
using JNGame.Sync.System;
|
||||
@@ -22,6 +23,7 @@ namespace DefaultNamespace
|
||||
return new SLogicSystem[]
|
||||
{
|
||||
new DInputSystem(), //游戏输入
|
||||
new JNEventSystem(), //事件系统
|
||||
new DDataSystem(), //数据 系统
|
||||
new DGASSystem(), //GAS 系统
|
||||
new DWorldSystem(), //世界逻辑
|
||||
@@ -41,7 +43,8 @@ namespace DefaultNamespace
|
||||
return new SViewSystem[]
|
||||
{
|
||||
//视图层
|
||||
new DViewSystem(), //游戏视图
|
||||
new DViewSystem(), //游戏视图
|
||||
new DGeCueSystem(), //GeCue视图
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
return GetService<EDBossDataSystem>().Data;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
public override void ViewRemove(ulong id,GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
Object.Destroy(view);
|
||||
|
@@ -44,7 +44,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
return GetService<EDNodeDataSystem>().Data;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
public override void ViewRemove(ulong id,GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
Object.Destroy(view);
|
||||
|
@@ -93,7 +93,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
return GetService<EDPlayerDataSystem>().Data;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
public override void ViewRemove(ulong id,GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
if (LocalView != view)
|
||||
|
Reference in New Issue
Block a user