David Woodruff
4 年前
当前提交
574fd252
共有 13 个文件被更改,包括 288 次插入 和 47 次删除
-
38Assets/BossRoom/Models/CharacterSetController.controller
-
17Assets/BossRoom/Scripts/Client/ClientCharacterVisualization.cs
-
11Assets/BossRoom/Scripts/Client/ClientInputSender.cs
-
6Assets/BossRoom/Scripts/Client/Game/Character/ClientCharacter.cs
-
72Assets/BossRoom/Scripts/Server/Game/Action/Action.cs
-
52Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs
-
1Assets/BossRoom/Scripts/Server/ServerCharacterMovement.cs
-
2Assets/BossRoom/Scripts/Shared/Game/Action/ActionRequestData.cs
-
18Assets/BossRoom/Scripts/Shared/NetworkCharacterState.cs
-
74Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs
-
11Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs.meta
-
22Assets/BossRoom/Scripts/Server/Game/Action/MeleeAction.cs
-
11Assets/BossRoom/Scripts/Server/Game/Action/MeleeAction.cs.meta
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace BossRoom.Server |
|||
{ |
|||
/// <summary>
|
|||
/// Class responsible for playing back action inputs from user.
|
|||
/// </summary>
|
|||
public class ActionPlayer |
|||
{ |
|||
private ServerCharacter m_parent; |
|||
|
|||
private List<Action> m_queue; |
|||
private float m_actionStarted_s = 0f; |
|||
|
|||
public ActionPlayer(ServerCharacter parent ) |
|||
{ |
|||
m_parent = parent; |
|||
m_queue = new List<Action>(); |
|||
} |
|||
|
|||
public void PlayAction(ref ActionRequestData data ) |
|||
{ |
|||
int level = 0; //todo, get this from parent's networked vars, maybe.
|
|||
var new_action = Action.MakeAction(m_parent, ref data, level); |
|||
|
|||
bool was_empty = m_queue.Count == 0; |
|||
m_queue.Add(new_action); |
|||
if( was_empty ) |
|||
{ |
|||
AdvanceQueue(false); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Optionally end the currently playing action, and advance to the next Action that wants to play.
|
|||
/// </summary>
|
|||
/// <param name="expireFirstElement">Pass true to remove the first element and advance to the next element. Pass false to "advance" to the 0th element</param>
|
|||
private void AdvanceQueue(bool expireFirstElement) |
|||
{ |
|||
if( expireFirstElement && m_queue.Count > 0 ) |
|||
{ |
|||
m_queue.RemoveAt(0); |
|||
} |
|||
|
|||
if( m_queue.Count > 0 ) |
|||
{ |
|||
m_actionStarted_s = Time.time; |
|||
bool play = m_queue[0].Start(); |
|||
if( !play ) |
|||
{ |
|||
AdvanceQueue(true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
if( this.m_queue.Count > 0 ) |
|||
{ |
|||
bool keepgoing = this.m_queue[0].Update(); |
|||
bool time_expired = (Time.time - this.m_actionStarted_s) >= this.m_queue[0].Description.Duration_s; |
|||
if ( !keepgoing || time_expired ) |
|||
{ |
|||
this.AdvanceQueue(true); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: cfede55de1de006448fa960048736574 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace BossRoom.Server |
|||
{ |
|||
public class MeleeAction : Action |
|||
{ |
|||
public MeleeAction(ServerCharacter parent, ref ActionRequestData data, int level) : base(parent, ref data, level) |
|||
{ |
|||
} |
|||
|
|||
public override bool Start() |
|||
{ |
|||
//stub. For now, just relay the action to all clients.
|
|||
m_parent.NetState.S2C_BroadcastAction(ref Data); |
|||
return true; |
|||
} |
|||
|
|||
public override bool Update() { return true; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 62b840a5705be5b4b9c5f9926aafcc85 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue