Unity3d development of the game Exchange Code Analysis and design and generate __u3d

Source: Internet
Author: User
Original address: http://gad.qq.com/article/detail/7159010 1, preface to throw away the engine, in fact, for many game development there is a more common module is the Exchange code function. At the beginning of the game development pit, I have also been asked to develop a module like this, and then I searched the Internet seems to have no relevant articles, here intend to my personal game Exchange code design to elaborate, of course, only shallow insights, further expansion in accordance with the project itself,   Use Unity3d as a development platform to illustrate it. 2, analysis of an exchange code from the generation to the use of the process is probably: Generate-> encryption-> Exchange authentication-> storage.             Here I will take these steps to say separately. A, the generation of exchange code as a string of strings carrying certain information, we take the most basic information to treat, if the corresponding project needs to expand on their own, here an Exchange code contains three information: Channel identification code + activity identification code + Exchange code recognition content. Here's the Exchange code to identify the content I used a timestamp to fill, when the decryption can be based on this time stamp as a key to the effectiveness of the Exchange code is a basic factor. In terms of the number of exchange codes, a 2+2+10=14 distribution is taken, presumably such a configuration:

For example, the application of the PO code is 01, the activity code is 01, the time stamp is now (April 24, 2016 17:34 00 seconds) 1461490440, that can get the moment of the Exchange code is 01011461490440. Also, to verify that the Exchange code is valid, it is necessary to verify that the Exchange code is within the validity period. In order to the same channel with a single activity code mutually exclusive, you can from the beginning to the end of the period of time for each additional second to generate an Exchange code, so calculate down to one months 30 days of validity as an example, you can generate 60*60*24*30 = 2.592 million different Exchange code,   For an activity in a channel business, nearly 2.6 million exchange codes are similar, of course, can also be extended according to the actual. B, encryption encryption this part of the internet has a lot of methods, here is not detailed to say, as long as you choose a reversible, do not generate a number of symbolic characters on it, I recommend myself to write a simple corresponding algorithm is enough, so that the original generated unencrypted Exchange code (0-9) of the characters corresponding to (A-Z, 0-9 Any combination code can look random enough. Here's what I do, because we just need to encrypt 0-9 characters, that is, the ASCII code of ' A ' corresponds to the ASCII code of 10-bit, ' Z ', within 10 digits, 0-9 itself, the three ranges we can use to correspond, and then add some shift or transposition of the Exchange code, Encryption is enough. The following code is a simple correspondence of mine, for reference only.
  
The above two functions is just a simple correspondence, the following figure is the same code encryption before and after the corresponding effect, of course, I also added a random case of the function to go in:
I believe it should be used enough. C. Redemption Verification This step includes the number of digits of the Exchange code, whether it is correctly encrypted, whether the correct decryption, the Exchange code after decryption is effective, the effective Exchange code can be exchanged for what items, the record after the exchange and so on. The verification of these steps is not troublesome, as long as the corresponding to the previous good, remember to record that this user has used this type of exchange code on the OK.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.