Ver código fonte

用户协议

lvjincheng 4 anos atrás
pai
commit
735551af83

Diferenças do arquivo suprimidas por serem muito extensas
+ 199 - 0
Assets/BowArrow/Resources/Prefabs/Views/AgreementView.prefab


+ 7 - 0
Assets/BowArrow/Resources/Prefabs/Views/AgreementView.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 252e7821e2fb6b143b7864750dd0712f
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

Diferenças do arquivo suprimidas por serem muito extensas
+ 331 - 387
Assets/BowArrow/Scenes/Login.unity


+ 1 - 0
Assets/BowArrow/Scripts/CommonConfig.cs

@@ -9,4 +9,5 @@ public class CommonConfig
     public static readonly int ringsPrecision = 1;
     /**箭的速度精度小数位 */
     public static readonly int arrowSpeedPrecision = 1;
+    public static string businessServerURI = "http://127.0.0.1:11332/SmartBowBusinessServer";
 }

+ 70 - 0
Assets/BowArrow/Scripts/Manager/LoginMgr.cs

@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
+using UnityEngine.Networking;
 using System.Text.RegularExpressions;
 using DG.Tweening;
 using Newtonsoft.Json;
@@ -18,9 +19,11 @@ public class LoginMgr : MonoBehaviour
     [SerializeField] Sprite[] loginModeSprites;
     [SerializeField] GameObject loginInUser;
     [SerializeField] GameObject loginInPWD;
+    [SerializeField] GameObject loginInCaptcha1;
     [SerializeField] GameObject loginInPhone;
     [SerializeField] GameObject loginInCode;
     [SerializeField] GameObject loginValidTime;
+    [SerializeField] GameObject loginInCaptcha2;
     [SerializeField] GameObject registerInUser;
     [SerializeField] GameObject registerInPWD1;
     [SerializeField] GameObject registerInPWD2;
@@ -28,6 +31,7 @@ public class LoginMgr : MonoBehaviour
     [SerializeField] GameObject registerInGender;
     [SerializeField] Text loginTip;
     [SerializeField] Text registerTip;
+    [SerializeField] Transform agreementTF;
 
     public static UserInfo myUserInfo = new UserInfo();
     static int userInfo_version = 1000;
@@ -37,6 +41,15 @@ public class LoginMgr : MonoBehaviour
     void Awake()
     {
         TextAutoLanguage.Init();
+
+        agreementTF.Find("TextA").GetComponent<Button>().onClick.AddListener(delegate() {
+            GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
+            o.GetComponent<AgreementView>().EnterUserAgreement();
+        });
+        agreementTF.Find("TextB").GetComponent<Button>().onClick.AddListener(delegate() {
+            GameObject o = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AgreementView"));
+            o.GetComponent<AgreementView>().EnterPrivacyAgreement();
+        });
     }
 
     void Start()
@@ -55,6 +68,35 @@ public class LoginMgr : MonoBehaviour
         }
     }
 
+    IEnumerator GetCaptcha(CaptchaType type)
+    {
+        int code = UnityEngine.Random.Range(1000, 10000);
+        UnityWebRequest uwr = new UnityWebRequest(CommonConfig.businessServerURI + "/api/createCaptcha?code=" + code, UnityWebRequest.kHttpVerbGET);
+        uwr.downloadHandler = new DownloadHandlerTexture();
+        yield return uwr.SendWebRequest();
+        Texture2D texture = DownloadHandlerTexture.GetContent(uwr);
+        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
+        switch (type) {
+            case CaptchaType.Login:
+                loginInCaptcha1.transform.Find("CodeImage").GetComponent<Image>().sprite = sprite;
+                captcha_Login = code;
+                break;
+            case CaptchaType.LoginPhone:
+                loginInCaptcha2.transform.Find("CodeImage").GetComponent<Image>().sprite = sprite;
+                captcha_LoginPhone = code;
+                break;
+            case CaptchaType.Register:
+                captcha_Register = code;
+                break;
+        }
+    }
+    enum CaptchaType {
+        Login, LoginPhone, Register
+    }
+    int captcha_Login = -222222222;
+    int captcha_LoginPhone = -222222222;
+    int captcha_Register = -222222222;
+
     InputField GetInputField(GameObject inputNode)
     {
         return inputNode.transform.Find("InputField").GetComponent<InputField>();
@@ -68,9 +110,14 @@ public class LoginMgr : MonoBehaviour
             loginMode2.GetComponent<Image>().sprite = loginModeSprites[0];
             loginInUser.SetActive(true);
             loginInPWD.SetActive(true);
+            loginInCaptcha1.SetActive(true);
             loginInPhone.SetActive(false);
             loginInCode.SetActive(false);
             loginValidTime.SetActive(false);
+            loginInCaptcha2.SetActive(false);
+            if (captcha_Login < 0) {
+                StartCoroutine(GetCaptcha(CaptchaType.Login));
+            }
         }
         else if (loginMode == 2)
         {
@@ -78,9 +125,14 @@ public class LoginMgr : MonoBehaviour
             loginMode2.GetComponent<Image>().sprite = loginModeSprites[1];
             loginInUser.SetActive(false);
             loginInPWD.SetActive(false);
+            loginInCaptcha1.SetActive(false);
             loginInPhone.SetActive(true);
             loginInCode.SetActive(true);
             loginValidTime.SetActive(true);
+            loginInCaptcha2.SetActive(true);
+            if (captcha_LoginPhone < 0) {
+                StartCoroutine(GetCaptcha(CaptchaType.LoginPhone));
+            }
         }
         loginTip.GetComponent<TextAutoLanguage>().SetText(0);
     }
