From 1e7ac5b65561da9613bfe3b6c37c4f31b2d9e9e5 Mon Sep 17 00:00:00 2001 From: Natalie Bunduwongse Date: Thu, 4 Apr 2024 16:12:32 +0700 Subject: [PATCH] feat: craft skin --- Assets/Shared/Scripts/UI/LevelCompleteScreen.cs | 12 +++++++++++- Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs | 10 +++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Assets/Shared/Scripts/UI/LevelCompleteScreen.cs b/Assets/Shared/Scripts/UI/LevelCompleteScreen.cs index 92e2c5d7d..1e11eec19 100644 --- a/Assets/Shared/Scripts/UI/LevelCompleteScreen.cs +++ b/Assets/Shared/Scripts/UI/LevelCompleteScreen.cs @@ -235,7 +235,17 @@ private async void OnTryAgainButtonClicked() private void OnNextButtonClicked() { - m_NextLevelEvent.Raise(); + // Check if the player is already using a new skin + if (!SaveManager.Instance.UseNewSkin) + { + // Player is not using a new skin, take player to Unlocked Skin screen + m_UnlockedSkinEvent.Raise(); + } + else + { + // Player is already using a new skin, take player to the next level + m_NextLevelEvent.Raise(); + } } private void ShowCompletedContainer(bool show) diff --git a/Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs b/Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs index 4cd280532..5088c844a 100644 --- a/Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs +++ b/Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs @@ -6,6 +6,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using Immutable.Passport; +using Immutable.Passport.Model; namespace HyperCasual.Runner { @@ -116,7 +118,13 @@ private async void Craft() m_CraftState = CraftSkinState.Crafting; // Burn tokens and mint a new skin i.e. crafting a skin - await Task.Delay(TimeSpan.FromSeconds(5)); + string transactionHash = await Passport.Instance.ZkEvmSendTransaction(new TransactionRequest() + { + to = "YOUR_IMMUTABLE_RUNNER_TOKEN_CONTRACT_ADDRESS", // Immutable Runner Token contract address + data = "0x1e957f1e", // Call craftSkin() in the contract + value = "0" + }); + Debug.Log($"Craft transaction hash: {transactionHash}"); m_CraftState = CraftSkinState.Crafted;