登录页一些效果,接路线列表页
This commit is contained in:
1 parent
d1d9c92f1c
commit
f45711f39f
78 files changed
+9990
-5830
No files matched your search
@@ -10,27 +10,76 @@ using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//记录:小f 是-457和-681
|
||||
public class LoginController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] InputField phone;
|
||||
[SerializeField] InputField pwd;
|
||||
[SerializeField] Button login;
|
||||
[SerializeField] Button loginNewAccount;
|
||||
[SerializeField] Button returnQuick;
|
||||
[SerializeField] Button sign;
|
||||
[SerializeField] GameObject loginScrollView;
|
||||
[SerializeField] GameObject signScrollView;
|
||||
[SerializeField] RawImage loading;
|
||||
private ScrollRect scrollPanel;
|
||||
private ScrollRect scrollSign;
|
||||
private Transform imagexf;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
transform.Find("RawImage").DOMove(new Vector3(0.5f,0.5f,0),1);
|
||||
if (login != null)
|
||||
//transform.Find("RawImage").DOMove(new Vector3(0.5f,0.5f,0),1);
|
||||
if (login != null)
|
||||
{
|
||||
login.onClick.AddListener(Submit);
|
||||
//login.onClick.AddListener(Submit);
|
||||
}
|
||||
if (loading != null)
|
||||
if (loading != null)
|
||||
{
|
||||
loading.texture.wrapMode = TextureWrapMode.Repeat;
|
||||
}
|
||||
if (loginScrollView != null)
|
||||
{
|
||||
scrollPanel = loginScrollView.GetComponent<ScrollRect>();
|
||||
}
|
||||
if (signScrollView != null)
|
||||
{
|
||||
scrollSign = signScrollView.GetComponent<ScrollRect>();
|
||||
}
|
||||
if (loginNewAccount != null)
|
||||
{
|
||||
loginNewAccount.onClick.AddListener(goLogin);
|
||||
}
|
||||
if (returnQuick != null)
|
||||
{
|
||||
returnQuick.onClick.AddListener(ReturnQuick);
|
||||
}
|
||||
if (sign != null)
|
||||
{
|
||||
sign.onClick.AddListener(goSign);
|
||||
}
|
||||
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
|
||||
}
|
||||
void ReturnQuick()
|
||||
{
|
||||
if (imagexf != null)
|
||||
{
|
||||
imagexf.DOLocalMove(new Vector3(0, -457, 0), 0.3f);
|
||||
}
|
||||
this.StartScrollPanel(0);
|
||||
}
|
||||
void goLogin()
|
||||
{
|
||||
if (imagexf != null)
|
||||
{
|
||||
imagexf.DOLocalMove(new Vector3(0, -681, 0), 0.3f);
|
||||
}
|
||||
this.StartScrollPanel(1);
|
||||
}
|
||||
void goSign()
|
||||
{
|
||||
this.StartScrollPanel(2);
|
||||
}
|
||||
|
||||
async void Submit()
|
||||
{
|
||||
if (phone == null || pwd == null)
|
||||
@@ -65,6 +114,8 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
pwd.ActivateInputField();
|
||||
}
|
||||
goScrollPanel();
|
||||
goScrollSign();
|
||||
//if (Input.GetKeyDown(KeyCode.Return) && )
|
||||
//{
|
||||
//}
|
||||
@@ -76,5 +127,86 @@ public class LoginController : MonoBehaviour
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
#region 主页面滑动逻辑
|
||||
private int tmpImdex = 0;
|
||||
private int scrollPanelIndex = 2;
|
||||
private float scrollValue = 0.5f;
|
||||
private bool startScrollPanel = false;
|
||||
private void StartScrollPanel(int index)
|
||||
{
|
||||
if (startScrollPanel) return;
|
||||
scrollPanelIndex = index;
|
||||
startScrollPanel = true;
|
||||
}
|
||||
private void goScrollPanel()
|
||||
{
|
||||
var index = scrollPanelIndex;
|
||||
var value = index * scrollValue;
|
||||
if (scrollPanel != null && startScrollPanel)
|
||||
{
|
||||
if (scrollPanel.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
scrollPanel.horizontalNormalizedPosition -= (scrollValue / 20);
|
||||
if (scrollPanel.horizontalNormalizedPosition <= value)
|
||||
{
|
||||
scrollPanel.horizontalNormalizedPosition = value;
|
||||
startScrollPanel = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollPanel.horizontalNormalizedPosition += (scrollValue / 20);
|
||||
if (scrollPanel.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
scrollPanel.horizontalNormalizedPosition = value;
|
||||
startScrollPanel = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
private void Test()
|
||||
{
|
||||
//if (startScrollPanel) return;
|
||||
//scrollPanelIndex = ((int)System.Math.Pow(tmpImdex, 3)
|
||||
// + 2*(int)System.Math.Pow(tmpImdex, 2)
|
||||
// + 1) % 4;
|
||||
//tmpImdex++;
|
||||
//Debug.Log(scrollPanelIndex);
|
||||
//startScrollPanel = true;
|
||||
if (startScrollSign) return;
|
||||
scrollSignIndex = (scrollSignIndex + 1) % 2;
|
||||
Debug.Log(scrollSignIndex);
|
||||
startScrollSign = true;
|
||||
}
|
||||
#region 注册页面滑动逻辑
|
||||
private bool startScrollSign = false;
|
||||
private int scrollSignIndex = 0;
|
||||
private void goScrollSign()
|
||||
{
|
||||
float value = scrollSignIndex;
|
||||
if (scrollSign != null && startScrollSign)
|
||||
{
|
||||
if (scrollSignIndex == 0)
|
||||
{
|
||||
scrollSign.horizontalNormalizedPosition -= (1f / 20);
|
||||
if (scrollSign.horizontalNormalizedPosition <= 0)
|
||||
{
|
||||
scrollSign.horizontalNormalizedPosition = 0;
|
||||
startScrollSign = false;
|
||||
}
|
||||
}
|
||||
else if (scrollSignIndex == 1)
|
||||
{
|
||||
scrollSign.horizontalNormalizedPosition += (1f / 20);
|
||||
if (scrollSign.horizontalNormalizedPosition >= 1)
|
||||
{
|
||||
scrollSign.horizontalNormalizedPosition = 1;
|
||||
startScrollSign = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b4cb8aeab1a46c42ae544f394538b87
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class MapListScript : MonoBehaviour, IEndDragHandler
|
||||
{
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
var sc = gameObject.transform.parent.GetComponent<MapListController>();
|
||||
if (eventData.position.y < 0)
|
||||
{
|
||||
sc.Refresh();
|
||||
}
|
||||
if (eventData.position.y + Screen.height > sc.Content.GetComponent<RectTransform>().rect.height)
|
||||
{
|
||||
sc.pageIndex++;
|
||||
sc.GetList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b590b8b6670b334ea1953fea1deba17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MyMap
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int rank { get; set; }
|
||||
public string image { get; set; }
|
||||
}
|
||||
public class MapScript : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
[SerializeField] Text text;
|
||||
[SerializeField] GameObject panel;
|
||||
[SerializeField] RawImage rawImage;
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void Initial(MapRoute myMap)
|
||||
{
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(()=>
|
||||
{
|
||||
//SceneManager.LoadScene("4-Demo", LoadSceneMode.Additive);
|
||||
});
|
||||
text.text = myMap.Name;
|
||||
Utils.DisplayImage(StartCoroutine, rawImage, myMap.CoverImage);
|
||||
int i = 0;
|
||||
foreach (RectTransform transform in panel.transform)
|
||||
{
|
||||
//if (i < myMap.rank && i < 5)
|
||||
if (i < 3 && i<5)
|
||||
{
|
||||
transform.GetComponent<Image>().color = new Color(255, 255, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2521131d8a9d2564390f6228711f4522
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HomeController : MonoBehaviour
|
||||
@@ -18,7 +19,8 @@ public class HomeController : MonoBehaviour
|
||||
[SerializeField] Text Climb;
|
||||
[SerializeField] Text NickName;
|
||||
[SerializeField] Button More;
|
||||
|
||||
[SerializeField] Button BtnRide;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -39,7 +41,7 @@ public class HomeController : MonoBehaviour
|
||||
//{
|
||||
// More.onClick.AddListener(MoreFunc);
|
||||
//}
|
||||
|
||||
BtnRide.onClick.AddListener(GoRide);
|
||||
var wifi = this.transform.Find("MainToolContainer").Find("Wifi");
|
||||
UIManager.AddEvent(wifi.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
@@ -54,7 +56,11 @@ public class HomeController : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void GoRide()
|
||||
{
|
||||
UIManager.ShowMapListPanel();
|
||||
//SceneManager.LoadScene("3-MapList");
|
||||
}
|
||||
|
||||
void MoreFunc()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MapListController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
[SerializeField] GameObject map;
|
||||
[SerializeField] GameObject content;
|
||||
[SerializeField] Dropdown hardSelector;
|
||||
[HideInInspector] public int pageIndex = 0;
|
||||
[HideInInspector] public int pageSize = 20;
|
||||
[HideInInspector] public string hard = "全部";
|
||||
public GameObject Content {
|
||||
get
|
||||
{
|
||||
return content;
|
||||
}
|
||||
}
|
||||
private bool isEnd = false;
|
||||
void Start()
|
||||
{
|
||||
if (hardSelector != null)
|
||||
{
|
||||
hardSelector.onValueChanged.AddListener(ChangeHard);
|
||||
}
|
||||
if (content!=null)
|
||||
{
|
||||
var transform = content.transform.GetComponent<RectTransform>();
|
||||
var layout = content.GetComponent<GridLayoutGroup>();
|
||||
if (layout != null)
|
||||
{
|
||||
var width = transform.rect.width;
|
||||
layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
|
||||
}
|
||||
}
|
||||
GetList();
|
||||
|
||||
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
|
||||
//obj.transform.parent = transform.parent;
|
||||
}
|
||||
|
||||
private void ChangeHard(int index)
|
||||
{
|
||||
var text = hardSelector.options[index].text;
|
||||
if (text == "全部难度")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = Global.mapApi.GetList(pageIndex, pageSize, "");
|
||||
if (res.result)
|
||||
{
|
||||
|
||||
if (res.data.Count == 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayMaps(res.data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void DisplayMaps(List<MapRoute> list)
|
||||
{
|
||||
if (map != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(map);
|
||||
obj.GetComponent<MapScript>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content.transform;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
pageIndex = 0;
|
||||
GetList();
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e87cee7d1f8eeb94d986bf6d6eaf4cbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -45,7 +45,14 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("DevicePanel", ref this.mDeviceController);
|
||||
}
|
||||
}
|
||||
|
||||
private MapListController mMapListController;
|
||||
public MapListController MapListPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("MapListPanel", ref this.mMapListController);
|
||||
}
|
||||
}
|
||||
public static UIManager Instance;
|
||||
|
||||
private void Awake()
|
||||
@@ -134,7 +141,10 @@ public class UIManager : MonoBehaviour
|
||||
public static void ShowLoadingDialogBox()
|
||||
{
|
||||
}
|
||||
|
||||
public static void ShowMapListPanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction<BaseEventData> call)
|
||||
{
|
||||
EventTrigger et = gameObject.GetComponent<EventTrigger>();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -16,16 +17,21 @@ namespace Assets.Scripts
|
||||
/*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/
|
||||
public static void showToast(GameObject game,string text,int duration = 1)
|
||||
{
|
||||
var toast = Utils.FindUpParent(game.transform).Find("ToastContainer");
|
||||
if (toast!=null)
|
||||
var parent = Utils.FindUpParent(game.transform);
|
||||
var toast = parent.Find("ToastContainer");
|
||||
if (toast == null)
|
||||
{
|
||||
toast.GetComponent<Toast>().showToast(JsonConvert.SerializeObject(new
|
||||
{
|
||||
text,
|
||||
duration
|
||||
}));
|
||||
//toast.SendMessage("showToast", );
|
||||
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
|
||||
newToast.name = "ToastContainer";
|
||||
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
|
||||
newToast.transform.parent = parent;
|
||||
toast = newToast.transform;
|
||||
}
|
||||
toast.GetComponent<Toast>().showToast(JsonConvert.SerializeObject(new
|
||||
{
|
||||
text,
|
||||
duration
|
||||
}));
|
||||
}
|
||||
/*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/
|
||||
|
||||
|
||||
Reference in new issue
Block a user