From e6b688aafe000d497f636af2e6965d229b31f49d Mon Sep 17 00:00:00 2001 From: AderKonstantin Date: Mon, 9 Dec 2024 13:49:14 +0300 Subject: [PATCH] feat: add NetworkVariables for PlayerPrefab --- .../Scripts/Runtime/Core/Classes/Trooper.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Assets/Scripts/Runtime/Core/Classes/Trooper.cs b/Assets/Scripts/Runtime/Core/Classes/Trooper.cs index d4baffc..9397438 100644 --- a/Assets/Scripts/Runtime/Core/Classes/Trooper.cs +++ b/Assets/Scripts/Runtime/Core/Classes/Trooper.cs @@ -8,6 +8,21 @@ public class Trooper : RobotController // Dev Debug Staff [SerializeField] Canvas screenSpaceCanvas; + [Header("Gameplay Variables")] + private NetworkVariable healthPoints = new NetworkVariable(); + public int HealthPoints { get { return healthPoints.Value; } set { healthPoints.Value = value; } } + + private NetworkVariable armorPoints = new NetworkVariable(); + public int ArmorPoints { get { return armorPoints.Value; } set { armorPoints.Value = value; } } + + private NetworkVariable ammoPoints = new NetworkVariable(); + public int AmmoPoints { get { return ammoPoints.Value; } set { ammoPoints.Value = value; } } + + [SerializeField] private int initialHP = 100; + public int InitialHP { get => initialHP; set => initialHP = value; } + + [SerializeField] private int initialArmor = 100; + public int InitialArmor { get => initialArmor; set => initialArmor = value; } // Gameplay - Scene Awake & Start private void Awake() { @@ -44,7 +59,11 @@ public class Trooper : RobotController audioListener.enabled = IsOwner; screenSpaceCanvas.enabled = IsOwner; + // Game Variables + healthPoints.Value = InitialHP; + Debug.Log($"NetworkObject ID: {NetworkObjectId} spawned with OwnerClientId: {OwnerClientId}"); + Debug.Log($"HP of OwnerClientID: {OwnerClientId} is {healthPoints.Value} when spawned."); } public override void OnNetworkDespawn()