WXGame/Blacksmith/Assets/Script/UI/GuidePanel.cs

257 lines
8.9 KiB
C#
Raw Normal View History

2024-12-24 17:05:51 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class GuidePanel : MonoBehaviour
{
[SerializeField] private List<RectTransform> textList;
[SerializeField] private RectTransform seleTra;
[SerializeField] private Button eventButton;
[SerializeField] private ForgePanel _forgePanel;
[SerializeField] private BattlePanel _battlePanel;
[SerializeField] private RogenItem _rogenItem;
[SerializeField] private Image _sceleImage;
[SerializeField] private Text _text;
2024-12-25 16:04:25 +08:00
[SerializeField] private RectTransform text2Tra;
2024-12-24 17:05:51 +08:00
[SerializeField] private Text _text2;
[SerializeField] private GameObject crafting;
[SerializeField] private GameObject cra2;
[SerializeField] private RectTransform hand;
private Tween ani;
private Tween ani2;
[SerializeField] private RectTransform lock1;
[SerializeField] private RectTransform lock2;
[SerializeField] private RectTransform lock2c1;
[SerializeField] private RectTransform lock3;
[SerializeField] private RectTransform lock4;
[SerializeField] private RectTransform lock5;
[SerializeField] private RectTransform lock5c1;
[SerializeField] private RectTransform lock5c2;
[SerializeField] private RectTransform lock6;
[SerializeField] private RectTransform lock7;
[SerializeField] private RectTransform lock8;
private void Start()
{
}
public void GLock1()
{
_sceleImage.gameObject.SetActive(false);
_text.text = "点击开店";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
_text2.gameObject.SetActive(false);
seleTra.position = lock1.position;
eventButton.onClick.AddListener(Event1);
}
private void Event1()
{
eventButton.onClick.RemoveListener(Event1);
seleTra.position = lock2.position;
eventButton.onClick.AddListener(SaveE1);
_sceleImage.gameObject.SetActive(true);
_text.text = "拖拽到锻造栏";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[3].position;
2024-12-24 17:05:51 +08:00
_forgePanel.GuideV1();
var data = JsonTab.Instance.tables.Item.Get(1011);
_sceleImage.sprite = AssetBundleManager.ins.Sprite(data.Icon, AtlasType.ItemIcon);
_sceleImage.GetComponent<RectTransform>().position = lock2.position;
ani2=_sceleImage.GetComponent<RectTransform>().DOMove(lock2c1.position, 1f).SetLoops(-1);
hand.localPosition = Vector3.zero;
ani.Kill();
ani= hand.GetComponent<RectTransform>().DOMove(lock2c1.position, 1f).SetLoops(-1);
}
private void SaveE1()
{
GameSystem.ins.drawingManager.itemsSlot[0] = 1011;
_forgePanel.ResetSlotItem();
eventButton.onClick.RemoveListener(SaveE1);
eventButton.onClick.AddListener(SaveE2);
}
private void SaveE2()
{
GameSystem.ins.drawingManager.itemsSlot[1] = 1011;
_forgePanel.ResetSlotItem();
eventButton.onClick.RemoveListener(SaveE2);
eventButton.onClick.AddListener(SaveE3);
}
private void SaveE3()
{
GameSystem.ins.drawingManager.itemsSlot[2] = 1011;
_forgePanel.ResetSlotItem();
eventButton.onClick.RemoveListener(SaveE3);
_sceleImage.gameObject.SetActive(false);
ani.Kill();
ani= hand.GetComponent<RectTransform>().DOLocalMove(Vector3.zero, 0.1f);
_text.text = "点击锻造";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[2].position;
2024-12-24 17:05:51 +08:00
seleTra.position = lock3.position;
eventButton.onClick.AddListener(Event2);
}
private void Event2()
{
eventButton.onClick.RemoveListener(Event2);
eventButton.gameObject.SetActive(false);
GetComponent<Image>().enabled = false;
seleTra.gameObject.SetActive(false);
_text2.gameObject.SetActive(true);
_text2.text = "在红色区域点击加速";
_forgePanel.CraftGuideEvent(() =>
{
Event3();
});
}
private void Event3()
{
seleTra.gameObject.SetActive(true);
seleTra.position = lock2c1.position;
eventButton.onClick.AddListener(Event4);
eventButton.gameObject.SetActive(true);
_text2.gameObject.SetActive(false);
GetComponent<Image>().enabled = true;
_text.text = "点击任意区域关闭页面";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
}
private void Event4()
{
seleTra.position = lock5.position;
crafting.SetActive(false);
eventButton.onClick.RemoveListener(Event4);
eventButton.onClick.AddListener(Event4c1);
_text.text = "拖拽铁剑给客户";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[1].position;
2024-12-24 17:05:51 +08:00
_sceleImage.gameObject.SetActive(true);
var data = JsonTab.Instance.tables.Item.Get(2011);
_sceleImage.sprite = AssetBundleManager.ins.Sprite(data.Icon, AtlasType.ItemIcon);
ani2.Kill();
_sceleImage.GetComponent<RectTransform>().position = lock5.position;
ani2=_sceleImage.GetComponent<RectTransform>().DOMove(lock5c1.position, 1f).SetLoops(-1);
hand.localPosition = Vector3.zero;
ani.Kill();
ani=hand.GetComponent<RectTransform>().DOMove(lock5c1.position, 1f).SetLoops(-1);
}
private void Event4c1()
{
_sceleImage.gameObject.SetActive(false);
seleTra.position = lock2c1.position;
ani.Kill();
ani= hand.GetComponent<RectTransform>().DOLocalMove(Vector3.zero, 0.1f);
eventButton.onClick.RemoveListener(Event4c1);
eventButton.onClick.AddListener(Event5);
GameSystem.ins.GuideV2();
_text.text = "点击关闭";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
}
private void Event5()
{
seleTra.position = lock4.position;
cra2.SetActive(false);
eventButton.onClick.RemoveListener(Event5);
eventButton.onClick.AddListener(Event6);
_text.text = "点击关店";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[1].position;
2024-12-24 17:05:51 +08:00
}
private void Event6()
{
seleTra.position = lock5c2.position;
eventButton.onClick.RemoveListener(Event6);
GameSystem.ins.CloseStore();
eventButton.onClick.AddListener(Event6c1);
}
private void Event6c1()
{
eventButton.onClick.RemoveListener(Event6c1);
UIMgr.ins.OpenBattlePanel();
DataManager.SetPrefab("firstGuideV1",1);
}
public void Event7()
{
_sceleImage.gameObject.SetActive(false);
_text2.gameObject.SetActive(false);
seleTra.position = lock6.position;
_text.text = "点击开始进入关卡";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
eventButton.onClick.AddListener(Event8);
}
private void Event8()
{
eventButton.onClick.RemoveListener(Event8);
seleTra.position = lock7.position;
_text.text = "点击放置武器";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
DataManager.AddItem(2011,3);
_battlePanel.OpenCombatPanel();
eventButton.onClick.AddListener(Event9);
}
private void Event9()
{
eventButton.onClick.RemoveListener(Event9);
BattleManager.ins.GetItemNum(2011,out var itemNum);
if (DataManager.GetItem(2011) - itemNum-1>=0)
{
BattleManager.ins.AddItem(2011,out bool bo);
UIMgr.ins.ResetBattleReadyPanel();
}
eventButton.onClick.AddListener(Event10);
}
private void Event10()
{
eventButton.onClick.RemoveListener(Event10);
BattleManager.ins.GetItemNum(2011,out var itemNum);
if (DataManager.GetItem(2011) - itemNum-1>=0)
{
BattleManager.ins.AddItem(2011,out bool bo);
UIMgr.ins.ResetBattleReadyPanel();
}
eventButton.onClick.AddListener(Event11);
}
private void Event11()
{
eventButton.onClick.RemoveListener(Event11);
BattleManager.ins.GetItemNum(2011,out var itemNum);
if (DataManager.GetItem(2011) - itemNum-1>=0)
{
BattleManager.ins.AddItem(2011,out bool bo);
UIMgr.ins.ResetBattleReadyPanel();
}
seleTra.position = lock8.position;
2024-12-25 16:04:25 +08:00
_text.text = "点击开始游戏";
2024-12-24 17:05:51 +08:00
eventButton.onClick.AddListener(Event12);
}
private void Event12()
{
eventButton.onClick.RemoveListener(Event12);
gameObject.SetActive(false);
BattleManager.ins.StartBattle();
DataManager.SetPrefab("firstGuideV2",1);
}
public void Event13()
{
_sceleImage.gameObject.SetActive(false);
_text2.gameObject.SetActive(false);
seleTra.position = _rogenItem.transform.position;
_text.text = "点击随机技能";
2024-12-25 16:04:25 +08:00
text2Tra.position = textList[0].position;
2024-12-24 17:05:51 +08:00
eventButton.onClick.AddListener(Event14);
}
public void Event14()
{
gameObject.SetActive(false);
_rogenItem.SendEvent();
eventButton.onClick.RemoveListener(Event14);
DataManager.SetPrefab("firstGuideV3",1);
}
}