In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how Unity interacts with NEO blockchain quickly". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how Unity interacts with NEO blockchain quickly" can help you solve the problem.
Wallet management
The reason I provided this script is to prove the importance of having a good getting started experience. Many cryptocurrency projects (and some games) require users to learn a lot to learn how to use the application. In the long run, we need to better understand how to bring in new users and minimize friction in doing so. Users have invested time in downloading games, and when they start asking for more time, the less they have to click and learn when they start playing the game, the less likely they are to delete the game immediately. Don't let users think.
Ideally, I would like to remove the first interface completely, just put the user directly into the game. But the problem of holding assets is obvious, and you have to be very clear about when and how to deal with them. When users forget or lose their keys, you can't go directly to the background to help users reset and retrieve their data. A good intermediate solution is that the beginning of the game does not involve any wallet content, and users will be prompted to enter these wallet information only if they want to better try your wallet function. I hope you can try to explore your own solutions.
Send a pass
When players score more than a certain threshold, we will give them tokens as a reward. GAS is, to some extent, the actual token in the NEO blockchain, so we will use it as a reward.
When you create a real game, you will have to fight attacks, and it is not easy to keep the game interesting and economically mobile while fighting. For demonstration purposes, we will simplify here. In a real online game, you need multiple anti-cheating mechanisms, but in the end, in the game, we know that we can never avoid all the attacks. Someone somewhere will make up his mind to ruin your game. Otherwise, you will miss a key code vulnerability. We try to strike a balance by preventing the most common attacks and lack of sleep, and we often divide the economy in such a way that other players' gaming experiences are not compromised in the process.
Create a game object named NEORewardManager, GameObject, as a child of other NEO managers. Create a script named NEORewardManager and copy and paste the following code:
Using System; using System.Collections; using UniRx; using UnityEngine; public class NEORewardManager: MonoBehaviour {[SerializeField] private NEOManager neoManager; [SerializeField] private CompleteProject.PlayerHealth playerHealth; [SerializeField] private int rewardThreshold = 50; private bool isGameOver; private void Update () {if (playerHealth.currentHealth 0 & & isGameOver) {isGameOver = false }} private IEnumerator OnGameOver () {yield return new WaitForSeconds (1); Time.timeScale = 0; if (CompleteProject.ScoreManager.score > = rewardThreshold) {StartCoroutine (TrySendGAS (1));} else {Time.timeScale = 1 }} private IEnumerator TrySendGAS (int amount) {yield return null; try {var tx = neoManager.API.SendAsset (neoManager.MasterKeyPair, neoManager.PlayerKeyPair.Value.address, NEOManager.AssetSymbol, (decimal) amount); if (tx = = null) {Debug.LogError ("Null Transaction returned") Time.timeScale = 1;} else {Debug.Log ("TX received, checking sync..."); Observable.FromCoroutine (SyncBalance). Subscribe (). AddTo (this) }} catch (NullReferenceException exception) {Debug.LogError ("There was a problem..."); Time.timeScale = 1;} catch (Exception exception) {Debug.LogError ("There was a problem..."); Time.timeScale = 1 }} private IEnumerator SyncBalance () {yield return null; try {/ / var balances = neoManager.API.GetAssetBalancesOf (neoManager.PlayerKeyPair.Value); / / neoManager.GASBalance.Value = balances.ContainsKey (NEOManager.AssetSymbol)? Balances [NEOManager.AssetSymbol]: 0; / / if (Mathf.Approximately ((float) NEOManager.GASBalance.Value, GameDataSystem.Coins.Value)) / / {/ / Debug.Log ("GAS transferred successfully") / /} / / else / / {/ / Debug.LogWarning ("Something's not right." + / "\ nCoins:" + GameDataSystem.Coins.Value + / "\ nGAS:" + NEOManager.GASBalance.Value) / /} Debug.Log ("Balance synced!"); Time.timeScale = 1;} catch (NullReferenceException exception) {Debug.LogWarning ("Something's not right." + / "\ nCoins:" + GameDataSystem.Coins.Value + "\ nGAS:" + neoManager.GASBalance.Value) Time.timeScale = 1;}
The system will wait for the game to end, and if the player scores more than a certain threshold at the end of the game, the system will transfer GAS from the main account to the local player account. Connect NEOManager and PlayerHealth by dragging and dropping references in the scene. You can also set the reward threshold to any value you want; have a look. In the subsequent playback, you can see a number of updates, which reflects that the GAS transfer has been normal. Congratulations, we can now have some basic interaction with the NEO block chain, yeah.
That's all for "how Unity interacts with the NEO blockchain quickly". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.