Skip to content

Commit

Permalink
0.5.0 (#110)
Browse files Browse the repository at this point in the history
* Fix loading scene

(cherry picked from commit f23b72e)

* Fix item spawning and change how to pause/resume packet handling (#106)

(cherry picked from commit cbb5f09)

* [Feature] New motion speed formula (#107)

* WIP: new motion speed formula

* spawn poring in offline scene

* if dealing with attack motion, we use the most accurate formula, otherwise robrowser's is fine

(cherry picked from commit 0ff7514)

* [Feature] Mesh Renderers (#108)

* change to mesh renderer

* Change sprite shader to always write (whatever that means) and change some minor stuff around the viewer to apply alpha and stop the entity on receiving vanish packet

* set ready false when receive vanish command

(cherry picked from commit 640731a)

* [Fix] Some minor fixes on the splash screen (#109)

(cherry picked from commit 1fb0021)
  • Loading branch information
Danil0v3s authored Sep 22, 2022
1 parent b110c0a commit f9ba39a
Show file tree
Hide file tree
Showing 15 changed files with 985 additions and 775 deletions.
943 changes: 302 additions & 641 deletions UnityClient/Assets/Resources/Shaders/Sprites/SpriteShader.shadergraph

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ private async void OnCharacterSelectionAccepted(ushort cmd, int size, InPacket p
Session.StartSession(new Session(entity, NetworkClient.State.LoginInfo.AccountID));
DontDestroyOnLoad(entity.gameObject);

//var mapUI = Instantiate(MapUIPrefab);
//DontDestroyOnLoad(mapUI);

var loginInfo = NetworkClient.State.LoginInfo;
new CZ.ENTER2(loginInfo.AccountID, selectedCharacter.GID, loginInfo.LoginID1, (int) new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(), loginInfo.Sex).Send();
}
Expand Down
3 changes: 2 additions & 1 deletion UnityClient/Assets/Scenes/Map/MapController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private async void Awake() {
GameManager.InitCamera();

var gameMap = await GameManager.BeginMapLoading(mapInfo.mapname);

PathFinding = gameMap.GetPathFinder();
NetworkClient.StartHeatBeat();
NetworkClient.ResumePacketHandling();
Expand Down Expand Up @@ -149,7 +150,7 @@ private async void OnEntityMoved(ushort cmd, int size, InPacket packet) {
if (packet is ZC.NPCACK_MAPMOVE) {
var pkt = packet as ZC.NPCACK_MAPMOVE;

if (pkt.MapName != Session.CurrentSession.CurrentMap) {
if (Path.GetFileNameWithoutExtension(pkt.MapName) != Session.CurrentSession.CurrentMap) {
var entity = Session.CurrentSession.Entity as Entity;
entity.StopMoving();

Expand Down
40 changes: 32 additions & 8 deletions UnityClient/Assets/Scenes/Splashscreen/SplashScreenController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ROIO;
using ROIO.Utils;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class SplashScreenController : MonoBehaviour {

Expand All @@ -16,36 +18,58 @@ public class SplashScreenController : MonoBehaviour {
[SerializeField]
private TextMeshProUGUI labelText;

[SerializeField]
private TextMeshProUGUI DownloadSizeText;

[SerializeField]
private Slider Slider;

void Start() {
StartCoroutine(Initialize());
}

private IEnumerator Initialize() {
labelText.text = "Checking for updates...";
yield return Addressables.InitializeAsync();
yield return new WaitForSeconds(1f);

StartCoroutine(PrefetchAssets());
}

private IEnumerator PrefetchAssets() {
#if !UNITY_EDITOR
var downloadSize = Addressables.GetDownloadSizeAsync(LabelsToPrefetch).WaitForCompletion();

if (downloadSize <= 0) {
yield return FetchConfigs();
}

foreach (var label in LabelsToPrefetch) {
var handle = Addressables.DownloadDependenciesAsync(label, true);

while(!handle.IsDone) {
var downloadStatus = handle.GetDownloadStatus();
var downloadedMbs = downloadStatus.DownloadedBytes / 1024 / 1024;
var totalMbs = downloadStatus.TotalBytes / 1024 / 1024;
var progress = downloadedMbs / (totalMbs > 0 ? totalMbs : 1) * 100;
var downloadedMbs = downloadStatus.DownloadedBytes / 1024f / 1024f;
var totalMbs = (downloadStatus.TotalBytes / 1024f / 1024f);

var progress = Conversions.SafeDivide(downloadedMbs, totalMbs);

var text = $"Downloading {label.labelString}\n{downloadedMbs}MB / {totalMbs}MB\n{progress}%";
var text = $"Downloading {label.labelString}";
labelText.text = text;
DownloadSizeText.text = $"{downloadedMbs}MB / {totalMbs}MB";
Slider.value = progress;

yield return null;
}

yield return handle;
}
#endif
yield return Addressables.InitializeAsync();
yield return new WaitForSeconds(1f);

StartCoroutine(FetchConfigs());
yield return FetchConfigs();
}

private IEnumerator FetchConfigs() {
labelText.text = "Fetching remote configuration...";
var localRequest = Addressables.LoadAssetAsync<TextAsset>("LocalConfigs.json.txt");
yield return localRequest;

Expand Down
Loading

0 comments on commit f9ba39a

Please sign in to comment.