浏览代码

stubs for main menu scene

/main
David Woodruff 4 年前
当前提交
5aa6f236
共有 22 个文件被更改,包括 1314 次插入8 次删除
  1. 8
      ProjectSettings/EditorBuildSettings.asset
  2. 1001
      Assets/Scenes/MainMenu.unity
  3. 7
      Assets/Scenes/MainMenu.unity.meta
  4. 8
      Assets/Scripts/Client.meta
  5. 8
      Assets/Scripts/Shared.meta
  6. 8
      Assets/Scripts/Client/UI.meta
  7. 38
      Assets/Scripts/Client/UI/MainMenuUI.cs
  8. 11
      Assets/Scripts/Client/UI/MainMenuUI.cs.meta
  9. 8
      Assets/Scripts/Shared/Net.meta
  10. 25
      Assets/Scripts/Shared/Net/GNH_Client.cs
  11. 11
      Assets/Scripts/Shared/Net/GNH_Client.cs.meta
  12. 26
      Assets/Scripts/Shared/Net/GNH_Server.cs
  13. 11
      Assets/Scripts/Shared/Net/GNH_Server.cs.meta
  14. 97
      Assets/Scripts/Shared/Net/GameNetHub.cs
  15. 11
      Assets/Scripts/Shared/Net/GameNetHub.cs.meta
  16. 26
      Assets/Scripts/Shared/Net/StartupManager.cs
  17. 11
      Assets/Scripts/Shared/Net/StartupManager.cs.meta
  18. 7
      Packages/com.unity.multiplayer.transport.litenet/Runtime/LiteNetLib/LiteNetLib.csproj.meta

8
ProjectSettings/EditorBuildSettings.asset


EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
m_Scenes:
- enabled: 1
path: Assets/Scenes/MainMenu.unity
guid: 4b62455423c0e284f96f7fd6ac947bf9
- enabled: 1
path: Assets/Scenes/SampleScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
m_configObjects: {}

1001
Assets/Scenes/MainMenu.unity
文件差异内容过多而无法显示
查看文件

7
Assets/Scenes/MainMenu.unity.meta


fileFormatVersion: 2
guid: 4b62455423c0e284f96f7fd6ac947bf9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Client.meta


fileFormatVersion: 2
guid: 422ec0f4d28e6d4468624a9c76adab77
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Shared.meta


fileFormatVersion: 2
guid: 43b21ee40bbd5b642a7ba927b1ae59fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Client/UI.meta


fileFormatVersion: 2
guid: 3d8dd27d96315be4c9c7413bc17b82c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

38
Assets/Scripts/Client/UI/MainMenuUI.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainMenuUI : MonoBehaviour
{
public GameObject NetHostGO;
private MLAPI.NetworkingManager m_netManager;
// Start is called before the first frame update
void Start()
{
m_netManager = NetHostGO.GetComponent<MLAPI.NetworkingManager>();
}
// Update is called once per frame
void Update()
{
}
public void OnHostClicked()
{
Debug.Log("Host Clicked");
//TODO: bring up transition screen.
m_netManager.StartHost();
UnityEngine.SceneManagement.SceneManager.LoadScene("SampleScene", UnityEngine.SceneManagement.LoadSceneMode.Single);
}
public void OnConnectClicked()
{
Debug.Log("Connect Clicked");
}
}

11
Assets/Scripts/Client/UI/MainMenuUI.cs.meta


fileFormatVersion: 2
guid: f6144e8dd0fc8ec4cb23a1a49059aa08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scripts/Shared/Net.meta


fileFormatVersion: 2
guid: aa3c75122fab71d4189f666de0192dc6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Scripts/Shared/Net/GNH_Client.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BossRoom
{
/// <summary>
/// Client logic for the GameNetHub. Contains implementations for all of GameNetHub's S2C RPCs.
/// </summary>
public class GNH_Client
{
private GameNetHub m_hub;
public GNH_Client(GameNetHub hub)
{
m_hub = hub;
}
public void RecvConnectFinished(string targetScene, ConnectStatus status )
{
//TBD: switch to target scene.
}
}
}

11
Assets/Scripts/Shared/Net/GNH_Client.cs.meta


fileFormatVersion: 2
guid: 5bd31edc1b1fd1342b3bf8193a5a03b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Scripts/Shared/Net/GNH_Server.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BossRoom
{
public class GNH_Server
{
private GameNetHub m_hub;
public GNH_Server(GameNetHub hub)
{
m_hub = hub;
}
public void RecvRequestConnect(string guid, ulong clientId)
{
//TODO: maintain a mapping of clientID to GUID, and handle the reconnect case.
//for the moment, just accept the change and point the client to "SampleScene". We will replace this
//with logic that selects between the Load
m_hub.S2C_ConnectFinished(clientId, "SampleScene", ConnectStatus.CONNECT);
}
}
}