@@ -106,6 +158,14 @@ public class LoginMgr : MonoBehaviour
     }
 
     public void login() {
+        if (loginMode == 1) {
+            LoginNormal(); 
+        } else if (loginMode == 2) {
+            LoginByPhone();
+        }
+    }
+
+    void LoginNormal() {
         InputField user = GetInputField(loginInUser);
         if (user.text.Trim().Length == 0) {
             loginTip.color = Color.yellow;
@@ -118,6 +178,12 @@ public class LoginMgr : MonoBehaviour
             loginTip.GetComponent<TextAutoLanguage>().SetText(42);
             return;
         }
+        // InputField captcha = GetInputField(loginInCaptcha1);
+        // if (captcha.text.Trim().Length == 0) {
+        //     loginTip.color = Color.yellow;
+        //     loginTip.GetComponent<TextAutoLanguage>().SetText(42);
+        //     return;
+        // }
         UserInfos userInfos = GetUserInfos();
         foreach (var userInfo in userInfos.list)
         {
@@ -140,6 +206,10 @@ public class LoginMgr : MonoBehaviour
         loginTip.GetComponent<TextAutoLanguage>().SetText(45);
     }
 
+    void LoginByPhone() {
+
+    }
+
     public void Register()
     {
         InputField user = GetInputField(registerInUser);

+ 8 - 0
Assets/BowArrow/Scripts/Manager/LoginView.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0303c44df93be4646b6e7ba8dfff7150
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 29 - 0
Assets/BowArrow/Scripts/Manager/LoginView/AgreementView.cs

@@ -0,0 +1,29 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class AgreementView : MonoBehaviour
+{
+    public void EnterUserAgreement() {
+        GetTitleText().text = "用户协议";
+        GetContentText().text = "\n" + GetContentText("1").text;;
+    }
+
+    public void EnterPrivacyAgreement() {
+        GetTitleText().text = "隐私政策";
+        GetContentText().text = "\n" + GetContentText("2").text;
+    }
+
+    Text GetTitleText() {
+        return transform.Find("Title").GetComponent<Text>();
+    }
+
+    Text GetContentText(string id = "") {
+        return transform.Find("ScrollView/Viewport/Content" + id).GetComponent<Text>();
+    }
+
+    public void Back() {
+        Destroy(gameObject);
+    }
+}

+ 11 - 0
Assets/BowArrow/Scripts/Manager/LoginView/AgreementView.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: db5ea2460be26e34db0692bc3cfbc48c
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/BowArrow/Textures/Common/IconBack0.png


+ 120 - 0
Assets/BowArrow/Textures/Common/IconBack0.png.meta

@@ -0,0 +1,120 @@
+fileFormatVersion: 2
+guid: 8737e8ae33ad9ee41a316a8445e0500f
+TextureImporter:
+  internalIDToNameTable: []
+  externalObjects: {}
+  serializedVersion: 11
+  mipmaps:
+    mipMapMode: 0
+    enableMipMap: 0
+    sRGBTexture: 1
+    linearTexture: 0
+    fadeOut: 0
+    borderMipMap: 0
+    mipMapsPreserveCoverage: 0
+    alphaTestReferenceValue: 0.5
+    mipMapFadeDistanceStart: 1
+    mipMapFadeDistanceEnd: 3
+  bumpmap:
+    convertToNormalMap: 0
+    externalNormalMap: 0
+    heightScale: 0.25
+    normalMapFilter: 0
+  isReadable: 0
+  streamingMipmaps: 0
+  streamingMipmapsPriority: 0
+  vTOnly: 0
+  grayScaleToAlpha: 0
+  generateCubemap: 6
+  cubemapConvolution: 0
+  seamlessCubemap: 0
+  textureFormat: 1
+  maxTextureSize: 2048
+  textureSettings:
+    serializedVersion: 2
+    filterMode: 1
+    aniso: 1
+    mipBias: 0
+    wrapU: 1
+    wrapV: 1
+    wrapW: 0
+  nPOTScale: 0
+  lightmap: 0
+  compressionQuality: 50
+  spriteMode: 1
+  spriteExtrude: 1
+  spriteMeshType: 1
+  alignment: 0
+  spritePivot: {x: 0.5, y: 0.5}
+  spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
+  alphaUsage: 1
+  alphaIsTransparency: 1
+  spriteTessellationDetail: -1
+  textureType: 8
+  textureShape: 1
+  singleChannelComponent: 0
+  flipbookRows: 1
+  flipbookColumns: 1
+  maxTextureSizeSet: 0
+  compressionQualitySet: 0
+  textureFormatSet: 0
+  ignorePngGamma: 0
+  applyGammaDecoding: 0
+  platformSettings:
+  - serializedVersion: 3
+    buildTarget: DefaultTexturePlatform
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Standalone
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  - serializedVersion: 3
+    buildTarget: Android
+    maxTextureSize: 2048
+    resizeAlgorithm: 0
+    textureFormat: -1
+    textureCompression: 1
+    compressionQuality: 50
+    crunchedCompression: 0
+    allowsAlphaSplitting: 0
+    overridden: 0
+    androidETC2FallbackOverride: 0
+    forceMaximumCompressionQuality_BC6H_BC7: 0
+  spriteSheet:
+    serializedVersion: 2
+    sprites: []
+    outline: []
+    physicsShape: []
+    bones: []
+    spriteID: 5e97eb03825dee720800000000000000
+    internalID: 0
+    vertices: []
+    indices: 
+    edges: []
+    weights: []
+    secondaryTextures: []
+  spritePackingTag: 
+  pSDRemoveMatte: 0
+  pSDShowRemoveMatteOption: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff