浏览代码

Character health system (#34)

This PR implements full character lifecycle with the following states:

Alive
Fainted - PCs go into this state upon reaching 0 HP
Dead - NPCs just die
Along with these states ReviveAction has been added, which restores a Fainted character back to life.

Player inputs now differentiate between friends and foes and tries to revive fainted allies on right click.

Commits have been arranged in a readable order and contain additional implementation details.
/main
GitHub 4 年前
当前提交
d4a3dbbf
共有 10 个文件被更改,包括 506 次插入166 次删除
  1. 294
      Assets/BossRoom/Models/CharacterSetController.controller
  2. 55
      Assets/BossRoom/Scripts/Client/ClientCharacterVisualization.cs
  3. 56
      Assets/BossRoom/Scripts/Client/ClientInputSender.cs
  4. 1
      Assets/BossRoom/Scripts/Server/Game/Action/Action.cs
  5. 43
      Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs
  6. 34
      Assets/BossRoom/Scripts/Shared/Game/Action/ActionRequestData.cs
  7. 12
      Assets/BossRoom/Scripts/Shared/NetworkCharacterState.cs
  8. 122
      ProjectSettings/GraphicsSettings.asset
  9. 52
      Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs
  10. 3
      Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs.meta

294
Assets/BossRoom/Models/CharacterSetController.controller


m_UseAutomaticThresholds: 1
m_NormalizedBlendValues: 0
m_BlendType: 0
--- !u!1102 &-7547485152901491539
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Fall Down
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 5579816715067545514}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: -1504929105726005784, guid: 2115c4661f55eff45a5a0f91fc0a12f0, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &-7345246596832709857
AnimatorState:
serializedVersion: 6

m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &-6735739854590397019
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -3516404760485336223}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-6270680072761177303
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_Name: WalkRun
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_Transitions:
- {fileID: 8427159825030150999}
- {fileID: 4924297452976420476}
- {fileID: -2323244736882414019}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0

m_UseAutomaticThresholds: 1
m_NormalizedBlendValues: 0
m_BlendType: 0
--- !u!1101 &-2323244736882414019
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: BeginRevive
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 8314685060882719794}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.7413794
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-2134875305200649429
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &-1777038757504527503
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -3516404760485336223}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &-1068572555509609370
AnimatorState:
serializedVersion: 6

m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_Name: Fall Down
- serializedVersion: 1
m_State: {fileID: 8314685060882719794}
m_Position: {x: 520, y: 200, z: 0}
- serializedVersion: 1
m_State: {fileID: 5803934921609956400}
m_Position: {x: 60, y: 340, z: 0}
- serializedVersion: 1
m_State: {fileID: 6995031694560656813}
m_Position: {x: 350, y: 320, z: 0}
- serializedVersion: 1
m_State: {fileID: -7547485152901491539}
m_Position: {x: -30, y: 240, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []

m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: BeginHitReact
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: FallDown
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: BeginRevive
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: Dead
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: StandUp
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &4924297452976420476
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Dead
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 6995031694560656813}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.7413794
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &4957634337843930872
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &5579816715067545514
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: StandUp
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 5803934921609956400}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.87288135
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &5593412509193387231
AnimatorStateTransition:
m_ObjectHideFlags: 1

m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &5803934921609956400
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Stand Up
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -6735739854590397019}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: -2919142679728832081, guid: 2115c4661f55eff45a5a0f91fc0a12f0, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1109 &6002482201662273439
AnimatorTransition:
m_ObjectHideFlags: 1

m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &6995031694560656813
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dead
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: -1504929105726005784, guid: 2115c4661f55eff45a5a0f91fc0a12f0, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &8124319401456280373
AnimatorStateMachine:
serializedVersion: 6

m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: -1068572555509609370}
--- !u!1102 &8314685060882719794
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Action - Revive
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: -1777038757504527503}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: -7620468718608648079, guid: 2115c4661f55eff45a5a0f91fc0a12f0, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1101 &8427159825030150999
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: FallDown
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -7547485152901491539}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.7413794
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &8468659891928091302
AnimatorStateTransition:
m_ObjectHideFlags: 1

55
Assets/BossRoom/Scripts/Client/ClientCharacterVisualization.cs


using System;
using Cinemachine;
using MLAPI;
using UnityEngine;

m_NetState = this.transform.parent.gameObject.GetComponent<NetworkCharacterState>();
m_NetState.DoActionEventClient += this.PerformActionFX;
m_NetState.NetworkLifeState.OnValueChanged += OnLifeStateChanged;
//we want to follow our parent on a spring, which means it can't be directly in the transform hierarchy.
m_Parent = transform.parent;

