mirror of
				https://github.com/DerTyp7/defrain-shooter-unity.git
				synced 2025-10-31 05:27:07 +01:00 
			
		
		
		
	idk 2
This commit is contained in:
		| @@ -14,14 +14,16 @@ public class Player : NetworkBehaviour | ||||
|  | ||||
|     [SyncVar(hook = nameof(SetName))] | ||||
|     public string username; | ||||
|  | ||||
|     [SerializeField] GameObject usernameTextObj; | ||||
|  | ||||
|     private int health; | ||||
|     private int kills; | ||||
|     private int deaths; | ||||
|  | ||||
|     public override void OnStartLocalPlayer() | ||||
|     { | ||||
|         base.OnStartClient(); | ||||
|  | ||||
|         //Load Player Username; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public void SetName(string oldName, string newName) | ||||
| @@ -29,100 +31,4 @@ public class Player : NetworkBehaviour | ||||
|         username = newName; | ||||
|         usernameTextObj.GetComponent<TMPro.TextMeshPro>().SetText(username); | ||||
|     } | ||||
|  | ||||
|     public string GetName() | ||||
|     { | ||||
|         return name; | ||||
|     } | ||||
|     public void Respawn() | ||||
|     { | ||||
|         isAlive = true; | ||||
|     } | ||||
|  | ||||
|     public void Die() | ||||
|     { | ||||
|         isAlive = false; | ||||
|         AddDeaths(1); | ||||
|     } | ||||
|  | ||||
|     //Health | ||||
|     public void AddHealth(int value) | ||||
|     { | ||||
|         if (isAlive) | ||||
|         { | ||||
|             health += value; | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     public void RemoveHealth(int value) | ||||
|     { | ||||
|         if (isAlive) | ||||
|         { | ||||
|             health -= value; | ||||
|             if (health <= 0) | ||||
|             { | ||||
|                 AddDeaths(1); | ||||
|                 health = 0; | ||||
|                 Die(); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     public void SetHealth(int value) | ||||
|     { | ||||
|         if (isAlive) | ||||
|         { | ||||
|             health = value; | ||||
|             if (health <= 0) | ||||
|             { | ||||
|                 AddDeaths(1); | ||||
|                 health = 0; | ||||
|                 Die(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public int GetHealth() | ||||
|     { | ||||
|         return health; | ||||
|     } | ||||
|  | ||||
|     //Kills | ||||
|     public void AddKills(int value) | ||||
|     { | ||||
|         kills += value; | ||||
|     } | ||||
|     public void RemoveKills(int value) | ||||
|     { | ||||
|         kills -= value; | ||||
|     } | ||||
|     public void SetKills(int value) | ||||
|     { | ||||
|         kills = value; | ||||
|     } | ||||
|  | ||||
|     public int GetKills() | ||||
|     { | ||||
|         return kills; | ||||
|     } | ||||
|  | ||||
|     //Deaths | ||||
|     public void AddDeaths(int value) | ||||
|     { | ||||
|         deaths += value; | ||||
|     } | ||||
|     public void RemoveDeaths(int value) | ||||
|     { | ||||
|         deaths -= value; | ||||
|     } | ||||
|     public void SetDeaths(int value) | ||||
|     { | ||||
|         deaths = value; | ||||
|     } | ||||
|  | ||||
|     public int GetDeaths() | ||||
|     { | ||||
|         return deaths; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 DerTyp187
					DerTyp187