Compare commits
2 Commits
b28b874dc5
...
bfca46aa5f
Author | SHA1 | Date | |
---|---|---|---|
|
bfca46aa5f | ||
|
a3af9db6f7 |
File diff suppressed because it is too large
Load Diff
24
TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs
Normal file
24
TheStrongestSnail/Assets/Scripts/Conversion/Conversion.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class Conversion : BaseUIPanel
|
||||||
|
{
|
||||||
|
public Button Button1;
|
||||||
|
public Button Button2;
|
||||||
|
public GameObject game;
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Button1.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.ShellToEgg));
|
||||||
|
Button2.onClick.AddListener(() =>ButtononClick(ConversionItem.mode.EggToShell));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ButtononClick(ConversionItem.mode mymode)
|
||||||
|
{
|
||||||
|
Canvas canvas = GetComponentInParent<Canvas>();
|
||||||
|
|
||||||
|
GameObject conver = Instantiate(game, canvas.transform);
|
||||||
|
conver.GetComponentInChildren<ConversionItem>().mymode = mymode;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 530b2572632928c469745e8007fafce2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -6,6 +6,7 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
public class ConversionItem : BaseUIPanel
|
public class ConversionItem : BaseUIPanel
|
||||||
{
|
{
|
||||||
@ -14,18 +15,48 @@ public class ConversionItem : BaseUIPanel
|
|||||||
|
|
||||||
public Button button1;
|
public Button button1;
|
||||||
public Button button2;
|
public Button button2;
|
||||||
|
|
||||||
|
|
||||||
|
public Image Image1;
|
||||||
|
public Image Image2;
|
||||||
|
public Sprite shellSprite;
|
||||||
|
public Sprite eggSprite;
|
||||||
public mode mymode = mode.ShellToEgg;
|
public mode mymode = mode.ShellToEgg;
|
||||||
private void Start()
|
|
||||||
|
public class coinsConvert
|
||||||
|
{
|
||||||
|
public float voluteCoin;
|
||||||
|
public float beansCoin;
|
||||||
|
public int convertType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void Start()
|
||||||
{
|
{
|
||||||
inputField.onValueChanged.AddListener(GetInputData);
|
inputField.onValueChanged.AddListener(GetInputData);
|
||||||
button1.onClick.AddListener(() => CancelOnClick(button1));
|
button1.onClick.AddListener(() => CancelOnClick(button1));
|
||||||
button2.onClick.AddListener(() => ConfirmOnClick(button2));
|
button2.onClick.AddListener(() => ConfirmOnClick(button2));
|
||||||
TextMeshProUGUI.text = "0";
|
TextMeshProUGUI.text = "0";
|
||||||
|
|
||||||
|
//testhead = await testLogo();//测试登录
|
||||||
}
|
}
|
||||||
public enum mode
|
public enum mode
|
||||||
{
|
{
|
||||||
ShellToEgg,
|
ShellToEgg = 0,//蜗壳转蜗蛋
|
||||||
EggToShell
|
EggToShell = 1//蜗蛋转蜗壳
|
||||||
|
}
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (mymode == mode.ShellToEgg)
|
||||||
|
{
|
||||||
|
Image1.sprite = shellSprite;
|
||||||
|
Image2.sprite = eggSprite;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Image2.sprite = shellSprite;
|
||||||
|
Image1.sprite = eggSprite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public async void CancelOnClick(Button button)//È¡Ïû°´Å¥
|
public async void CancelOnClick(Button button)//È¡Ïû°´Å¥
|
||||||
{
|
{
|
||||||
@ -35,20 +66,44 @@ public class ConversionItem : BaseUIPanel
|
|||||||
public async void ConfirmOnClick(Button button)//È·¶¨°´Å¥
|
public async void ConfirmOnClick(Button button)//È·¶¨°´Å¥
|
||||||
{
|
{
|
||||||
await ButtonClickAnimationAsync(button.gameObject);
|
await ButtonClickAnimationAsync(button.gameObject);
|
||||||
Regex.IsMatch(inputField.text, @"^[1-9]\d*$");
|
if (IsGreaterThanZeroDecimal(inputField.text))
|
||||||
addEventPopUp("²âÊÔµ¯´°");
|
{
|
||||||
|
coinsConvert body = new coinsConvert();
|
||||||
|
if (mymode == mode.ShellToEgg)
|
||||||
|
{
|
||||||
|
body.voluteCoin = float.Parse(inputField.text);
|
||||||
|
body.beansCoin = float.Parse(TextMeshProUGUI.text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
body.voluteCoin = float.Parse(TextMeshProUGUI.text);
|
||||||
|
body.beansCoin = float.Parse(inputField.text);
|
||||||
|
}
|
||||||
|
body.convertType = (int)mymode;
|
||||||
|
//string response = await web.SendRequest(web.URL + "/snail/user/coinsConvert", "POST", JsonUtility.ToJson(body), testhead);//测试
|
||||||
|
string response = await web.SendRequest(web.URL + "/snail/user/coinsConvert", "POST", JsonUtility.ToJson(body), Global.global.CreateHeaders());//正式接入
|
||||||
|
Debug.Log("入参:"+ JsonUtility.ToJson(body) + " 1.8返回: " + response);
|
||||||
|
ServerResponse18 serverResponse = JsonConvert.DeserializeObject<ServerResponse18>(response);
|
||||||
|
addEventPopUp(serverResponse.message);
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addEventPopUp("请输入正确的数量");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetInputData(string userInput)
|
public void GetInputData(string userInput)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(userInput)) {
|
if (string.IsNullOrWhiteSpace(userInput) || !IsGreaterThanZeroDecimal(inputField.text)) {
|
||||||
userInput = "0";
|
userInput = "0";
|
||||||
}
|
}
|
||||||
TextMeshProUGUI.text = "0";
|
TextMeshProUGUI.text = "0";
|
||||||
if (mymode == mode.ShellToEgg)
|
if (mymode == mode.ShellToEgg)
|
||||||
TextMeshProUGUI.text = (int.Parse(userInput) * 3).ToString();
|
TextMeshProUGUI.text = (float.Parse(userInput) * 3).ToString("F2");
|
||||||
if (mymode == mode.EggToShell)
|
if (mymode == mode.EggToShell)
|
||||||
TextMeshProUGUI.text = (int.Parse(userInput) / 3).ToString();
|
TextMeshProUGUI.text = (float.Parse(userInput) / 3).ToString("F2");
|
||||||
|
|
||||||
ButtonClickAnimationAsync(TextMeshProUGUI.gameObject);
|
ButtonClickAnimationAsync(TextMeshProUGUI.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,12 @@ public class ServerResponse514: Response
|
|||||||
{
|
{
|
||||||
public Data514 data; // 数据对象
|
public Data514 data; // 数据对象
|
||||||
}
|
}
|
||||||
|
[Serializable]
|
||||||
|
public class ServerResponse18 : Response
|
||||||
|
{
|
||||||
|
public object data; // 数据对象
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
public class Response
|
public class Response
|
||||||
{
|
{
|
||||||
public int code; // 响应状态码
|
public int code; // 响应状态码
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
//panel基类,主要用于panel的显示和隐藏
|
//panel基类,主要用于panel的显示和隐藏
|
||||||
//初始化会隐藏Panel
|
//初始化会隐藏Panel
|
||||||
@ -31,18 +32,25 @@ public class BaseUIPanel : Base
|
|||||||
public virtual void ShopPanel()
|
public virtual void ShopPanel()
|
||||||
{
|
{
|
||||||
Panel.gameObject.SetActive(true);
|
Panel.gameObject.SetActive(true);
|
||||||
CloseBTN.gameObject.SetActive(true);
|
if (CloseBTN != null)
|
||||||
|
{
|
||||||
|
CloseBTN.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
Panel.transform.DOScale(1f, 0.3f);
|
Panel.transform.DOScale(1f, 0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 隐藏面板,可以重写
|
/// 隐藏面板,可以重写
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void HidePanel()
|
public virtual async Task HidePanel()
|
||||||
{
|
{
|
||||||
Panel.transform.DOScale(0.5f,0.2f);
|
Panel.transform.DOScale(0.5f,0.2f);
|
||||||
CloseBTN.gameObject.SetActive(false);
|
if (CloseBTN != null)
|
||||||
|
{
|
||||||
|
CloseBTN.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
Panel.gameObject.SetActive(false);
|
Panel.gameObject.SetActive(false);
|
||||||
|
await Task.Delay(200);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ public class EventPopUp : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Canvas canvas = GetComponentInParent<Canvas>();
|
Canvas canvas = GetComponentInParent<Canvas>();
|
||||||
float canvasHeight = canvas.GetComponent<RectTransform>().rect.height;
|
float canvasHeight = canvas.GetComponent<RectTransform>().rect.height;
|
||||||
transform.DOMoveY(canvasHeight - 200f, 1.5f);
|
transform.DOMoveY(canvasHeight - (canvasHeight*0.3f), 1.5f);
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
Image.DOColor(new Color(1f, 1f, 1f, 0f), 5f);
|
Image.DOColor(new Color(1f, 1f, 1f, 0f), 5f);
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5100);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class Base : MonoBehaviour
|
public class Base : MonoBehaviour
|
||||||
{
|
{
|
||||||
public async Task ButtonClickAnimationAsync(GameObject button)
|
public async Task ButtonClickAnimationAsync(GameObject button)//按钮动画
|
||||||
{
|
{
|
||||||
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||||
Sequence mySequence = DOTween.Sequence();
|
Sequence mySequence = DOTween.Sequence();
|
||||||
@ -19,12 +21,46 @@ public class Base : MonoBehaviour
|
|||||||
await tcs.Task;
|
await tcs.Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEventPopUp(string Details)
|
public void addEventPopUp(string Details)//添加弹窗
|
||||||
{
|
{
|
||||||
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
|
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
|
||||||
Canvas canvas = GetComponentInParent<Canvas>();
|
Canvas canvas = GetComponentInParent<Canvas>();
|
||||||
prefab.GetComponent<EventPopUp>().text = Details;
|
prefab.GetComponent<EventPopUp>().text = Details;
|
||||||
Instantiate(prefab, canvas.transform);
|
Instantiate(prefab, canvas.transform);
|
||||||
}
|
}
|
||||||
|
logoPanel.ServerResponse TestserverResponse;
|
||||||
|
protected Dictionary<string, string> testhead;
|
||||||
|
public async Task<Dictionary<string, string>> testLogo()//测试登录
|
||||||
|
{
|
||||||
|
|
||||||
|
LoginAndGetToken.loginbody body = new LoginAndGetToken.loginbody
|
||||||
|
{
|
||||||
|
userName = "15151658596",
|
||||||
|
password = "123456",
|
||||||
|
verifyCode = 111111
|
||||||
|
};
|
||||||
|
string loginResponse = await web.SendRequest(web.URL + "/snail/user/login", "POST", JsonUtility.ToJson(body));
|
||||||
|
logoPanel.ServerResponse response = JsonUtility.FromJson<logoPanel.ServerResponse>(loginResponse);
|
||||||
|
if (response != null && response.code == 200 && response.data != null)
|
||||||
|
{
|
||||||
|
TestserverResponse = response;
|
||||||
|
addEventPopUp("测试登录成功");
|
||||||
|
|
||||||
|
return new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "Authorization", TestserverResponse.data.token }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
addEventPopUp("测试登录失败");
|
||||||
|
return new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsGreaterThanZeroDecimal(string text)//判断必须为小数而且大于0
|
||||||
|
{
|
||||||
|
// 使用正则表达式匹配大于0的小数
|
||||||
|
string pattern = @"^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$";
|
||||||
|
Regex regex = new Regex(pattern);
|
||||||
|
|
||||||
|
return regex.IsMatch(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
TheStrongestSnail/Assets/res/AllUI/ui_145.png
Normal file
BIN
TheStrongestSnail/Assets/res/AllUI/ui_145.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
135
TheStrongestSnail/Assets/res/AllUI/ui_145.png.meta
Normal file
135
TheStrongestSnail/Assets/res/AllUI/ui_145.png.meta
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1eb81db3ba5d67749baba23351f73479
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 12
|
||||||
|
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
|
||||||
|
ignoreMasterTextureLimit: 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
|
||||||
|
cookieLightType: 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: iPhone
|
||||||
|
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: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user