mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
idk 2
This commit is contained in:
129
Assets/GameManager.prefab
Normal file
129
Assets/GameManager.prefab
Normal file
@@ -0,0 +1,129 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3422988367618467032
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3422988367618467043}
|
||||
- component: {fileID: 3422988367618467039}
|
||||
- component: {fileID: 3422988367618467036}
|
||||
- component: {fileID: 3422988367618467037}
|
||||
- component: {fileID: 3422988367618467038}
|
||||
- component: {fileID: -5945522205665126515}
|
||||
m_Layer: 0
|
||||
m_Name: GameManager
|
||||
m_TagString: GameController
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3422988367618467043
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &3422988367618467039
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 26ee7b094ee25bf49aaf5ffba35f8cf6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Players: []
|
||||
localPlayer: {fileID: 0}
|
||||
--- !u!114 &3422988367618467036
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 58bd0a0557e21bf4e8ea0e0cd4e9d057, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
dontDestroyOnLoad: 1
|
||||
PersistNetworkManagerToOfflineScene: 0
|
||||
runInBackground: 1
|
||||
autoStartServerBuild: 1
|
||||
serverTickRate: 30
|
||||
offlineScene: Assets/Scenes/TestOfflineScene.unity
|
||||
onlineScene: Assets/Scenes/TestScene.unity
|
||||
transport: {fileID: 3422988367618467037}
|
||||
networkAddress: localhost
|
||||
maxConnections: 100
|
||||
authenticator: {fileID: 0}
|
||||
playerPrefab: {fileID: 6272346181302961293, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
||||
autoCreatePlayer: 1
|
||||
playerSpawnMethod: 0
|
||||
spawnPrefabs: []
|
||||
--- !u!114 &3422988367618467037
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6b0fecffa3f624585964b0d0eb21b18e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Port: 7777
|
||||
DualMode: 1
|
||||
NoDelay: 1
|
||||
Interval: 10
|
||||
Timeout: 10000
|
||||
FastResend: 2
|
||||
CongestionWindow: 0
|
||||
SendWindowSize: 4096
|
||||
ReceiveWindowSize: 4096
|
||||
NonAlloc: 1
|
||||
debugLog: 1
|
||||
statisticsGUI: 1
|
||||
statisticsLog: 0
|
||||
--- !u!114 &3422988367618467038
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
offsetX: 0
|
||||
offsetY: 0
|
||||
--- !u!114 &-5945522205665126515
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3422988367618467032}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b62b46838717d934483010f517c5b772, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
@@ -12,11 +12,19 @@ using UnityEngine;
|
||||
public class GameMaster : MonoBehaviour
|
||||
{
|
||||
[Header("GameMaster")]
|
||||
<<<<<<< Updated upstream
|
||||
[SerializeField] private List<Player> Players = new List<Player>();
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
=======
|
||||
[SerializeField] private List<Player> Players = new List<Player>();
|
||||
[SerializeField] private int countOfRounds = 10;
|
||||
|
||||
public GameObject localPlayer;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -33,4 +41,13 @@ public class GameMaster : MonoBehaviour
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
18
Assets/Scripts/GameManager/JoinLeaveManager.cs
Normal file
18
Assets/Scripts/GameManager/JoinLeaveManager.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Mirror;
|
||||
using UnityEngine;
|
||||
|
||||
public class JoinLeaveManager : MonoBehaviour
|
||||
{
|
||||
private NetworkManager networkManager;
|
||||
|
||||
public void Join(string ip, string username)
|
||||
{
|
||||
networkManager = GetComponent<NetworkManager>();
|
||||
|
||||
Debug.Log("[JoinLeaveManager] Trying to join server: " + ip + " as " + username);
|
||||
|
||||
networkManager.StartClient();
|
||||
networkManager.networkAddress = ip;
|
||||
Debug.Log("[JoinLeaveManager] " + username + " joined the server: " + ip);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameManager/JoinLeaveManager.cs.meta
Normal file
11
Assets/Scripts/GameManager/JoinLeaveManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b62b46838717d934483010f517c5b772
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,14 +7,26 @@ public class JoinBtnScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_InputField inputIp;
|
||||
[SerializeField] private TMP_InputField inputUsername;
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
private JoinLeaveManager joinLeaveManager;
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(JoinServer);
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
joinLeaveManager = GameObject.Find("GameManager").GetComponent<JoinLeaveManager>();
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
public void JoinServer()
|
||||
{
|
||||
<<<<<<< Updated upstream
|
||||
NetworkClient.Connect(inputIp.text);
|
||||
=======
|
||||
joinLeaveManager.Join(inputIp.text, inputUsername.text);
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user