{
//TODO: [GOMPS-13] break this method out into its own class, so we can drive multi-frame graphical effects.
//FIXME: [GOMPS-13] hook this up to information in the ActionDescription.
m_ClientVisualsAnimator.SetInteger("AttackID", 1);
m_ClientVisualsAnimator.SetTrigger("BeginAttack");
if (data.TargetIds != null && data.TargetIds.Length > 0)
switch (data.ActionTypeEnum)
NetworkedObject targetObject = MLAPI.Spawning.SpawnManager.SpawnedObjects[data.TargetIds[0]];
if (targetObject != null)
{
var targetAnimator = targetObject.GetComponent<BossRoom.Client.ClientCharacter>().ChildVizObject.OurAnimator;
if (targetAnimator != null)
case ActionType.TANK_BASEATTACK:
m_ClientVisualsAnimator.SetInteger("AttackID", 1);
m_ClientVisualsAnimator.SetTrigger("BeginAttack");
if (data.TargetIds != null && data.TargetIds.Length > 0)
targetAnimator.SetTrigger("BeginHitReact");
NetworkedObject targetObject = MLAPI.Spawning.SpawnManager.SpawnedObjects[data.TargetIds[0]];
if (targetObject != null)
{
var targetAnimator = targetObject.GetComponent<BossRoom.Client.ClientCharacter>().ChildVizObject.OurAnimator;
if (targetAnimator != null)
{
targetAnimator.SetTrigger("BeginHitReact");
}
}
}
break;
case ActionType.ARCHER_BASEATTACK:
break;
case ActionType.GENERAL_CHASE:
break;
case ActionType.GENERAL_REVIVE:
m_ClientVisualsAnimator.SetTrigger("BeginRevive");
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private void OnLifeStateChanged(LifeState previousValue, LifeState newValue)
{
switch (newValue)
{
case LifeState.ALIVE:
m_ClientVisualsAnimator.SetTrigger("StandUp");
break;
case LifeState.FAINTED:
m_ClientVisualsAnimator.SetTrigger("FallDown");
break;
case LifeState.DEAD:
m_ClientVisualsAnimator.SetTrigger("Dead");
break;
default:
throw new ArgumentOutOfRangeException(nameof(newValue), newValue, null);
}
}

56
Assets/BossRoom/Scripts/Client/ClientInputSender.cs


[RequireComponent(typeof(NetworkCharacterState))]
public class ClientInputSender : NetworkedBehaviour
{
private int m_NpcLayerMask;
/// We detect clicks in Update (because you can miss single discrete clicks in FixedUpdate). But we need to
/// raycast in FixedUpdate, because raycasts done in Update won't work reliably.
/// This nullable vector will be set to a screen coordinate when an attack click was made.
/// We detect clicks in Update (because you can miss single discrete clicks in FixedUpdate). But we need to
/// raycast in FixedUpdate, because raycasts done in Update won't work reliably.
/// This nullable vector will be set to a screen coordinate when an attack click was made.
private System.Nullable<Vector3> m_AttackClickRequest;
private System.Nullable<Vector3> m_ClickRequest;
public override void NetworkStart()
{

}
}
m_NpcLayerMask = LayerMask.GetMask("NPCs");
m_NetworkCharacter = GetComponent<NetworkCharacterState>();
}

if (Input.GetMouseButton(0))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
{
// The MLAPI_INTERNAL channel is a reliable sequenced channel. Inputs should always arrive and be in order that's why this channel is used.

}
if (m_AttackClickRequest != null)
if (m_ClickRequest != null)
if (Physics.Raycast(Camera.main.ScreenPointToRay(m_AttackClickRequest.Value), out hit) && GetTargetObject(ref hit) != 0)
if (Physics.Raycast(Camera.main.ScreenPointToRay(m_ClickRequest.Value), out hit) && GetTargetObject(ref hit) != 0)
//these two actions will queue one after the other, causing us to run over to our target and take a swing.
//if we have clicked on an enemy:
// - two actions will queue one after the other, causing us to run over to our target and take a swing.
//if we have clicked on a fallen friend - we will revive him
chase_data.TargetIds = new ulong[] { GetTargetObject(ref hit) };
chase_data.TargetIds = new ulong[] {GetTargetObject(ref hit)};
var hit_data = new ActionRequestData();
hit_data.ShouldQueue = true; //wait your turn--don't clobber the chase action.
hit_data.ActionTypeEnum = ActionType.TANK_BASEATTACK;
m_NetworkCharacter.ClientSendActionRequest(ref hit_data);
//TODO fixme: there needs to be a better way to check if target is a PC or an NPC
bool isTargetingNPC = hit.transform.gameObject.layer == m_NpcLayerMask;
if (isTargetingNPC)
{
var hit_data = new ActionRequestData();
hit_data.ShouldQueue = true; //wait your turn--don't clobber the chase action.
hit_data.ActionTypeEnum = ActionType.TANK_BASEATTACK;
m_NetworkCharacter.ClientSendActionRequest(ref hit_data);
}
else
{
//proceed to revive the target if it's in FAINTED state
var targetCharacterState = hit.transform.GetComponent<NetworkCharacterState>();
if (targetCharacterState.NetworkLifeState.Value == LifeState.FAINTED)
{
var revive_data = new ActionRequestData();
revive_data.ShouldQueue = true;
revive_data.ActionTypeEnum = ActionType.GENERAL_REVIVE;
revive_data.TargetIds = new [] {GetTargetObject(ref hit)};
m_NetworkCharacter.ClientSendActionRequest(ref revive_data);
}
}
}
else
{

}
m_AttackClickRequest = null;
m_ClickRequest = null;
}
}

