mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
提交Cue案例
This commit is contained in:
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