mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 20:52:10 +01:00
updated mirror added testofflinescene
This commit is contained in:
@@ -9,16 +9,25 @@ public class Player : NetworkBehaviour
|
||||
public Team team;
|
||||
[SerializeField] private const int defaultHp = 100;
|
||||
|
||||
|
||||
public ulong clientId;
|
||||
private string name;
|
||||
|
||||
[SyncVar(hook = nameof(SetName))]
|
||||
public string username;
|
||||
[SerializeField] GameObject usernameTextObj;
|
||||
|
||||
private int health;
|
||||
private int kills;
|
||||
private int deaths;
|
||||
|
||||
|
||||
public void SetName(string newName)
|
||||
public override void OnStartLocalPlayer()
|
||||
{
|
||||
name = newName;
|
||||
base.OnStartClient();
|
||||
}
|
||||
|
||||
public void SetName(string oldName, string newName)
|
||||
{
|
||||
username = newName;
|
||||
usernameTextObj.GetComponent<TMPro.TextMeshPro>().SetText(username);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
|
||||
28
Assets/Scripts/Player/PlayerColor.cs
Normal file
28
Assets/Scripts/Player/PlayerColor.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
public class PlayerColor : NetworkBehaviour
|
||||
{
|
||||
[SyncVar(hook = "SetColor")]
|
||||
public Color color;
|
||||
public Renderer renderer;
|
||||
|
||||
void SetColor(Color oldColor, Color newColor)
|
||||
{
|
||||
if (color == null)
|
||||
{
|
||||
color = renderer.material.color;
|
||||
}
|
||||
|
||||
renderer.material.color = newColor;
|
||||
color = newColor;
|
||||
|
||||
}
|
||||
|
||||
public override void OnStartClient()
|
||||
{
|
||||
renderer.material.color = color;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Player/PlayerColor.cs.meta
Normal file
11
Assets/Scripts/Player/PlayerColor.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00dc60b61b501f2419e2abd7158be5f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user