if (Input.GetMouseButtonDown(1))
{
m_AttackClickRequest = Input.mousePosition;
m_ClickRequest = Input.mousePosition;
}
}

1
Assets/BossRoom/Scripts/Server/Game/Action/Action.cs


{
case ActionLogic.MELEE: return new MeleeAction(parent, ref data, level);
case ActionLogic.CHASE: return new ChaseAction(parent, ref data, level);
case ActionLogic.REVIVE: return new ReviveAction(parent, ref data, level);
default: throw new System.NotImplementedException();
}
}

43
Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <param name="data">Contains all data necessary to create the action</param>
public void PlayAction(ref ActionRequestData data )
{
this.m_actionPlayer.PlayAction(ref data);
//the character needs to be alive in order to be able to play actions
if (NetState.NetworkLifeState.Value == LifeState.ALIVE)
{
this.m_actionPlayer.PlayAction(ref data);
}
}
/// <summary>

{
//in a more complicated implementation, we might look up all sorts of effects from the inflicter, and compare them
//to our own effects, and modify the damage or healing as appropriate. But in this game, we just take it straight.
//we can't currently heal a dead character back to Alive state.
//that's handled by a separate function.
//TODO: handle death state.
GameObject.Destroy(this.gameObject);
ClearActions();
if (IsNPC)
{
NetState.NetworkLifeState.Value = LifeState.DEAD;
}
else
{
NetState.NetworkLifeState.Value = LifeState.FAINTED;
}
}
/// <summary>
/// Receive a Life State change that brings Fainted characters back to Alive state.
/// </summary>
/// <param name="inflicter">Person reviving the character.</param>
/// <param name="HP">The HP to set to a newly revived character.</param>
public void Revive(ServerCharacter inflicter, int HP)
{
if (NetState.NetworkLifeState.Value == LifeState.FAINTED)
{
NetState.HitPoints.Value = HP;
NetState.NetworkLifeState.Value = LifeState.ALIVE;
}
if (m_aiBrain != null)
if (m_aiBrain != null && NetState.NetworkLifeState.Value == LifeState.ALIVE)
{
m_aiBrain.Update();
}

34
Assets/BossRoom/Scripts/Shared/Game/Action/ActionRequestData.cs


TANK_BASEATTACK,
ARCHER_BASEATTACK,
GENERAL_CHASE,
GENERAL_REVIVE,
}

RANGED,
RANGEDTARGETED,
CHASE,
REVIVE,
//O__O adding a new ActionLogic type? Update Action.MakeAction!
//O__O adding a new ActionLogic branch? Update Action.MakeAction!
/// FIXME: [GOMPS-99] This will be turned into a ScriptableObject.
/// FIXME: [GOMPS-99] This will be turned into a ScriptableObject.
/// ActionLogic that drives this Action. This corresponds to the actual block of code that executes it.
/// ActionLogic that drives this Action. This corresponds to the actual block of code that executes it.
/// by game logic when the action takes effect.
/// by game logic when the action takes effect.
/// How much it consts in Mana to play this Action.
/// How much it consts in Mana to play this Action.
/// How how the Action performer can be from the Target, or how far the action can go (for an untargeted action like a bowshot).
/// How how the Action performer can be from the Target, or how far the action can go (for an untargeted action like a bowshot).
/// Duration in seconds that this Action takes to play.
/// Duration in seconds that this Action takes to play.
/// Time when the Action should do its "main thing" (e.g. when a melee attack should apply damage).
/// Time when the Action should do its "main thing" (e.g. when a melee attack should apply damage).
/// How long the effect this Action leaves behind will last, in seconds.
/// How long the effect this Action leaves behind will last, in seconds.
/// The primary Animation action that gets played when visualizing this Action.
/// The primary Animation action that gets played when visualizing this Action.
/// FIXME [GOMPS-99]: this list will be turned into a collection of Scriptable Objects.
/// FIXME [GOMPS-99]: this list will be turned into a collection of Scriptable Objects.
/// Question: Do we want to show how to do skill levels, as I am doing here?
/// </summary>
public class ActionData

