This commit is contained in:
huyulong 2024-11-27 01:13:25 +08:00
commit 694e658cf2
6 changed files with 294 additions and 1696 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,3 @@
internal class TextMeshUGUI
{
}

View File

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

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using TMPro;
//MD FUCK Everthing
//史山,别学
@ -27,19 +28,23 @@ public class mainBTN :main_game
public GameObject BTN_1;
public GameObject BTN_2;
public GameObject BTN_3;
[Header("BTN的父节点")]
public GameObject BTNBox;
[Header("下面是显示部分")]
public Image playerIcon;
public TextMeshProUGUI playerName;
public TextMeshProUGUI playerWoKeNumber;
public TextMeshProUGUI playerWoDanNumber;
public GameObject BTN_0_0;
public GameObject BTN_1_1;
public GameObject BTN_2_2;
public GameObject BTN_3_3;
private float startPosY;
private float clickPosY;
// Start is called before the first frame update
public override void Start()
{
base.Start();
base.Start();
// 确保mainPanel不为空
if (mainPanel == null)
@ -51,10 +56,18 @@ public class mainBTN :main_game
mainPanelRect = mainPanel.GetComponent<RectTransform>();
// 添加按钮点击事件
BTN_0.GetComponent<Button>().onClick.AddListener(() => MovePanel(0));
BTN_1.GetComponent<Button>().onClick.AddListener(() => MovePanel(-2100));
BTN_2.GetComponent<Button>().onClick.AddListener(() => MovePanel(-3760));
BTN_3.GetComponent<Button>().onClick.AddListener(() => MovePanel(-5350));
BTN_0.GetComponent<Button>().onClick.AddListener(() => {
MovePanel(0);
});
BTN_1.GetComponent<Button>().onClick.AddListener(() => {
MovePanel(-2100);
});
BTN_2.GetComponent<Button>().onClick.AddListener(() => {
MovePanel(-3760);
});
BTN_3.GetComponent<Button>().onClick.AddListener(() => {
MovePanel(-5350);
});
BTN5.onClick.AddListener(() => {
@ -70,27 +83,84 @@ public class mainBTN :main_game
asyncOnShopBTN(BTN8, panel8);
});
startPosY = BTN_0.transform.position.y;
clickPosY = startPosY + Screen.height * 0.02f;
MovePanel(-3760);
}
void BTNMove(float targetX)
{
if (targetX==0)
{
BTN_0.transform.SetParent(this.transform);
BTN_1.transform.SetParent(BTNBox.transform);
BTN_2.transform.SetParent(BTNBox.transform);
BTN_3.transform.SetParent(BTNBox.transform);
BTN_0.transform.DOMoveY(clickPosY, 0.1f);
BTN_1.transform.DOMoveY(startPosY, 0.1f);
BTN_2.transform.DOMoveY(startPosY, 0.1f);
BTN_3.transform.DOMoveY(startPosY, 0.1f);
return;
}
else if (targetX == -2100)
{
BTN_0.transform.SetParent(BTNBox.transform);
BTN_1.transform.SetParent(this.transform);
BTN_2.transform.SetParent(BTNBox.transform);
BTN_3.transform.SetParent(BTNBox.transform);
BTN_0.transform.DOMoveY(startPosY, 0.1f);
BTN_1.transform.DOMoveY(clickPosY, 0.1f);
BTN_2.transform.DOMoveY(startPosY, 0.1f);
BTN_3.transform.DOMoveY(startPosY, 0.1f);
return;
}
else if (targetX == -3760)
{
BTN_0.transform.SetParent(BTNBox.transform);
BTN_1.transform.SetParent(BTNBox.transform);
BTN_2.transform.SetParent(this.transform);
BTN_3.transform.SetParent(BTNBox.transform);
BTN_0.transform.DOMoveY(startPosY, 0.1f);
BTN_1.transform.DOMoveY(startPosY, 0.1f);
BTN_2.transform.DOMoveY(clickPosY, 0.1f);
BTN_3.transform.DOMoveY(startPosY, 0.1f);
return;
}
else if (targetX == -5350)
{
BTN_0.transform.SetParent(BTNBox.transform);
BTN_1.transform.SetParent(BTNBox.transform);
BTN_2.transform.SetParent(BTNBox.transform);
BTN_3.transform.SetParent(this.transform);
BTN_0.transform.DOMoveY(startPosY, 0.1f);
BTN_1.transform.DOMoveY(startPosY, 0.1f);
BTN_2.transform.DOMoveY(startPosY, 0.1f);
BTN_3.transform.DOMoveY(clickPosY, 0.1f);
return;
}
}
// 统一的面板移动方法
public void MovePanel(float targetX)
{
// ¸üа´Å¥µÄÏÔʾºÍÒþ²Ø
BTN_0.SetActive(targetX != 0);
BTN_1.SetActive(targetX != -2100);
BTN_2.SetActive(targetX != -3760);
BTN_3.SetActive(targetX != -5350);
BTN_0_0.SetActive(targetX == 0);
BTN_1_1.SetActive(targetX == -2100);
BTN_2_2.SetActive(targetX == -3760);
BTN_3_3.SetActive(targetX == -5350);
BTNMove(targetX);
// 使用 DOTween 实现平滑移动
mainPanelRect.DOKill(); // 杀死之前的动画,防止重复动画干扰
mainPanelRect.DOAnchorPosX(targetX, 0.3f).SetEase(Ease.Linear);
}
void UpDatePlayer(Sprite playerIcon, string playerName,string playerWoKeNumber,string playerWoDanNumber)
{
this.playerIcon.sprite = playerIcon;
this.playerName.text = playerName;
this.playerWoKeNumber.text = playerWoKeNumber;
this.playerWoDanNumber.text = playerWoDanNumber;
}
}

View File

@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class main_RedDot : MonoBehaviour
{
public GameObject redDot;
public void ShowRedDot()
{
redDot.SetActive(true);
}
public void HideRedDot()
{
redDot.SetActive(false);
}
}

View File

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