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:
@@ -22,6 +22,7 @@ public class GameMaster : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.H))
|
||||
{
|
||||
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
8
Assets/Scripts/TestOfflineScene.meta
Normal file
8
Assets/Scripts/TestOfflineScene.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4afae0198a9648843bad3b58b765e01e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/TestOfflineScene/HostBtnScript.cs
Normal file
16
Assets/Scripts/TestOfflineScene/HostBtnScript.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TestOfflineScene/HostBtnScript.cs.meta
Normal file
11
Assets/Scripts/TestOfflineScene/HostBtnScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5976e078a6233fa4f881ca82c0c320ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/Scripts/TestOfflineScene/JoinBtnScript.cs
Normal file
20
Assets/Scripts/TestOfflineScene/JoinBtnScript.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TestOfflineScene/JoinBtnScript.cs.meta
Normal file
11
Assets/Scripts/TestOfflineScene/JoinBtnScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0e1cb5cdbbf01e48a053873229fda16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user