mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
added PlayerClass with Sync
This commit is contained in:
35
Assets/Scripts/Player/Player.cs
Normal file
35
Assets/Scripts/Player/Player.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
[SerializeField] int health;
|
||||
[SerializeField] float SyncIntervalSeconds = 5.0f;
|
||||
[SerializeField] GameObject GameManager;
|
||||
|
||||
private PlayerMaster playerMaster;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
playerMaster = GameManager.GetComponent<PlayerMaster>();
|
||||
InvokeRepeating("Sync", 3.0f, SyncIntervalSeconds);
|
||||
}
|
||||
|
||||
|
||||
private void Sync()
|
||||
{
|
||||
Debug.Log("Sync");
|
||||
health = playerMaster.GetHealthOfPlayer(gameObject);
|
||||
}
|
||||
|
||||
public void SubstractHealth(int value)
|
||||
{
|
||||
health -= value;
|
||||
}
|
||||
|
||||
public void AddHealth(int value)
|
||||
{
|
||||
health += value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user