From 9a1f2e526c22387ba6021ae292a18dd6ae80102f Mon Sep 17 00:00:00 2001 From: valeriofantasy Date: Sun, 12 Apr 2020 17:45:50 +0100 Subject: [PATCH 1/2] Dynamic Sprite Sizes --- .../Core/Appearances/Provider/SpritesAsset.cs | 16 ++++++++-------- .../Scripts/Core/Appearances/SpriteProvider.cs | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/OpenTibia/Assets/Scripts/Core/Appearances/Provider/SpritesAsset.cs b/OpenTibia/Assets/Scripts/Core/Appearances/Provider/SpritesAsset.cs index 0011c3c..b1a987f 100644 --- a/OpenTibia/Assets/Scripts/Core/Appearances/Provider/SpritesAsset.cs +++ b/OpenTibia/Assets/Scripts/Core/Appearances/Provider/SpritesAsset.cs @@ -9,13 +9,6 @@ public class SpritesAsset public const int AtlasTexture_Width = 512; public const int AtlasTexture_Height = 512; - private static Vector2Int[] s_SpritesAssetSizesRef = new Vector2Int[] { - new Vector2Int(1, 1), - new Vector2Int(1, 2), - new Vector2Int(2, 1), - new Vector2Int(2, 2) - }; - private uint _firstSpriteId = 0; private uint _lastSpriteId = 0; private uint _spriteType = 0; @@ -33,12 +26,19 @@ public SpritesAsset(uint firstSpriteId, uint lastSpriteId, uint spriteType, stri _fileName = filename; } + private static Vector2Int GetSpriteSize(uint spriteType) { + var width = spriteType / 100; + var height = spriteType % 100; + + return new Vector2Int((int) width, (int) height); + } + public Rendering.CachedSpriteInformation GetCachedSpriteInformation(uint spriteId, AssetBundle assetBundle) { Texture2D tex2D = assetBundle.LoadAsset(_fileName); if (!tex2D) return null; - var realSpriteSize = s_SpritesAssetSizesRef[_spriteType - 1] * Constants.FieldSize; + var realSpriteSize = GetSpriteSize(_spriteType) * Constants.FieldSize; uint realId = spriteId - _firstSpriteId; int texPerRow = AtlasTexture_Width / realSpriteSize.x; int x = (int)((realId % texPerRow) * realSpriteSize.x); diff --git a/OpenTibia/Assets/Scripts/Core/Appearances/SpriteProvider.cs b/OpenTibia/Assets/Scripts/Core/Appearances/SpriteProvider.cs index 4d6aec1..01ee038 100644 --- a/OpenTibia/Assets/Scripts/Core/Appearances/SpriteProvider.cs +++ b/OpenTibia/Assets/Scripts/Core/Appearances/SpriteProvider.cs @@ -44,16 +44,17 @@ public void GenerateChannelsMaterialProps(MaterialPropertyBlock props) { } public sealed class SpritesProvider { - private static Vector2[] SpriteTypeSizeRefs = new Vector2[] { - new Vector2(1.0f, 1.0f), - new Vector2(1.0f, 2.0f), - new Vector2(2.0f, 1.0f), - new Vector2(2.0f, 2.0f) - }; List _spriteSheet; List _cachedSprites = new List(); + private static Vector2 GetSpriteSize(uint spriteType) { + var width = spriteType / 100; + var height = spriteType % 100; + + return new Vector2(width, height); + } + public IEnumerator Parse(System.IO.Stream stream) { using (var reader = new System.IO.BinaryReader(stream)) { uint total = reader.ReadUInt32(); @@ -109,7 +110,7 @@ private SpriteLoadingStatus GetSpriteInfo(uint spriteId, out Vector4 uv, out Vec return loadingStatus; } - size = SpriteTypeSizeRefs[match.SpriteType - 1] * Constants.FieldSize; + size = GetSpriteSize(match.SpriteType) * Constants.FieldSize; uint realId = spriteId - match.FirstSpriteId; int texPerRow = (int)(texture.width / size.x); From a0dec117b92087e3575b925671a1ad8dc3d7f5d4 Mon Sep 17 00:00:00 2001 From: valeriobleite Date: Thu, 16 Apr 2020 19:56:43 +0100 Subject: [PATCH 2/2] Change Version Unity --- OpenTibia/Packages/manifest.json | 2 +- OpenTibia/ProjectSettings/ProjectVersion.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenTibia/Packages/manifest.json b/OpenTibia/Packages/manifest.json index 17614e8..5055300 100644 --- a/OpenTibia/Packages/manifest.json +++ b/OpenTibia/Packages/manifest.json @@ -5,7 +5,7 @@ "com.unity.collab-proxy": "1.2.16", "com.unity.ide.rider": "1.1.4", "com.unity.ide.vscode": "1.1.4", - "com.unity.test-framework": "1.1.9", + "com.unity.test-framework": "1.1.13", "com.unity.textmeshpro": "2.0.1", "com.unity.ugui": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/OpenTibia/ProjectSettings/ProjectVersion.txt b/OpenTibia/ProjectSettings/ProjectVersion.txt index 798259b..7ffb090 100644 --- a/OpenTibia/ProjectSettings/ProjectVersion.txt +++ b/OpenTibia/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.3.0f6 -m_EditorVersionWithRevision: 2019.3.0f6 (27ab2135bccf) +m_EditorVersion: 2019.3.8f1 +m_EditorVersionWithRevision: 2019.3.8f1 (4ba98e9386ed)