spawn ships
This commit is contained in:
Родитель
5c72eb5ade
Коммит
f0a952fd07
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a4c98355d3b704ef99f71b957061b12b
|
guid: 573df92b82ee77c448f181821d617c60
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: c743ae24ee231884887054d20ccdd0ab
|
guid: ae15a6df40454a446bd8a73356a71a51
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 68c7e4565cde54155bb78d8e935f1ddb
|
guid: 429a6edf064b6534ba4940f6ff4c1526
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 863e1b9976c4e46d29bf83928b3a8ab2
|
guid: a3f0f0e72b185664aab3424af9461349
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
iconMap: {}
|
iconMap: {}
|
||||||
executionOrder: {}
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
isPreloaded: 0
|
isPreloaded: 0
|
||||||
isOverridable: 0
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
platformData:
|
platformData:
|
||||||
- first:
|
- first:
|
||||||
Any:
|
Any:
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 99b48d4d4f6a66340ab06bd487d70a45
|
|
||||||
folderAsset: yes
|
|
||||||
timeCreated: 1493304320
|
|
||||||
licenseType: Store
|
|
||||||
DefaultImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
|
@ -54,7 +54,7 @@ LightmapSettings:
|
||||||
m_EnableBakedLightmaps: 0
|
m_EnableBakedLightmaps: 0
|
||||||
m_EnableRealtimeLightmaps: 0
|
m_EnableRealtimeLightmaps: 0
|
||||||
m_LightmapEditorSettings:
|
m_LightmapEditorSettings:
|
||||||
serializedVersion: 10
|
serializedVersion: 12
|
||||||
m_Resolution: 2
|
m_Resolution: 2
|
||||||
m_BakeResolution: 40
|
m_BakeResolution: 40
|
||||||
m_AtlasSize: 1024
|
m_AtlasSize: 1024
|
||||||
|
@ -62,6 +62,7 @@ LightmapSettings:
|
||||||
m_AOMaxDistance: 1
|
m_AOMaxDistance: 1
|
||||||
m_CompAOExponent: 1
|
m_CompAOExponent: 1
|
||||||
m_CompAOExponentDirect: 0
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAmbientOcclusion: 0
|
||||||
m_Padding: 2
|
m_Padding: 2
|
||||||
m_LightmapParameters: {fileID: 0}
|
m_LightmapParameters: {fileID: 0}
|
||||||
m_LightmapsBakeMode: 1
|
m_LightmapsBakeMode: 1
|
||||||
|
@ -76,10 +77,16 @@ LightmapSettings:
|
||||||
m_PVRDirectSampleCount: 32
|
m_PVRDirectSampleCount: 32
|
||||||
m_PVRSampleCount: 500
|
m_PVRSampleCount: 500
|
||||||
m_PVRBounces: 2
|
m_PVRBounces: 2
|
||||||
|
m_PVREnvironmentSampleCount: 500
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_PVRFilteringMode: 2
|
||||||
|
m_PVRDenoiserTypeDirect: 0
|
||||||
|
m_PVRDenoiserTypeIndirect: 0
|
||||||
|
m_PVRDenoiserTypeAO: 0
|
||||||
m_PVRFilterTypeDirect: 0
|
m_PVRFilterTypeDirect: 0
|
||||||
m_PVRFilterTypeIndirect: 0
|
m_PVRFilterTypeIndirect: 0
|
||||||
m_PVRFilterTypeAO: 0
|
m_PVRFilterTypeAO: 0
|
||||||
m_PVRFilteringMode: 1
|
m_PVREnvironmentMIS: 0
|
||||||
m_PVRCulling: 1
|
m_PVRCulling: 1
|
||||||
m_PVRFilteringGaussRadiusDirect: 1
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
m_PVRFilteringGaussRadiusIndirect: 5
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
@ -87,7 +94,9 @@ LightmapSettings:
|
||||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
m_ShowResolutionOverlay: 1
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
m_LightingDataAsset: {fileID: 0}
|
m_LightingDataAsset: {fileID: 0}
|
||||||
m_UseShadowmask: 1
|
m_UseShadowmask: 1
|
||||||
--- !u!196 &4
|
--- !u!196 &4
|
||||||
|
@ -150,9 +159,10 @@ Camera:
|
||||||
m_ClearFlags: 1
|
m_ClearFlags: 1
|
||||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||||
m_projectionMatrixMode: 1
|
m_projectionMatrixMode: 1
|
||||||
|
m_GateFitMode: 2
|
||||||
|
m_FOVAxisMode: 0
|
||||||
m_SensorSize: {x: 36, y: 24}
|
m_SensorSize: {x: 36, y: 24}
|
||||||
m_LensShift: {x: 0, y: 0}
|
m_LensShift: {x: 0, y: 0}
|
||||||
m_GateFitMode: 2
|
|
||||||
m_FocalLength: 50
|
m_FocalLength: 50
|
||||||
m_NormalizedViewPortRect:
|
m_NormalizedViewPortRect:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
@ -204,6 +214,8 @@ GameObject:
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 2104027225}
|
- component: {fileID: 2104027225}
|
||||||
- component: {fileID: 2104027224}
|
- component: {fileID: 2104027224}
|
||||||
|
- component: {fileID: 2104027226}
|
||||||
|
- component: {fileID: 2104027227}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameManager
|
m_Name: GameManager
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -223,11 +235,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 08c5abc1c8bd9d7428048b5bc932bc87, type: 3}
|
m_Script: {fileID: 11500000, guid: 08c5abc1c8bd9d7428048b5bc932bc87, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_users:
|
email: bleh@blah.com
|
||||||
- email: hello@world.com
|
|
||||||
password: password
|
|
||||||
- email: goodbye@world.com
|
|
||||||
password: password
|
|
||||||
--- !u!4 &2104027225
|
--- !u!4 &2104027225
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -242,3 +250,29 @@ Transform:
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &2104027226
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2104027223}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7408efdfffadbb84b9f5def253d85577, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_shipPrefab: {fileID: 8291833512214639835, guid: 584333c77fccb9944a3793d4e4cb7c65,
|
||||||
|
type: 3}
|
||||||
|
--- !u!114 &2104027227
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2104027223}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 819a13b084a12774eb665e3ff85ee4f6, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
|
|
@ -309,6 +309,51 @@ PrefabInstance:
|
||||||
m_RemovedComponents:
|
m_RemovedComponents:
|
||||||
- {fileID: 8579451657641387260, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
- {fileID: 8579451657641387260, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
||||||
|
--- !u!1 &1491314831
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1491314833}
|
||||||
|
- component: {fileID: 1491314832}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameManager
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &1491314832
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1491314831}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7408efdfffadbb84b9f5def253d85577, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_shipPrefab: {fileID: 8291833512214639835, guid: 584333c77fccb9944a3793d4e4cb7c65,
|
||||||
|
type: 3}
|
||||||
|
--- !u!4 &1491314833
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1491314831}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: -10}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &1501938911
|
--- !u!1001 &1501938911
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -10,50 +10,22 @@ using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace FootRoids
|
namespace FootRoids
|
||||||
{
|
{
|
||||||
[Serializable]
|
|
||||||
public struct FakeUser
|
|
||||||
{
|
|
||||||
public string email;
|
|
||||||
public string password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FakeMatchmaker : MonoBehaviour
|
public class FakeMatchmaker : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] FakeUser[] m_Users = null;
|
|
||||||
readonly IClient m_Client = new Client("http", "207.254.17.33", 7350, "defaultkey");
|
|
||||||
List<ISocket> m_Sockets = new List<ISocket>();
|
|
||||||
IMatch m_Match;
|
IMatch m_Match;
|
||||||
|
[SerializeField] private string m_email = "one@one.com";
|
||||||
|
|
||||||
async void Start()
|
async void Start() {
|
||||||
{
|
var client = ServerSessionManager.Instance.Client;
|
||||||
foreach (var user in m_Users)
|
ServerSessionManager.Instance.Session = await client.AuthenticateEmailAsync(m_email, "password");
|
||||||
{
|
ServerSessionManager.Instance.Socket.ReceivedMatchmakerMatched += MatchmakerMatched;
|
||||||
ServerSessionManager.Instance.Session = await m_Client.AuthenticateEmailAsync(user.email, user.password);
|
|
||||||
ServerSessionManager.Instance.Socket = m_Client.NewSocket();
|
|
||||||
|
|
||||||
ServerSessionManager.Instance.Socket.Connected += () => { Debug.Log("Socket Connected!"); };
|
await ServerSessionManager.Instance.Socket.ConnectAsync(ServerSessionManager.Instance.Session);
|
||||||
|
await ServerSessionManager.Instance.Socket.AddMatchmakerAsync("*", 2, 2);
|
||||||
ServerSessionManager.Instance.Socket.Closed += () => { Debug.Log("Socket Closed!"); };
|
|
||||||
|
|
||||||
ServerSessionManager.Instance.Socket.ReceivedChannelMessage += (message) => { Debug.Log("Message Received: " + message); };
|
|
||||||
|
|
||||||
ServerSessionManager.Instance.Socket.ReceivedMatchmakerMatched += MatchmakerMatched;
|
|
||||||
|
|
||||||
ServerSessionManager.Instance.Socket.ReceivedMatchState += async (state) =>
|
|
||||||
{
|
|
||||||
Debug.Log("Received Message From Server: " + state.State);
|
|
||||||
};
|
|
||||||
|
|
||||||
await ServerSessionManager.Instance.Socket.ConnectAsync(ServerSessionManager.Instance.Session);
|
|
||||||
await ServerSessionManager.Instance.Socket.AddMatchmakerAsync("*", 2, 2);
|
|
||||||
m_Sockets.Add(ServerSessionManager.Instance.Socket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatchmakerMatched(IMatchmakerMatched matched)
|
void MatchmakerMatched(IMatchmakerMatched matched)
|
||||||
{
|
{
|
||||||
Debug.Log("Matched!");
|
|
||||||
|
|
||||||
UnityMainThreadDispatcher.Instance().Enqueue(() =>
|
UnityMainThreadDispatcher.Instance().Enqueue(() =>
|
||||||
{
|
{
|
||||||
ISocket socket = ServerSessionManager.Instance.Socket;
|
ISocket socket = ServerSessionManager.Instance.Socket;
|
||||||
|
@ -75,29 +47,18 @@ namespace FootRoids
|
||||||
SceneManager.UnloadSceneAsync("FakeMatchmaker");
|
SceneManager.UnloadSceneAsync("FakeMatchmaker");
|
||||||
MatchCommunicationManager.Instance.JoinMatchAsync(matched);
|
MatchCommunicationManager.Instance.JoinMatchAsync(matched);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationQuit()
|
private IEnumerator LoadGame(IMatchmakerMatched matched)
|
||||||
{
|
{
|
||||||
foreach (var socket in m_Sockets)
|
AsyncOperation asyncLoad = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("MatchScene", UnityEngine.SceneManagement.LoadSceneMode.Additive);
|
||||||
|
|
||||||
|
while (!asyncLoad.isDone)
|
||||||
{
|
{
|
||||||
socket?.CloseAsync();
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("FakeMatchmaker");
|
||||||
|
MatchCommunicationManager.Instance.JoinMatchAsync(matched);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(KeyCode.P))
|
|
||||||
{
|
|
||||||
if (m_Match == null)
|
|
||||||
{
|
|
||||||
Debug.Log("Match is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Log("Sending Message To Server!");
|
|
||||||
var socket = m_Sockets[0];
|
|
||||||
var newState = new Dictionary<string, string> {{"hello", "world"}}.ToJson();
|
|
||||||
socket.SendMatchStateAsync(m_Match.Id, 1, newState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace Multiplayer
|
||||||
|
|
||||||
public string CurrentHostId { private set; get; }
|
public string CurrentHostId { private set; get; }
|
||||||
public string MatchId { private set; get; }
|
public string MatchId { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public bool IsHost
|
public bool IsHost
|
||||||
{
|
{
|
||||||
|
@ -38,7 +37,6 @@ namespace Multiplayer
|
||||||
private ISocket _socket { get { return ServerSessionManager.Instance.Socket; } }
|
private ISocket _socket { get { return ServerSessionManager.Instance.Socket; } }
|
||||||
|
|
||||||
private bool allPlayersAdded;
|
private bool allPlayersAdded;
|
||||||
private bool matchJoined;
|
|
||||||
private bool isLeaving;
|
private bool isLeaving;
|
||||||
private Queue<IncommingMessageState> inboundMessages = new Queue<IncommingMessageState>();
|
private Queue<IncommingMessageState> inboundMessages = new Queue<IncommingMessageState>();
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ namespace Multiplayer
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(allPlayersAdded == false || matchJoined == false)
|
if(allPlayersAdded == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +66,7 @@ namespace Multiplayer
|
||||||
IncommingMessageState inboundMessage = inboundMessages.Dequeue();
|
IncommingMessageState inboundMessage = inboundMessages.Dequeue();
|
||||||
ReceiveMatchStateHandle(inboundMessage.opCode, inboundMessage.message);
|
ReceiveMatchStateHandle(inboundMessage.opCode, inboundMessage.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameEnded(MatchMessageGameEnded obj)
|
private void GameEnded(MatchMessageGameEnded obj)
|
||||||
|
@ -79,27 +77,27 @@ namespace Multiplayer
|
||||||
public async void JoinMatchAsync(IMatchmakerMatched matched)
|
public async void JoinMatchAsync(IMatchmakerMatched matched)
|
||||||
{
|
{
|
||||||
ChooseHost(matched);
|
ChooseHost(matched);
|
||||||
|
|
||||||
Players = new List<IUserPresence>();
|
Players = new List<IUserPresence>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Listen to incomming match messages and user connection changes
|
// Listen to incoming match messages and user connection changes
|
||||||
_socket.ReceivedMatchPresence += OnMatchPresence;
|
_socket.ReceivedMatchPresence += OnMatchPresence;
|
||||||
_socket.ReceivedMatchState += ReceiveMatchStateMessage;
|
_socket.ReceivedMatchState += ReceiveMatchStateMessage;
|
||||||
|
|
||||||
// Join the match
|
// Join the match
|
||||||
IMatch match = await _socket.JoinMatchAsync(matched);
|
var match = await _socket.JoinMatchAsync(matched);
|
||||||
// Set current match id
|
// Set current match id
|
||||||
// It will be used to leave the match later
|
// It will be used to leave the match later
|
||||||
MatchId = match.Id;
|
MatchId = match.Id;
|
||||||
|
|
||||||
Debug.Log("Joined match with id: " + match.Id + "; presences count: " + match.Presences.Count());
|
Debug.Log("Joined match with id: " + match.Id + "; presences count: " + match.Presences.Count());
|
||||||
|
foreach (var user in match.Presences) {
|
||||||
|
Debug.Log("User: " + user.Username);
|
||||||
|
}
|
||||||
|
|
||||||
|
AddConnectedPlayers(match);
|
||||||
bool playersJoin = AddConnectedPlayers(match);
|
if(allPlayersAdded)
|
||||||
if(playersJoin)
|
|
||||||
{
|
{
|
||||||
matchJoined = true;
|
|
||||||
StartGame();
|
StartGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +120,9 @@ namespace Multiplayer
|
||||||
//{
|
//{
|
||||||
// OpponentId = user.UserId;
|
// OpponentId = user.UserId;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
Debug.Log("Player Count: " + Players.Count);
|
||||||
|
|
||||||
if (AllPlayersJoined == true)
|
if (AllPlayersJoined == true)
|
||||||
{
|
{
|
||||||
allPlayersAdded = true;
|
allPlayersAdded = true;
|
||||||
|
@ -161,7 +162,6 @@ namespace Multiplayer
|
||||||
default:
|
default:
|
||||||
Debug.Log("Needs more implementation!");
|
Debug.Log("Needs more implementation!");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,31 +185,20 @@ namespace Multiplayer
|
||||||
CurrentHostId = hostUser.Presence.UserId;
|
CurrentHostId = hostUser.Presence.UserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AddConnectedPlayers(IMatch match)
|
private void AddConnectedPlayers(IMatch match)
|
||||||
{
|
{
|
||||||
foreach(IUserPresence user in match.Presences)
|
foreach(IUserPresence user in match.Presences)
|
||||||
{
|
{
|
||||||
if(Players.FindIndex(x => x.UserId == user.UserId) == -1)
|
if(Players.FindIndex(x => x.UserId == user.UserId) == -1)
|
||||||
{
|
{
|
||||||
Debug.Log("User +" + user.Username + " joined match");
|
Debug.Log("User +" + user.Username + " joined match");
|
||||||
|
|
||||||
Players.Add(user);
|
Players.Add(user);
|
||||||
|
|
||||||
// TODO: need to set opponent id?
|
|
||||||
|
|
||||||
if(AllPlayersJoined == true)
|
|
||||||
{
|
|
||||||
allPlayersAdded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("Not allowed!");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(AllPlayersJoined)
|
||||||
return true;
|
{
|
||||||
|
allPlayersAdded = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Multiplayer;
|
||||||
|
using Nakama;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class GameManager : MonoBehaviour {
|
||||||
|
|
||||||
|
[SerializeField] private GameObject _shipPrefab;
|
||||||
|
private Dictionary<string, GameObject> _networkedGameObjects = new Dictionary<string, GameObject>();
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
MatchCommunicationManager.Instance.OnGameStarted += InitializeGame;
|
||||||
|
MatchCommunicationManager.Instance.OnGameEnded += EndGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeGame() {
|
||||||
|
MatchCommunicationManager.Instance.OnGameStarted -= InitializeGame;
|
||||||
|
var players = MatchCommunicationManager.Instance.Players;
|
||||||
|
foreach (var player in players) {
|
||||||
|
CreateShip(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EndGame(MatchMessageGameEnded message) {
|
||||||
|
MatchCommunicationManager.Instance.OnGameEnded -= EndGame;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateShip(IUserPresence owner) {
|
||||||
|
Debug.Log("Creating Ship for User: " + owner.Username);
|
||||||
|
var shipGO = Instantiate(_shipPrefab);
|
||||||
|
var network = shipGO.GetComponent<NetworkedObject>();
|
||||||
|
network.owner = owner;
|
||||||
|
|
||||||
|
_networkedGameObjects.Add(owner.UserId, shipGO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameObject GetObjectWithNetworkId(string id) {
|
||||||
|
return _networkedGameObjects[id];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7408efdfffadbb84b9f5def253d85577
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
Copyright 2015 Pim de Witte All Rights Reserved.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
/// Author: Pim de Witte (pimdewitte.com) and contributors, https://github.com/PimDeWitte/UnityMainThreadDispatcher
|
||||||
|
/// <summary>
|
||||||
|
/// A thread-safe class which holds a queue with actions to execute on the next Update() method. It can be used to make calls to the main thread for
|
||||||
|
/// things such as UI Manipulation in Unity. It was developed for use in combination with the Firebase Unity plugin, which uses separate threads for event handling
|
||||||
|
/// </summary>
|
||||||
|
public class MainThreadDispatcher : MonoBehaviour {
|
||||||
|
private static readonly Queue<Action> _executionQueue = new Queue<Action>();
|
||||||
|
|
||||||
|
public void Update() {
|
||||||
|
lock (_executionQueue) {
|
||||||
|
while (_executionQueue.Count > 0) {
|
||||||
|
_executionQueue.Dequeue().Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Locks the queue and adds the IEnumerator to the queue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
|
||||||
|
public void Enqueue(IEnumerator action) {
|
||||||
|
lock (_executionQueue) {
|
||||||
|
_executionQueue.Enqueue(() => { StartCoroutine(action); });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Locks the queue and adds the Action to the queue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">function that will be executed from the main thread.</param>
|
||||||
|
public void Enqueue(Action action) {
|
||||||
|
Enqueue(ActionWrapper(action));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Locks the queue and adds the Action to the queue, returning a Task which is completed when the action completes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action">function that will be executed from the main thread.</param>
|
||||||
|
/// <returns>A Task that can be awaited until the action completes</returns>
|
||||||
|
public Task EnqueueAsync(Action action) {
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
|
void WrappedAction() {
|
||||||
|
try {
|
||||||
|
action();
|
||||||
|
tcs.TrySetResult(true);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
tcs.TrySetException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Enqueue(ActionWrapper(WrappedAction));
|
||||||
|
return tcs.Task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IEnumerator ActionWrapper(Action a) {
|
||||||
|
a();
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static MainThreadDispatcher _instance = null;
|
||||||
|
|
||||||
|
public static bool Exists() {
|
||||||
|
return _instance != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MainThreadDispatcher Instance() {
|
||||||
|
if (!Exists()) {
|
||||||
|
throw new Exception(
|
||||||
|
"UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Awake() {
|
||||||
|
if (_instance == null) {
|
||||||
|
_instance = this;
|
||||||
|
DontDestroyOnLoad(this.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy() {
|
||||||
|
_instance = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 819a13b084a12774eb665e3ff85ee4f6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 08c5abc1c8bd9d7428048b5bc932bc87
|
guid: 7c8fd2fecbc0f6d46ac1a19a797b077c
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Nakama;
|
||||||
|
using Nakama.TinyJson;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class NetworkManager : MonoBehaviour {
|
||||||
|
|
||||||
|
[SerializeField] private string email;
|
||||||
|
|
||||||
|
private readonly IClient _client = new Client("http", "127.0.0.1", 7350, "defaultkey");
|
||||||
|
private ISocket _socket;
|
||||||
|
private IMatch _match;
|
||||||
|
private GameManager _gameManager;
|
||||||
|
private IUserPresence _self;
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
_gameManager = GetComponent<GameManager>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Start() {
|
||||||
|
var session = await _client.AuthenticateEmailAsync(email, "password");
|
||||||
|
var socket = _client.NewSocket();
|
||||||
|
socket.Connected += () => {
|
||||||
|
Debug.Log("Socket Connected!");
|
||||||
|
};
|
||||||
|
socket.Closed += () => {
|
||||||
|
Debug.Log("Socket Closed!");
|
||||||
|
};
|
||||||
|
socket.ReceivedChannelMessage += (message) => {
|
||||||
|
Debug.Log("Message Received: " + message);
|
||||||
|
};
|
||||||
|
socket.ReceivedMatchmakerMatched += async (matched) => {
|
||||||
|
var match = await socket.JoinMatchAsync(matched);
|
||||||
|
};
|
||||||
|
socket.ReceivedMatchState += (state) => {
|
||||||
|
Debug.Log("Received Message From Server: " + state.State);
|
||||||
|
};
|
||||||
|
socket.ReceivedMatchPresence += (presence) => {
|
||||||
|
foreach (var user in presence.Joins) {
|
||||||
|
OnPlayerJoined(user);
|
||||||
|
}
|
||||||
|
foreach (var user in presence.Leaves) {
|
||||||
|
OnPlayerLeft(user);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await socket.ConnectAsync(session);
|
||||||
|
await socket.AddMatchmakerAsync("*", 2, 2);
|
||||||
|
_socket= socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnApplicationQuit() {
|
||||||
|
_socket?.CloseAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMatchJoined(IMatch match) {
|
||||||
|
_self = match.Self;
|
||||||
|
var participants = match.Presences.ToArray();
|
||||||
|
foreach (var player in participants) {
|
||||||
|
// MainThreadDispatcher.Instance().Enqueue(_gameManager.CreateShip(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayerJoined(IUserPresence player) {
|
||||||
|
// MainThreadDispatcher.Instance().Enqueue(_gameManager.CreateShip(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayerLeft(IUserPresence player) {
|
||||||
|
//TODO Destroy player's ship object
|
||||||
|
Debug.Log("Player Left: " + player.Username);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate() {
|
||||||
|
|
||||||
|
// if (Input.GetKeyDown(KeyCode.P) ) {
|
||||||
|
// if (_match == null) {
|
||||||
|
// Debug.Log("Match is null");
|
||||||
|
// }
|
||||||
|
// Debug.Log("Sending Message To Server!");
|
||||||
|
// var socket = _sockets[0];
|
||||||
|
// var newState = new Dictionary<string, string> {{"hello", "world"}}.ToJson();
|
||||||
|
// socket.SendMatchStateAsync(_match.Id, 1, newState);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08c5abc1c8bd9d7428048b5bc932bc87
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Nakama;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class NetworkedObject : MonoBehaviour {
|
||||||
|
public IUserPresence owner;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 119103344b8d0ff4092f30feb92c4fd5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,135 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &8291833512214639835
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 8291833512214639829}
|
||||||
|
- component: {fileID: 8291833512214639828}
|
||||||
|
- component: {fileID: 8291833512214639830}
|
||||||
|
- component: {fileID: 8291833512214639831}
|
||||||
|
- component: {fileID: -2807015394847699250}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Ship
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &8291833512214639829
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8291833512214639835}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!212 &8291833512214639828
|
||||||
|
SpriteRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8291833512214639835}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 0
|
||||||
|
m_ReceiveShadows: 0
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 10754, 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_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 0
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 0
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_Sprite: {fileID: 21300000, guid: 0c3df53fe2e934f03a4920b155092b87, type: 3}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_FlipX: 0
|
||||||
|
m_FlipY: 0
|
||||||
|
m_DrawMode: 0
|
||||||
|
m_Size: {x: 0.99, y: 0.75}
|
||||||
|
m_AdaptiveModeThreshold: 0.5
|
||||||
|
m_SpriteTileMode: 0
|
||||||
|
m_WasSpriteAssigned: 1
|
||||||
|
m_MaskInteraction: 0
|
||||||
|
m_SpriteSortPoint: 0
|
||||||
|
--- !u!50 &8291833512214639830
|
||||||
|
Rigidbody2D:
|
||||||
|
serializedVersion: 4
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8291833512214639835}
|
||||||
|
m_BodyType: 0
|
||||||
|
m_Simulated: 1
|
||||||
|
m_UseFullKinematicContacts: 0
|
||||||
|
m_UseAutoMass: 0
|
||||||
|
m_Mass: 1
|
||||||
|
m_LinearDrag: 0
|
||||||
|
m_AngularDrag: 0.05
|
||||||
|
m_GravityScale: 0
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Interpolate: 0
|
||||||
|
m_SleepingMode: 1
|
||||||
|
m_CollisionDetection: 0
|
||||||
|
m_Constraints: 0
|
||||||
|
--- !u!114 &8291833512214639831
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8291833512214639835}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 49a70b167dac0c442a59992aad208874, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
_speed: 3
|
||||||
|
_rotationSpeed: 3
|
||||||
|
_rigidbody: {fileID: 0}
|
||||||
|
--- !u!114 &-2807015394847699250
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8291833512214639835}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 119103344b8d0ff4092f30feb92c4fd5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
owned: 0
|
|
@ -0,0 +1,7 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 584333c77fccb9944a3793d4e4cb7c65
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class SimpleMove : MonoBehaviour {
|
||||||
|
|
||||||
|
[SerializeField] private float _speed = 3f;
|
||||||
|
[SerializeField] private float _rotationSpeed = 3f;
|
||||||
|
[SerializeField] private Rigidbody2D _rigidbody;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Awake() {
|
||||||
|
_rigidbody = GetComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update() {
|
||||||
|
var vInput = Input.GetAxis("Vertical") * _speed;
|
||||||
|
var hInput = Input.GetAxis("Horizontal") * _rotationSpeed;
|
||||||
|
|
||||||
|
_rigidbody.AddForce(new Vector2(0, vInput));
|
||||||
|
_rigidbody.AddTorque(-hInput);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49a70b167dac0c442a59992aad208874
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -3,7 +3,7 @@
|
||||||
--- !u!30 &1
|
--- !u!30 &1
|
||||||
GraphicsSettings:
|
GraphicsSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 12
|
serializedVersion: 13
|
||||||
m_Deferred:
|
m_Deferred:
|
||||||
m_Mode: 1
|
m_Mode: 1
|
||||||
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
@ -32,6 +32,9 @@ GraphicsSettings:
|
||||||
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
|
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
m_PreloadedShaders: []
|
m_PreloadedShaders: []
|
||||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||||
type: 0}
|
type: 0}
|
||||||
|
@ -56,3 +59,5 @@ GraphicsSettings:
|
||||||
m_AlbedoSwatchInfos: []
|
m_AlbedoSwatchInfos: []
|
||||||
m_LightsUseLinearIntensity: 0
|
m_LightsUseLinearIntensity: 0
|
||||||
m_LightsUseColorTemperature: 0
|
m_LightsUseColorTemperature: 0
|
||||||
|
m_LogWhenShaderIsCompiled: 0
|
||||||
|
m_AllowEnlightenSupportForUpgradedProject: 1
|
||||||
|
|
|
@ -91,7 +91,7 @@ PlayerSettings:
|
||||||
xboxEnableFitness: 0
|
xboxEnableFitness: 0
|
||||||
visibleInBackground: 1
|
visibleInBackground: 1
|
||||||
allowFullscreenSwitch: 1
|
allowFullscreenSwitch: 1
|
||||||
fullscreenMode: 1
|
fullscreenMode: 3
|
||||||
xboxSpeechDB: 0
|
xboxSpeechDB: 0
|
||||||
xboxEnableHeadOrientation: 0
|
xboxEnableHeadOrientation: 0
|
||||||
xboxEnableGuest: 0
|
xboxEnableGuest: 0
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
local nk = require("nakama")
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
function M.match_init(context, setupstate)
|
|
||||||
local gamestate = {}
|
|
||||||
local tickrate = 1
|
|
||||||
local label = ""
|
|
||||||
return gamestate, tickrate, label
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.match_join_attempt(context, dispatcher, tick, state, presence, metadata)
|
|
||||||
local acceptuser = true
|
|
||||||
return state, acceptuser
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.match_join(context, dispatcher, tick, state, presences)
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.match_leave(context, dispatcher, tick, state, presences)
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.match_loop(context, dispatcher, tick, state, messages)
|
|
||||||
for _, message in ipairs(messages) do
|
|
||||||
print(("Received %s from %s"):format(message.data, message.sender.username))
|
|
||||||
local decoded = nk.json_decode(message.data)
|
|
||||||
for k, v in pairs(decoded) do
|
|
||||||
print(("Message key %s contains value %s"):format(k, v))
|
|
||||||
end
|
|
||||||
-- PONG message back to sender
|
|
||||||
dispatcher.broadcast_message(1, message.data, {message.sender})
|
|
||||||
end
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.match_terminate(context, dispatcher, tick, state, grace_seconds)
|
|
||||||
return state
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
|
@ -1,19 +0,0 @@
|
||||||
local nk = require("nakama")
|
|
||||||
|
|
||||||
local function makematch(context, matched_users)
|
|
||||||
-- print matched users
|
|
||||||
for _, user in ipairs(matched_users) do
|
|
||||||
local presence = user.presence
|
|
||||||
nk.logger_info(("Matched user '%s' named '%s'"):format(presence.user_id, presence.username))
|
|
||||||
for k, v in pairs(user.properties) do
|
|
||||||
nk.logger_info(("Matched on '%s' value '%s'"):format(k, v))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local modulename = "hello_world"
|
|
||||||
local setupstate = { invited = matched_users }
|
|
||||||
local matchid = nk.match_create(modulename, setupstate)
|
|
||||||
return matchid
|
|
||||||
end
|
|
||||||
|
|
||||||
nk.register_matchmaker_matched(makematch)
|
|
Загрузка…
Ссылка в новой задаче