MB 5 years ago
parent
commit
f46db2b6c4
11 changed files with 88 additions and 201 deletions
  1. +2
    -1
      Assets/Scenes/ClientScene.unity
  2. +30
    -6
      Assets/Scenes/LobbyScene.unity
  3. +2
    -173
      Assets/Scenes/TestScene.unity
  4. +14
    -1
      Assets/Scipts/Multiplayer/Client/ClientLoginManager.cs
  5. +0
    -8
      Assets/Scipts/Multiplayer/Client/LobbyManager.cs
  6. +18
    -0
      Assets/Scipts/Multiplayer/Server/LoginManager.cs
  7. +0
    -9
      Assets/Scipts/Multiplayer/Server/ServerManager.cs
  8. +8
    -0
      Assets/Scipts/UI.meta
  9. +11
    -0
      Assets/Scipts/UI/LobbyUIController.cs
  10. +1
    -1
      Assets/Scipts/UI/LobbyUIController.cs.meta
  11. +2
    -2
      ProjectSettings/EditorBuildSettings.asset

+ 2
- 1
Assets/Scenes/ClientScene.unity View File

@ -145,7 +145,8 @@ MonoBehaviour:
ServerAddress: 10.17.38.221
Port: 4444
ConnectOnStart: 0
GameSceneName: MainScene
LobbyScene: LobbyScene
GameScene: TestScene
Name: The most nardish of players
IsConnected: 0
ID: 0

+ 30
- 6
Assets/Scenes/LobbyScene.unity View File

@ -124,6 +124,7 @@ GameObject:
- component: {fileID: 919644062}
- component: {fileID: 919644061}
- component: {fileID: 919644060}
- component: {fileID: 919644064}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@ -208,6 +209,17 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &919644064
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 919644059}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 405724f17a9fdf7498f87dfdb5dbcb9e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1007511397
GameObject:
m_ObjectHideFlags: 0
@ -284,7 +296,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1007511400}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 919644064}
m_MethodName: OnClickStartGame
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &1007511400
@ -333,7 +356,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_AspectMode: 0
m_AspectRatio: 3.3936446
m_AspectRatio: 4.5044775
--- !u!1 &1535509334
GameObject:
m_ObjectHideFlags: 0
@ -363,10 +386,11 @@ MonoBehaviour:
m_EditorClassIdentifier:
SetSingletonOnAwake: 1
isPersistant: 1
LocalPlayerPrefab: {fileID: 1359508890942550, guid: 88f2120ea01cef248ba929e8eea4c759,
LocalPlayerPrefab: {fileID: 1067952265812482, guid: db2d9f4b5a72e5a47a7dd9f0d1fa1e43,
type: 2}
RemotePlayerPrefab: {fileID: 1737980672629790, guid: bdf6a76720f2a98408b6639537d99358,
RemotePlayerPrefab: {fileID: 1899238032005644, guid: 35b69a93d1dd9c24fbf2ba57dfc4aafb,
type: 2}
LocalPlayer: {fileID: 0}
--- !u!4 &1535509336
Transform:
m_ObjectHideFlags: 0
@ -600,7 +624,7 @@ MonoBehaviour:
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 22.55
m_fontSize: 30.05
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 1
@ -708,7 +732,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 196.71722, y: 0}
m_SizeDelta: {x: 0, y: 4.710968}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1973300969
MonoBehaviour:

+ 2
- 173
Assets/Scenes/TestScene.unity View File

@ -113,91 +113,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &6342918
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6342922}
- component: {fileID: 6342921}
- component: {fileID: 6342920}
- component: {fileID: 6342919}
m_Layer: 0
m_Name: Sphere (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!135 &6342919
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 6342918}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &6342920
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 6342918}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &6342921
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 6342918}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &6342922
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 6342918}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &695038879
GameObject:
m_ObjectHideFlags: 0
@ -279,7 +194,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 695038879}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: -1.95, z: 0}
m_LocalScale: {x: 2, y: 2, z: 2}
m_Children: []
m_Father: {fileID: 0}
@ -428,91 +343,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 39.144, y: 0, z: 0}
--- !u!1 &1713353743
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1713353747}
- component: {fileID: 1713353746}
- component: {fileID: 1713353745}
- component: {fileID: 1713353744}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!135 &1713353744
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1713353743}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &1713353745
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1713353743}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1713353746
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1713353743}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1713353747
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1713353743}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -10, y: 0.04, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2130458414
GameObject:
m_ObjectHideFlags: 0
@ -546,8 +376,7 @@ MonoBehaviour:
type: 2}
RemotePlayerPrefab: {fileID: 1737980672629790, guid: bdf6a76720f2a98408b6639537d99358,
type: 2}
mapTop: {x: 10, y: 1, z: 10}
mapBot: {x: -10, y: 1, z: -10}
LocalPlayer: {fileID: 0}
--- !u!4 &2130458416
Transform:
m_ObjectHideFlags: 0

