Boss Room 是一款使用 Unity MLAPI 制作的全功能合作多人 RPG。 它旨在作为学习样本,展示类似游戏中经常出现的某些典型游戏模式。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

52 行
1.6 KiB

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.ServerBroadcastAction(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;
}
}
}