added PlayerClass with Sync

This commit is contained in:
DerTyp187
2021-10-14 20:16:38 +02:00
parent e057a569a5
commit 666e4f479f
5 changed files with 65 additions and 1 deletions

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