mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-11-04 07:08:59 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			731 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			731 B
		
	
	
	
		
			C#
		
	
	
	
	
	
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.SyncHealth(gameObject);
 | 
						|
    }
 | 
						|
 | 
						|
    public void SubstractHealth(int value)
 | 
						|
    {
 | 
						|
        health -= value;
 | 
						|
    }
 | 
						|
 | 
						|
    public void AddHealth(int value)
 | 
						|
    {
 | 
						|
        health += value;
 | 
						|
    }
 | 
						|
}
 |