updated mirror added testofflinescene

This commit is contained in:
DerTyp187
2021-10-25 13:03:25 +02:00
parent 93244c5160
commit 5921e33205
18 changed files with 2551 additions and 14 deletions

View File

@@ -22,6 +22,7 @@ public class GameMaster : MonoBehaviour
{
if (Input.GetKeyDown(KeyCode.H))
{
Cursor.lockState = CursorLockMode.Confined;
Cursor.visible = true;
}

View File

@@ -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()

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

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 00dc60b61b501f2419e2abd7158be5f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4afae0198a9648843bad3b58b765e01e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using Mirror;
using UnityEngine.UI;
using UnityEngine;
public class HostBtnScript : MonoBehaviour
{
private void Start()
{
gameObject.GetComponent<Button>().onClick.AddListener(HostServer);
}
public void HostServer()
{
NetworkClient.ConnectHost();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5976e078a6233fa4f881ca82c0c320ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using Mirror;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class JoinBtnScript : MonoBehaviour
{
[SerializeField] private TMP_InputField inputIp;
[SerializeField] private TMP_InputField inputUsername;
private void Start()
{
gameObject.GetComponent<Button>().onClick.AddListener(JoinServer);
}
public void JoinServer()
{
NetworkClient.Connect(inputIp.text);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0e1cb5cdbbf01e48a053873229fda16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: