浏览代码
Adding ReviveAction
Adding ReviveAction
ReviveAction brings Fainted characters back to life. ServerCharacter only allows PCs to become Fainted - NPCs become dead instead. HP <= 0 is the triggering condition for going from Alive to either Fainted or Dead. That also clears out the action queue and prevents NPC AIBrain from being updated./main
sorcerer_king
4 年前
当前提交
490c45ba
共有 6 个文件被更改,包括 109 次插入 和 11 次删除
-
1Assets/BossRoom/Scripts/Server/Game/Action/Action.cs
-
6Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs
-
43Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs
-
15Assets/BossRoom/Scripts/Shared/Game/Action/ActionRequestData.cs
-
52Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs
-
3Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs.meta
|
|||
using MLAPI.Spawning; |
|||
using UnityEngine; |
|||
|
|||
namespace BossRoom.Server |
|||
{ |
|||
public class ReviveAction : Action |
|||
{ |
|||
private bool m_ExecFired; |
|||
private ServerCharacter m_TargetCharacter; |
|||
|
|||
public ReviveAction(ServerCharacter parent, ref ActionRequestData data, int level) : base(parent, ref data, level) |
|||
{ |
|||
} |
|||
|
|||
public override bool Start() |
|||
{ |
|||
if (m_Data.TargetIds == null || m_Data.TargetIds.Length == 0 || !SpawnManager.SpawnedObjects.ContainsKey(m_Data.TargetIds[0])) |
|||
{ |
|||
Debug.Log("Failed to start ReviveAction. The target entity wasn't submitted or doesn't exist anymore"); |
|||
return false; |
|||
} |
|||
|
|||
var targetNeworkedObj = SpawnManager.SpawnedObjects[m_Data.TargetIds[0]]; |
|||
m_TargetCharacter = targetNeworkedObj.GetComponent<ServerCharacter>(); |
|||
m_Parent.NetState.S2C_BroadcastAction(ref Data); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
public override bool Update() |
|||
{ |
|||
if (!m_ExecFired && Time.time - TimeStarted >= Description.ExecTime_s) |
|||
{ |
|||
m_ExecFired = true; |
|||
|
|||
if (m_TargetCharacter.NetState.NetworkLifeState.Value == LifeState.FAINTED) |
|||
{ |
|||
m_TargetCharacter.Revive(m_Parent, (int) m_Data.Amount); |
|||
} |
|||
else |
|||
{ |
|||
//cancel the action if the target is alive!
|
|||
Cancel(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1122d1ad1a0b437c8a0e586ecb64449d |
|||
timeCreated: 1610045410 |
撰写
预览
正在加载...
取消
保存
Reference in new issue