diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator.unity b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator.unity index 36afad0..695a848 100644 --- a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator.unity +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator.unity @@ -7309,7 +7309,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8229dcd11ab919c4a95848ed679cccaf, type: 3} m_Name: m_EditorClassIdentifier: - host: 192.168.234.87 + host: 127.0.0.1 port: 54578 onStateChanged: m_PersistentCalls: diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ArtworkGenerator.cs b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ArtworkGenerator.cs index 2885754..80218e3 100644 --- a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ArtworkGenerator.cs +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ArtworkGenerator.cs @@ -27,12 +27,12 @@ namespace UltraCombos.Minions.GirlsRoom.Nav } - public void OnPaintingReceived(Artwork artwork, string paintingPath, string signaturePath) + public void OnPaintingReceived(Artwork artwork, string paintingPath, string signaturePath, string messagePath) { - StartCoroutine(Generate(artwork, paintingPath, signaturePath)); + StartCoroutine(Generate(artwork, paintingPath, signaturePath, messagePath)); } - IEnumerator Generate(Artwork artwork, string paintingPath, string signaturePath) + IEnumerator Generate(Artwork artwork, string paintingPath, string signaturePath, string messagePath) { paint.UpdateArtwork(artwork); yield return new WaitForEndOfFrame(); @@ -42,6 +42,7 @@ namespace UltraCombos.Minions.GirlsRoom.Nav serial = artwork.serial, painting_path = paintingPath, signature_path = signaturePath, + message_path = messagePath }; int width = cam.targetTexture.width; diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/PrintingGenerator.cs b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/PrintingGenerator.cs index 56c6aa5..6199188 100644 --- a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/PrintingGenerator.cs +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/PrintingGenerator.cs @@ -27,7 +27,7 @@ namespace UltraCombos.Minions.GirlsRoom.Nav public TextureEvent onPrint = new TextureEvent(); [System.Serializable] - public class LuggageEvent : UnityEvent { } + public class LuggageEvent : UnityEvent { } public LuggageEvent onPrintLuggage = new LuggageEvent(); private void Start() @@ -66,7 +66,18 @@ namespace UltraCombos.Minions.GirlsRoom.Nav if (painting_texture && signature_texture) { - painting.UpdateArtwork(work.serial, painting_texture, signature_texture); + Color32 color; + try + { + string message = File.ReadAllText(work.message_path); + color = Frozen.RoyalGallery.Utils.HexToColor(message); + } + catch (FileNotFoundException e) + { + color = new Color32(255, 255, 255, 255); + } + + painting.UpdateArtwork(work.serial, painting_texture, signature_texture, color); yield return new WaitForEndOfFrame(); @@ -78,7 +89,7 @@ namespace UltraCombos.Minions.GirlsRoom.Nav // should be replaced with printing process onPrint.Invoke(printing_texture); - onPrintLuggage.Invoke(work.serial, painting_texture, signature_texture); + onPrintLuggage.Invoke(work.serial, painting_texture, signature_texture, color); /* string path = $"../../Build_GirlsRoomNav/Print/{work.serial}.jpg"; System.IO.File.WriteAllBytes(path, printing_texture.EncodeToJPG()); @@ -89,11 +100,11 @@ namespace UltraCombos.Minions.GirlsRoom.Nav coroutine = null; } - public void PrintLuggage(string serial, Texture2D painting, Texture2D signature) + public void PrintLuggage(string serial, Texture2D painting, Texture2D signature, Color32 color) { if (luggage_coroutine == null) { - luggage_coroutine = StartCoroutine(PrintingLuggage(serial, painting, signature)); + luggage_coroutine = StartCoroutine(PrintingLuggage(serial, painting, signature, color)); } } @@ -101,13 +112,13 @@ namespace UltraCombos.Minions.GirlsRoom.Nav { if (luggage_coroutine == null) { - luggage_coroutine = StartCoroutine(PrintingLuggage(work.serial, work.painting, work.signature)); + luggage_coroutine = StartCoroutine(PrintingLuggage(work.serial, work.painting, work.signature, work.color)); } } - IEnumerator PrintingLuggage(string serial, Texture2D painting_texture, Texture2D signature_texture) + IEnumerator PrintingLuggage(string serial, Texture2D painting_texture, Texture2D signature_texture, Color32 color) { - painting.UpdateArtwork(serial, painting_texture, signature_texture); + painting.UpdateArtwork(serial, painting_texture, signature_texture, color); yield return new WaitForEndOfFrame(); diff --git a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ResourceServer.cs b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ResourceServer.cs index 5aaba5c..cb08daf 100644 --- a/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ResourceServer.cs +++ b/03_RoyalGallery/Unity-19050-03_RoyalGallery_Navigator_PC/19050-03_RoyalGallery_Navigator_PC/Assets/PaintingNavigator/Script/ResourceServer.cs @@ -31,12 +31,13 @@ namespace UltraCombos.Frozen.RoyalGallery PrintingGenerator luggagePrinter; [System.Serializable] - public class PaintingEvent : UnityEvent { } + public class PaintingEvent : UnityEvent { } [Space(10)] public PaintingEvent onPaintingReceived = new PaintingEvent(); const string painting_filename = "painting.png"; const string signature_filename = "signature.png"; + const string message_filename = "message.dat"; Artwork last_data = null; Coroutine fetching = null; @@ -111,12 +112,37 @@ namespace UltraCombos.Frozen.RoyalGallery string signature_path = $"{folder.FullName}/{signature_filename}"; yield return Utility.Network.LoadTexture(signature_path, value => signature = value); - if (painting && signature) + string message_path = $"{folder.FullName}/{message_filename}"; + + do { - var artwork = new Artwork() { serial = folder.Name, painting = painting, signature = signature }; + if (!painting) + { + break; + } + + if (!signature) + { + break; + } + + Color32 color; + try + { + string message = File.ReadAllText(message_path); + color = Utils.HexToColor(message); + } + catch (FileNotFoundException e) + { + color = new Color32(255, 255, 255, 255); + } + + var artwork = new Artwork() { serial = folder.Name, painting = painting, signature = signature, color = color }; last_data = artwork; - onPaintingReceived.Invoke(artwork, painting_path, signature_path); - } + onPaintingReceived.Invoke(artwork, painting_path, signature_path, message_path); + + } while (false); + yield return null; } @@ -150,8 +176,9 @@ namespace UltraCombos.Frozen.RoyalGallery var folder = Directory.CreateDirectory($"{store_dir.FullName}/{last_data.serial}"); string painting_path = $"{folder.FullName}/{painting_filename}"; string signature_path = $"{folder.FullName}/{signature_filename}"; + string message_path = $"{folder.FullName}/{message_filename}"; - onPaintingReceived.Invoke(last_data, painting_path, signature_path); + onPaintingReceived.Invoke(last_data, painting_path, signature_path, message_path); } } @@ -188,13 +215,14 @@ namespace UltraCombos.Frozen.RoyalGallery File.WriteAllBytes(painting_path, data.Content.ToByteArray()); string signature_path = $"{folder.FullName}/{signature_filename}"; File.WriteAllBytes(signature_path, data.Signature.ToByteArray()); - + string message_path = $"{folder.FullName}/{message_filename}"; + File.WriteAllText(message_path, data.Message); last_data = artwork; if (luggagePrinter.isActiveAndEnabled) { luggagePrinter.PrintLuggage(artwork); } - onPaintingReceived.Invoke(artwork, painting_path, signature_path); + onPaintingReceived.Invoke(artwork, painting_path, signature_path, message_path); Log($"Painting {data.Id} is loaded. ({painting.width} x {painting.height})"); } }