+ 14
- 1
Assets/Scipts/Multiplayer/Client/ClientLoginManager.cs View File

@ -22,6 +22,8 @@ namespace Multiplayer
ClientManager.Client.RegisterHandler(MsgType.Connect, OnConnected);
ClientManager.Client.RegisterHandler(MsgType.Disconnect, OnDisconnected);
ClientManager.Client.RegisterHandler(LoginMsgID.QueryName, OnRecieveID);
ClientManager.Client.RegisterHandler(LoginMsgID.EnterLobby, StartLobby);
ClientManager.Client.RegisterHandler(PlayerMsgID.GameStart, StartGame);
}
private void OnConnected(NetworkMessage msg)
@ -46,12 +48,23 @@ namespace Multiplayer
ClientManager.ID = playerMsg.ID;
ClientManager.SendMessage(LoginMsgID.Name, new StringMsg(ClientManager.ID, ClientManager.Name));
StartLobby();
}
private void GoToLobby()
private void StartLobby(NetworkMessage msg)
{
StartLobby();
}
private void StartLobby()
{
UnityEngine.SceneManagement.SceneManager.LoadScene(ClientManager.LobbyScene);
}
private void StartGame(NetworkMessage msg)
{
UnityEngine.SceneManagement.SceneManager.LoadScene(ClientManager.GameScene);
}
}
}

+ 0
- 8
Assets/Scipts/Multiplayer/Client/LobbyManager.cs View File

@ -1,8 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LobbyManager : MonoBehaviour {
}

+ 18
- 0
Assets/Scipts/Multiplayer/Server/LoginManager.cs View File

@ -23,6 +23,7 @@ namespace Multiplayer
ServerManager.Server.RegisterHandler(LoginMsgID.Name, OnPlayerLogin);
ServerManager.Server.RegisterHandler(MsgType.Connect, OnConnect);
ServerManager.Server.RegisterHandler(MsgType.Disconnect, OnDisconnect);
ServerManager.Server.RegisterHandler(PlayerMsgID.GameStart, ClientStartsGame);
}
@ -62,6 +63,23 @@ namespace Multiplayer
else
Debug.Log("Unkown player has disconnected.");
}
private void ClientStartsGame(NetworkMessage msg)
{
StartGame();
}
private void StartGame()
{
foreach (Player player in ServerManager.AllPlayers.Values)
player.Connection.Send(PlayerMsgID.GameStart, new PlayerMsg(player.ID));
}
private void GoToLobby()
{
foreach(Player player in ServerManager.AllPlayers.Values)
player.Connection.Send(PlayerMsgID.Lobby, new PlayerMsg(player.ID));
}
}
}

+ 0
- 9
Assets/Scipts/Multiplayer/Server/ServerManager.cs View File

@ -52,15 +52,6 @@ namespace Multiplayer
Server.Listen(Port);
}
[ContextMenu("Start Game")]
public void StartGame()
{
foreach (Player player in AllPlayers.Values)
{
player.Connection.Send(PlayerMsgID.Lobby, new PlayerMsg(player.ID));
}
}
private void Update()
{
if (Server != null)

+ 8
- 0
Assets/Scipts/UI.meta View File

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

+ 11
- 0
Assets/Scipts/UI/LobbyUIController.cs View File

@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LobbyUIController : MonoBehaviour {
public void OnClickStartGame()
{
Multiplayer.ClientManager.Instance.SendMessage(Multiplayer.PlayerMsgID.GameStart, new Multiplayer.PlayerMsg(Multiplayer.ClientManager.Instance.ID));
}
}

Assets/Scipts/Multiplayer/Client/LobbyManager.cs.meta → Assets/Scipts/UI/LobbyUIController.cs.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ad5b0dc1c78c8064b95e9ba337a3c50d
guid: 405724f17a9fdf7498f87dfdb5dbcb9e
MonoImporter:
externalObjects: {}
serializedVersion: 2

+ 2
- 2
ProjectSettings/EditorBuildSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f182faa74c5ed42826273c1aa3fa86e317c6b7e71f9d22f4ea0a329d03f90c21
size 355
oid sha256:c64c0a8ab387e76ea0a66bea48669e6993ffdbbc6c34f74a7fabe55bd6e8ca93
size 552

Loading…
Cancel
Save