Skip to content

Commit

Permalink
Feature/switch different landscape (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaweilu committed Oct 4, 2023
1 parent 34ad793 commit b93bf50
Show file tree
Hide file tree
Showing 117 changed files with 4,224 additions and 288 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Servers/AppUsage/.data
# WebGL
Assets/WebGLScripts~/node_modules
WebGLBuild/Holiday/*
WebGLBuild/PanoramicData/Panorama/
WebGLBuild/Data/*
Assets/WebGLTemplates/Holiday/index.js
Assets/WebGLTemplates/Holiday/index.js.meta
7 changes: 3 additions & 4 deletions Assets/AddressableAssetsData/AddressableAssetSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: f2b2967d531f20348b75f02e0528aacd
m_currentHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
Hash: 9e3aeab7e3ad3cb4a0628f9608695942
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 1
m_BundleLocalCatalog: 0
Expand Down Expand Up @@ -46,7 +46,6 @@ MonoBehaviour:
m_GroupAssets:
- {fileID: 11400000, guid: d57c51f5be2793546828e3518fc49122, type: 2}
- {fileID: 11400000, guid: a103d381e22f4cb4c8c8ee4801c6ebaf, type: 2}
- {fileID: 11400000, guid: 5ed5c3f447c830a4eb4cf3b808b10549, type: 2}
- {fileID: 11400000, guid: 7b2ad813c3811e540927b4ed7827ba8b, type: 2}
m_BuildSettings:
m_CompileScriptsInVirtualMode: 0
Expand Down Expand Up @@ -161,11 +160,11 @@ MonoBehaviour:
m_Key: HostingServiceUploadSpeed
- m_AssemblyName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
m_ClassName: System.String
m_Data: WebGLBuild/Data/assets/0.1.0/StandaloneWindows64
m_Data: WebGLBuild/Data/assets/0.1.0/WebGL
m_Key: ContentRoot
- m_AssemblyName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
m_ClassName: System.Boolean
m_Data: True
m_Data: False
m_Key: IsEnabled
- m_AssemblyName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
m_ClassName: System.String
Expand Down
20 changes: 15 additions & 5 deletions Assets/AddressableAssetsData/AssetGroups/AppCommon.asset
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ MonoBehaviour:
m_SerializedData: []
m_GUID: f2b2967d531f20348b75f02e0528aacd
m_SerializeEntries:
- m_GUID: c6ae014bfb0f10d45a7451f05c0c220b
m_Address: AvatarArmature
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 5dd0a9896b950494ca1303948d70b252
m_Address: MessageConfig
m_ReadOnly: 0
Expand All @@ -47,6 +42,21 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: c6ae014bfb0f10d45a7451f05c0c220b
m_Address: AvatarArmature
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: d2d735dc7a9b2a04aaac4b867f92ca5d
m_Address: LandscapeConfig
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: dac329d0652cea1478e0d98a0696f88d
m_Address: SpaceConfig
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: 70324997c374a0844916ed3e0c6c273b, type: 2}
m_SchemaSet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ MonoBehaviour:
m_RedirectLimit: -1
m_RetryCount: 0
m_BuildPath:
m_Id: 2ff51ae6a25533741a6db0e46a3dd5a4
m_Id: bfd6bf59170f8934dae7ab70a80c51a0
m_LoadPath:
m_Id: 6cc7f50c87664584ba7690908e9d1bd0
m_Id: b265ebd845b3b074c829603b1d1f6854
m_BundleMode: 0
m_AssetBundleProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ MonoBehaviour:
m_RedirectLimit: -1
m_RetryCount: 0
m_BuildPath:
m_Id: 2ff51ae6a25533741a6db0e46a3dd5a4
m_Id: bfd6bf59170f8934dae7ab70a80c51a0
m_LoadPath:
m_Id: 6cc7f50c87664584ba7690908e9d1bd0
m_Id: b265ebd845b3b074c829603b1d1f6854
m_BundleMode: 0
m_AssetBundleProviderType:
m_AssemblyName: Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Expand Down

This file was deleted.

29 changes: 0 additions & 29 deletions Assets/AddressableAssetsData/AssetGroups/VirtualSpace.asset

This file was deleted.

61 changes: 46 additions & 15 deletions Assets/Holiday/App/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Extreal.SampleApp.Holiday.Controls.RetryStatusControl;
using Extreal.SampleApp.Holiday.Screens.ConfirmationScreen;
using UniRx;
using Message = Extreal.SampleApp.Holiday.App.P2P.Message;

namespace Extreal.SampleApp.Holiday.App
{
Expand All @@ -20,6 +21,7 @@ public class AppState : DisposableBase

public string PlayerName { get; private set; } = "Guest";
public AvatarConfig.Avatar Avatar { get; private set; }
public SpaceConfig.Space Space { get; private set; }
public bool IsHost => role == PeerRole.Host;
public bool IsClient => role == PeerRole.Client;
public string GroupName { get; private set; } // Host only
Expand All @@ -35,6 +37,12 @@ public class AppState : DisposableBase
public IReadOnlyReactiveProperty<bool> P2PReady => p2PReady.AddTo(disposables);
private readonly ReactiveProperty<bool> p2PReady = new ReactiveProperty<bool>(false);

public IObservable<Message> OnMessageSent => onMessageSent.AddTo(disposables);
private readonly Subject<Message> onMessageSent = new Subject<Message>();

public IObservable<Message> OnMessageReceived => onMessageReceived.AddTo(disposables);
private readonly Subject<Message> onMessageReceived = new Subject<Message>();

public IObservable<string> OnNotificationReceived => onNotificationReceived.AddTo(disposables);
private readonly Subject<string> onNotificationReceived = new Subject<string>();

Expand All @@ -45,6 +53,7 @@ public class AppState : DisposableBase
private readonly Subject<RetryStatus> onRetryStatusReceived = new Subject<RetryStatus>();

private readonly BoolReactiveProperty multiplayReady = new BoolReactiveProperty(false);
private readonly BoolReactiveProperty landscapeInitialized = new BoolReactiveProperty(false);

private readonly CompositeDisposable disposables = new CompositeDisposable();

Expand All @@ -53,16 +62,20 @@ public class AppState : DisposableBase
public AppState()
{
multiplayReady.AddTo(disposables);
landscapeInitialized.AddTo(disposables);

MonitorPlayingReadyStatus();
RestorePlayingReadyStatus();
}

[SuppressMessage("Usage", "CC0033")]
private void MonitorPlayingReadyStatus() =>
Observable.
CombineLatest(multiplayReady, spaceReady, p2PReady)
.Where(readies => readies.All(ready => ready))
multiplayReady.Merge(spaceReady, p2PReady, landscapeInitialized)
.Where(_ =>
{
LogWaitingStatus();
return multiplayReady.Value && spaceReady.Value && p2PReady.Value && landscapeInitialized.Value;
})
.Subscribe(_ =>
{
if (Logger.IsDebug())
Expand All @@ -75,30 +88,48 @@ public AppState()

[SuppressMessage("Usage", "CC0033")]
private void RestorePlayingReadyStatus() =>
Observable
.CombineLatest(multiplayReady, spaceReady, p2PReady)
.Where(readies => readies.All(ready => !ready))
.Subscribe(_ =>
{
if (Logger.IsDebug())
{
Logger.LogDebug("Stop playing");
}
playingReady.Value = false;
})
.AddTo(disposables);
spaceReady.Merge(landscapeInitialized)
.Where(_ =>
{
LogWaitingStatus();
return !spaceReady.Value && !landscapeInitialized.Value;
})
.Subscribe(_ =>
{
if (Logger.IsDebug())
{
Logger.LogDebug("Stop playing");
}
playingReady.Value = false;
})
.AddTo(disposables);

private void LogWaitingStatus()
{
if (Logger.IsDebug())
{
Logger.LogDebug($"Multiplay, Space Ready, P2P Ready, Landscape Initialized: " +
$"{multiplayReady.Value}, {spaceReady.Value}, {p2PReady.Value}, {landscapeInitialized.Value}");
}
}

public void SetPlayerName(string playerName) => PlayerName = playerName;
public void SetAvatar(AvatarConfig.Avatar avatar) => Avatar = avatar;
public void SetSpace(SpaceConfig.Space space) => Space = space;
public void SetRole(PeerRole role) => this.role = role;
public void SetGroupName(string groupName) => GroupName = groupName;
public void SetGroupId(string groupId) => GroupId = groupId;
public void SetSpaceName(string spaceName) => SpaceName = spaceName;
public void SetP2PReady(bool ready) => p2PReady.Value = ready;
public void SetMultiplayReady(bool ready) => multiplayReady.Value = ready;
public void SetSpaceReady(bool ready) => spaceReady.Value = ready;
public void SetLandscapeInitialized(bool initialized) => landscapeInitialized.Value = initialized;
public void SetStage(StageName stageName) => StageState = new StageState(stageName);

public void SendMessage(Message message) => onMessageSent.OnNext(message);

public void ReceivedMessage(Message message) => onMessageReceived.OnNext(message);

public void Notify(string message)
{
Logger.LogError(message);
Expand Down
9 changes: 8 additions & 1 deletion Assets/Holiday/App/AppUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static bool IsTouchDevice()
=> false;
#endif

private static readonly HashSet<StageName> SpaceStages = new HashSet<StageName> { StageName.VirtualStage };
private static readonly HashSet<StageName> SpaceStages = new HashSet<StageName> { StageName.VirtualStage, StageName.PanoramicVideoStage, StageName.PanoramicImageStage };

public static bool IsSpace(StageName stageName) => SpaceStages.Contains(stageName);

Expand Down Expand Up @@ -47,6 +47,13 @@ public static void NotifyRetried(AppState appState, bool result, string successM
}
}

public static string ConcatUrl(string baseUrl, string relativePath)
{
baseUrl = baseUrl.TrimEnd('/');
relativePath = relativePath.TrimStart('/');
return $"{baseUrl}/{relativePath}";
}

public static long ToMb(long bytes) => bytes >> 20;
}
}
5 changes: 5 additions & 0 deletions Assets/Holiday/App/AssetWorkflow/AssetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class AssetHelper : DisposableBase

public VoiceChatConfig VoiceChatConfig { get; private set; }

public SpaceConfig SpaceConfig { get; private set; }
public LandscapeConfig LandscapeConfig { get; private set; }

private static readonly ELogger Logger = LoggingManager.GetLogger(nameof(AssetHelper));

private readonly StageNavigator<StageName, SceneName> stageNavigator;
Expand All @@ -56,11 +59,13 @@ public void DownloadCommonAssetAsync(StageName nextStage)
MessageConfig = await LoadAndAddToDisposablesAsync<MessageConfig>();
PeerConfig = await LoadAndReleaseAsync<P2PConfig, PeerConfig>(asset => asset.PeerConfig);
AvatarConfig = await LoadAndAddToDisposablesAsync<AvatarConfig>();
SpaceConfig = await LoadAndAddToDisposablesAsync<SpaceConfig>();
(NgoHostConfig, NgoClientConfig)
= await LoadAndReleaseAsync<MultiplayConfig, (HostConfig, ClientConfig)>(
asset => (asset.HostConfig, asset.ClientConfig));
VoiceChatConfig = await LoadAndReleaseAsync<ChatConfig, VoiceChatConfig>(
asset => asset.VoiceChatConfig);
LandscapeConfig = await LoadAndAddToDisposablesAsync<LandscapeConfig>();
stageNavigator.ReplaceAsync(nextStage).Forget();
};
DownloadAsync(nameof(MessageConfig), nextFunc).Forget();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Holiday/App/Config/AppConfig.asset
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
verticalSyncs: 0
targetFrameRate: 60
downloadTimeoutSeconds: 10
downloadTimeoutSeconds: 60
downloadMaxRetryCount: 5
downloadConnectRetryMessage: 'Reconnect for download : {0}'
downloadRetrySuccessMessage: Successfully reconnected for download.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5834b5087d578d24c926ce20cd31e6d6, type: 3}
m_Name: VirtualSpace_ContentUpdateGroupSchema
m_Script: {fileID: 11500000, guid: de095b56920b482458a182e93f616a58, type: 3}
m_Name: LandscapeConfig
m_EditorClassIdentifier:
m_Group: {fileID: 11400000, guid: 5ed5c3f447c830a4eb4cf3b808b10549, type: 2}
m_StaticContent: 0
baseUrl: http://localhost:3333/Panorama/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Assets/Holiday/App/Config/LandscapeConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using UnityEngine;

namespace Extreal.SampleApp.Holiday.App.Config
{
[CreateAssetMenu(
menuName = nameof(Holiday) + "/" + nameof(LandscapeConfig),
fileName = nameof(LandscapeConfig))]
public class LandscapeConfig : ScriptableObject
{
[SerializeField] private string baseUrl;

public string BaseUrl => baseUrl;
}
}

0 comments on commit b93bf50

Please sign in to comment.