11
Assets/Scripts/Shared/Net/GNH_Server.cs.meta


fileFormatVersion: 2
guid: 54b0859a1da930541adf0b2d1bb8d977
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

97
Assets/Scripts/Shared/Net/GameNetHub.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BossRoom
{
public enum ConnectStatus
{
CONNECT, //client successfully connected. This may also be a successful reconnect.
ESERVERFULL, //can't join, server is already at capacity.
EMATCHSTARTED, //can't join, match is already in progress.
EUNKNOWN //can't join, reason unknown.
}
/// <summary>
/// The GameNetHub is a general-purpose relay for game network messages between the client and server. It is available
/// as soon as the initial network connection has completed, and persists across all scenes. Its purpose is to move non-GameObject-specific
/// methods between server and client. Generally these have to do with connection, and match end conditions.
/// </summary>
///
/// <remarks
/// Why is there a RequestConnect call-and-response here? How is that different from the "ApprovalCheck" logic that MLAPI optionally runs
/// when establishing a new client connection?
/// In short, the connection flow in this class happens second after the logic embodied by StartClient runs (and after the client has seen
/// NetworkStart fire). We need to provide an initial dump of info when a client logs in, specifically what scene to transition to. We would need
/// this message even if we used ConnectionData to send up our client GUID--because of that, it makes more sense to keep the two RPCs here, as
/// a 2nd step in the login flow.
///
/// Why do we need to send a client GUID? What is it? Don't we already have a clientID?
/// ClientIDs are assigned on login. If you connect to a server, then your connection drops, and you reconnect, you get a new ClientID. This
/// makes it awkward to get back your old character, which the server is going to hold onto for a fixed timeout. To properly reconnect and recover
/// your character, you need a persistent identifier for your own client install. We solve that by generating a random GUID and storing it
/// in player prefs, so it persists across sessions of the game.
/// </remarks>
///
public class GameNetHub : MLAPI.NetworkedBehaviour
{
public GameObject NetworkingManagerGO;
private GNH_Client m_clientLogic;
private GNH_Server m_serverLogic;
public MLAPI.NetworkingManager NetManager { get; private set; }
// Start is called before the first frame update
void Start()
{
Object.DontDestroyOnLoad(this.gameObject);
Object.DontDestroyOnLoad(NetworkingManagerGO);
NetManager = NetworkingManagerGO.GetComponent<MLAPI.NetworkingManager>();
}
public override void NetworkStart()
{
if( NetManager.IsServer )
{
m_serverLogic = new GNH_Server(this);
}
else if( NetManager.IsClient )
{
m_clientLogic = new GNH_Client(this);
}
else
{
Debug.LogError("NetworkStart invoked, but NetworkingManager is neither server nor client");
}
}
//Server->Client RPCs
public void S2C_ConnectResult( ulong netId, ConnectStatus status )
{
InvokeClientRpcOnClient("RecvConnectResult", netId, status);
}
[MLAPI.Messaging.ClientRPC]
private void RecvConnectFinished( ConnectStatus status )
{
m_clientLogic.RecvConnectFinished( status);
}
//Client->Server
public void C2S_RequestConnect( string guid )
{
InvokeServerRpc("RecvRequestConnect", guid, NetManager.LocalClientId, MLAPI.Security.SecuritySendFlags.None);
}
[MLAPI.Messaging.ServerRPC(RequireOwnership = false)]
private void RecvRequestConnect( string guid, ulong clientId )
{
}
}
}

11
Assets/Scripts/Shared/Net/GameNetHub.cs.meta


fileFormatVersion: 2
guid: 7ba4a1d598313d94a81a08ceae147b57
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Scripts/Shared/Net/StartupManager.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This class manages the network startup flow in the MainMenu, when the user has selected
/// either "Connect" or "Host". In the case of "Host", the flow isn't very interesting--you just start
/// up the NetworkingManager in host mode and switch to the target scene.
///
/// In Connect mode, however, things are a bit more interesting. We must not only begin via the initial StartClient, but
/// also receive the first S2C RPC telling us what Scene to go to.
/// </summary>
public class StartupManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

11
Assets/Scripts/Shared/Net/StartupManager.cs.meta


fileFormatVersion: 2
guid: 4703759d077152c4db03d0b623e23e9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

7
Packages/com.unity.multiplayer.transport.litenet/Runtime/LiteNetLib/LiteNetLib.csproj.meta


fileFormatVersion: 2
guid: 11c9a199da28e0144b82a7c9dbd440be
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存