{ ActionType.GENERAL_CHASE, new List<ActionDescription>
{
{new ActionDescription{Logic=ActionLogic.CHASE } }
}
}
}
},
{ ActionType.GENERAL_REVIVE, new List<ActionDescription>
{
{new ActionDescription{Logic=ActionLogic.REVIVE, Amount=10, ExecTime_s=0.3f, Duration_s=0.5f, Anim="Todo" } }
}
}
};
}

12
Assets/BossRoom/Scripts/Shared/NetworkCharacterState.cs


namespace BossRoom
{
public enum LifeState
{
ALIVE,
FAINTED,
DEAD,
}
/// <summary>
/// Contains all NetworkedVars and RPCs of a character. This component is present on both client and server objects.

public NetworkedVarFloat NetworkMovementSpeed { get; } = new NetworkedVarFloat();
public NetworkedVarInt HitPoints;
public NetworkedVarInt Mana;
public NetworkedVarInt Mana;
public NetworkedVar<LifeState> NetworkLifeState { get; } = new NetworkedVar<LifeState>(LifeState.ALIVE);
/// <summary>
/// Gets invoked when inputs are received from the client which own this networked character.
/// </summary>

122
ProjectSettings/GraphicsSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 13
m_Deferred:
m_Mode: 1
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
m_DeferredReflections:
m_Mode: 1
m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
m_ScreenSpaceShadows:
m_Mode: 1
m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
m_LegacyDeferred:
m_Mode: 1
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
m_DepthNormals:
m_Mode: 1
m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
m_MotionVectors:
m_Mode: 1
m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
m_LightHalo:
m_Mode: 1
m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
m_LensFlare:
m_Mode: 1
m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
m_VideoShadersIncludeMode: 2
m_AlwaysIncludedShaders:
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_CustomRenderPipeline: {fileID: 0}
m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1
m_DefaultMobileRenderingPath: 1
m_TierSettings:
- serializedVersion: 5
m_BuildTarget: 1
m_Tier: 0
m_Settings:
standardShaderQuality: 2
renderingPath: 3
hdrMode: 1
realtimeGICPUUsage: 25
useReflectionProbeBoxProjection: 1
useReflectionProbeBlending: 1
useHDR: 1
useDetailNormalMap: 1
useCascadedShadowMaps: 1
prefer32BitShadowMaps: 0
enableLPPV: 1
useDitherMaskForAlphaBlendedShadows: 1
m_Automatic: 0
- serializedVersion: 5
m_BuildTarget: 1
m_Tier: 1
m_Settings:
standardShaderQuality: 2
renderingPath: 3
hdrMode: 1
realtimeGICPUUsage: 25
useReflectionProbeBoxProjection: 1
useReflectionProbeBlending: 1
useHDR: 1
useDetailNormalMap: 1
useCascadedShadowMaps: 1
prefer32BitShadowMaps: 0
enableLPPV: 1
useDitherMaskForAlphaBlendedShadows: 1
m_Automatic: 0
- serializedVersion: 5
m_BuildTarget: 1
m_Tier: 2
m_Settings:
standardShaderQuality: 2
renderingPath: 3
hdrMode: 1
realtimeGICPUUsage: 50
useReflectionProbeBoxProjection: 1
useReflectionProbeBlending: 1
useHDR: 1
useDetailNormalMap: 1
useCascadedShadowMaps: 1
prefer32BitShadowMaps: 0
enableLPPV: 1
useDitherMaskForAlphaBlendedShadows: 1
m_Automatic: 0
m_LightmapStripping: 0
m_FogStripping: 0
m_InstancingStripping: 0
m_LightmapKeepPlain: 1
m_LightmapKeepDirCombined: 1
m_LightmapKeepDynamicPlain: 1
m_LightmapKeepDynamicDirCombined: 1
m_LightmapKeepShadowMask: 1
m_LightmapKeepSubtractive: 1
m_FogKeepLinear: 1
m_FogKeepExp: 1
m_FogKeepExp2: 1
m_AlbedoSwatchInfos: []
m_LightsUseLinearIntensity: 0
m_LightsUseColorTemperature: 0
m_DefaultRenderingLayerMask: 1
m_LogWhenShaderIsCompiled: 0
version https://git-lfs.github.com/spec/v1
<<<<<<< HEAD
oid sha256:a06b62f70a65345f430b10b6241693d1e969fbecffb1c158ac330169470fab52
size 3569
=======
oid sha256:442894020eebc9cfeddc7b95f3e637fdcf033513a507e0fbe231a8e0e4f7d60b
size 2230
>>>>>>> 4459f56 (LFS is terrorising me)

52
Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs


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;
}
}
}

3
Assets/BossRoom/Scripts/Server/Game/Action/ReviveAction.cs.meta


fileFormatVersion: 2
guid: 1122d1ad1a0b437c8a0e586ecb64449d
timeCreated: 1610045410
正在加载...
取消
保存