mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2026-07-31 07:29:02 +02:00
idk
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using Mirror;
|
||||
|
||||
|
||||
// Erstellung von Teams
|
||||
@@ -12,10 +12,10 @@ using UnityEngine;
|
||||
public class GameMaster : MonoBehaviour
|
||||
{
|
||||
[Header("GameMaster")]
|
||||
[SerializeField] private List<Player> Players = new List<Player>();
|
||||
[SerializeField] private List<Player> Players = new List<Player>();
|
||||
public GameObject localPlayer;
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -33,4 +33,8 @@ public class GameMaster : MonoBehaviour
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
15
Assets/Scripts/GameManager/Manager.cs
Normal file
15
Assets/Scripts/GameManager/Manager.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
public class Manager : NetworkManager
|
||||
{
|
||||
public override void OnClientConnect(NetworkConnection conn)
|
||||
{
|
||||
base.OnClientConnect(conn);
|
||||
//Debug.Log(conn.identity.gameObject.GetComponent<Player>().username);
|
||||
|
||||
//conn.identity.gameObject.GetComponent<Player>().username = "Test";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameManager/Manager.cs.meta
Normal file
11
Assets/Scripts/GameManager/Manager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58bd0a0557e21bf4e8ea0e0cd4e9d057
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/SaveData.cs
Normal file
29
Assets/Scripts/SaveData.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SaveData : MonoBehaviour
|
||||
{
|
||||
[SerializeField] PlayerData _PlayerData = new PlayerData();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(SavePlayerToJson);
|
||||
}
|
||||
|
||||
public void SavePlayerToJson()
|
||||
{
|
||||
string playerData = JsonUtility.ToJson(_PlayerData);
|
||||
|
||||
System.IO.File.WriteAllText(Application.persistentDataPath + "/PlayerData.json", playerData);
|
||||
Debug.Log(Application.persistentDataPath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerData
|
||||
{
|
||||
public string username;
|
||||
}
|
||||
11
Assets/Scripts/SaveData.cs.meta
Normal file
11
Assets/Scripts/SaveData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039d8e4cae766214180c87269a6218db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,13 +4,15 @@ using UnityEngine;
|
||||
|
||||
public class HostBtnScript : MonoBehaviour
|
||||
{
|
||||
private GameObject GameManager;
|
||||
private void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(HostServer);
|
||||
GameManager = GameObject.Find("GameManager");
|
||||
}
|
||||
|
||||
public void HostServer()
|
||||
{
|
||||
NetworkClient.ConnectHost();
|
||||
GameManager.GetComponent<NetworkManager>().StartHost();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,22 @@ public class JoinBtnScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_InputField inputIp;
|
||||
[SerializeField] private TMP_InputField inputUsername;
|
||||
private GameObject GameManager;
|
||||
private NetworkManager networkManager;
|
||||
public GameObject localPlayer;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(JoinServer);
|
||||
GameManager = GameObject.Find("GameManager");
|
||||
networkManager = GameManager.GetComponent<NetworkManager>();
|
||||
}
|
||||
|
||||
public void JoinServer()
|
||||
{
|
||||
NetworkClient.Connect(inputIp.text);
|
||||
networkManager.StartClient();
|
||||
networkManager.networkAddress = inputIp.text;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user