Cute_demon_attacks/meng_yao/Assets/script/JumpScene/SceneBtn.cs

237 lines
6.5 KiB
C#
Raw Normal View History

2024-10-28 22:05:14 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
2024-10-30 01:08:16 +08:00
using DG.Tweening;
2024-10-28 22:05:14 +08:00
public class SceneBtn : MonoBehaviour
{
2024-10-30 01:08:16 +08:00
2024-10-28 22:05:14 +08:00
public Button shopbtn;
public Button Developbtn;
public Button Troughbtn;
public Button Herobtn;
public Button Treebtn;
2024-10-30 01:08:16 +08:00
public Sprite showtextbg;
public Sprite showtextup;
public Sprite removetextbg;
public Sprite removetextup;
private RectTransform Developpanel;
private RectTransform shoppanel;
private RectTransform Troughpanel;
private RectTransform heropanel;
private RectTransform treepanel;
private Image shopimagebg;
private Image shopimagerup;
private Image Developimagebg;
private Image Developimagerup;
private Image Troughimagebg;
private Image Troughmagerup;
private Image Heroimagebg;
private Image Heroimagerup;
private Image Treeimagebg;
private Image Treeimagerup;
Vector3 Deflate = new Vector3(0.5f, 0.5f, 0.5f);
2024-11-08 16:29:30 +08:00
public List<GameObject> Scenelist = new List<GameObject>();
2024-10-28 22:05:14 +08:00
void Start()
{
shopbtn.onClick.AddListener(shopClick);
Developbtn.onClick.AddListener(DevelopClick);
Troughbtn.onClick.AddListener(TroughClick);
Herobtn.onClick.AddListener(HeroClick);
Treebtn.onClick.AddListener(TreeClick);
2024-10-30 01:08:16 +08:00
Developpanel = Developbtn.GetComponent<RectTransform>();
shoppanel = shopbtn.GetComponent<RectTransform>();
Troughpanel = Troughbtn.GetComponent<RectTransform>();
heropanel = Herobtn.GetComponent<RectTransform>();
treepanel = Treebtn.GetComponent<RectTransform>();
shopimagebg = shopbtn.transform.Find("Bg").GetComponent<Image>();
shopimagerup= shopbtn.transform.Find("TxtBorder").GetComponent<Image>();
Developimagebg = Developbtn.transform.Find("Bg").GetComponent<Image>();
Developimagerup = Developbtn.transform.Find("TxtBorder").GetComponent<Image>();
Troughimagebg = Troughbtn.transform.Find("Bg").GetComponent<Image>();
Troughmagerup = Troughbtn.transform.Find("TxtBorder").GetComponent<Image>();
Heroimagebg =Herobtn.transform.Find("Bg").GetComponent<Image>();
Heroimagerup = Herobtn.transform.Find("TxtBorder").GetComponent<Image>();
Treeimagebg = Treebtn.transform.Find("Bg").GetComponent<Image>();
Treeimagerup = Treebtn.transform.Find("TxtBorder").GetComponent<Image>();
2024-10-30 03:45:54 +08:00
// BeginLoad(JumpScene.jumpbool);
2024-10-30 01:08:16 +08:00
2024-10-30 03:45:54 +08:00
}
private void Update()
{
2024-11-08 16:29:30 +08:00
switch (JumpScene.jumpbool)
2024-10-30 03:45:54 +08:00
{
2024-11-08 16:29:30 +08:00
case 0: //
RemoveImage();
Showimage(shopimagebg, shopimagerup);
Removlist();
Appear();
2024-10-30 03:45:54 +08:00
break;
2024-11-08 16:29:30 +08:00
case 1://1
2024-11-05 07:05:29 +08:00
RemoveImage();
2024-10-30 03:45:54 +08:00
Showimage(Developimagebg, Developimagerup);
2024-11-08 16:29:30 +08:00
Removlist();
Appear();
2024-10-30 03:45:54 +08:00
break;
2024-11-08 16:29:30 +08:00
case 2://0
2024-11-05 07:05:29 +08:00
RemoveImage();
2024-11-08 16:29:30 +08:00
Showimage(Troughimagebg, Troughmagerup);
Removlist();
Appear();
2024-10-30 03:45:54 +08:00
break;
2024-11-08 16:29:30 +08:00
case 3://3
2024-11-05 07:05:29 +08:00
RemoveImage();
2024-10-30 03:45:54 +08:00
Showimage(Heroimagebg, Heroimagerup);
2024-11-08 16:29:30 +08:00
Removlist();
Appear();
2024-10-30 03:45:54 +08:00
break;
2024-11-08 16:29:30 +08:00
case 4://4
2024-11-05 07:05:29 +08:00
RemoveImage();
2024-10-30 03:45:54 +08:00
Showimage(Treeimagebg, Treeimagerup);
2024-11-08 16:29:30 +08:00
Removlist();
Appear();
break;
case 5:
Removlist();
Appear();
2024-10-30 03:45:54 +08:00
break;
default:
break;
}
2024-10-28 22:05:14 +08:00
}
void shopClick()
{
2024-11-05 07:05:29 +08:00
2024-10-30 03:45:54 +08:00
2024-10-30 01:08:16 +08:00
shoppanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack);
StartCoroutine(Magnify(shoppanel));
2024-11-08 16:29:30 +08:00
JumpScene.jumpbool = 0;
//SceneGuodu.instance.SlideInAndLoadScene(JumpScene.shop_scene);
2024-10-28 22:05:14 +08:00
}
void DevelopClick()
{
2024-11-05 07:05:29 +08:00
2024-10-30 03:45:54 +08:00
2024-10-30 01:08:16 +08:00
Developpanel.DOScale(Deflate,0.3f).SetEase(Ease.OutBack);
StartCoroutine(Magnify(Developpanel));
2024-11-08 16:29:30 +08:00
JumpScene.jumpbool = 1;
//SceneGuodu.instance.SlideInAndLoadScene(JumpScene.develop_the_main_interface_slices);
2024-10-28 22:05:14 +08:00
}
void TroughClick()
2024-10-30 01:08:16 +08:00
{
2024-11-05 07:05:29 +08:00
2024-10-30 03:45:54 +08:00
2024-10-30 01:08:16 +08:00
Troughpanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack);
StartCoroutine(Magnify(Troughpanel));
2024-11-08 16:29:30 +08:00
JumpScene.jumpbool = 2;
//SceneGuodu.instance.SlideInAndLoadScene(JumpScene.main_scene);
2024-10-28 22:05:14 +08:00
}
void HeroClick()
2024-10-30 01:08:16 +08:00
{
2024-11-05 07:05:29 +08:00
2024-10-30 03:45:54 +08:00
2024-10-30 01:08:16 +08:00
heropanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack);
StartCoroutine(Magnify(heropanel));
2024-11-08 16:29:30 +08:00
JumpScene.jumpbool = 3;
//SceneGuodu.instance.SlideInAndLoadScene(JumpScene.heroBg);
2024-10-28 22:05:14 +08:00
}
void TreeClick()
2024-10-30 03:45:54 +08:00
{
2024-11-08 16:29:30 +08:00
2024-10-30 03:45:54 +08:00
treepanel.DOScale(Deflate, 0.3f).SetEase(Ease.OutBack);
StartCoroutine(Magnify(treepanel));
2024-11-08 16:29:30 +08:00
JumpScene.jumpbool = 4;
//SceneGuodu.instance.SlideInAndLoadScene(JumpScene.EcoTree);
2024-10-28 22:05:14 +08:00
}
2024-10-30 01:08:16 +08:00
void Showimage(Image im,Image im2)
{
2024-10-30 03:45:54 +08:00
2024-10-30 01:08:16 +08:00
im.sprite = showtextbg;
im2.sprite = showtextup;
}
public void RemoveImage()
{
shopimagebg.sprite = removetextbg;
shopimagerup.sprite = removetextup;
Developimagebg.sprite = removetextbg;
Developimagerup.sprite = removetextup;
Troughimagebg.sprite = removetextbg;
Troughmagerup.sprite = removetextup;
Heroimagebg.sprite = removetextbg;
Heroimagerup.sprite = removetextup;
Treeimagebg.sprite = removetextbg;
Treeimagerup.sprite = removetextup;
2024-10-31 20:40:09 +08:00
2024-10-30 01:08:16 +08:00
}
IEnumerator Magnify(RectTransform allpanel)
{
yield return null;
allpanel.DOScale(Vector3.one, 0.5f).SetEase(Ease.OutBack);
}
2024-11-08 16:29:30 +08:00
private void Removlist()
{
foreach (var i in Scenelist)
{
i.gameObject.SetActive(false);
}
}
2024-10-30 01:08:16 +08:00
2024-11-08 16:29:30 +08:00
private void Appear()
2024-10-31 20:40:09 +08:00
{
2024-11-08 16:29:30 +08:00
switch (JumpScene.jumpbool)
2024-10-31 20:40:09 +08:00
{
case 0:
2024-11-08 16:29:30 +08:00
Scenelist[0].gameObject.SetActive(true);
2024-10-31 20:40:09 +08:00
break;
case 1:
2024-11-08 16:29:30 +08:00
Scenelist[1].gameObject.SetActive(true);
2024-10-31 20:40:09 +08:00
break;
case 2:
2024-11-08 16:29:30 +08:00
Scenelist[2].gameObject.SetActive(true);
2024-10-31 20:40:09 +08:00
break;
case 3:
2024-11-08 16:29:30 +08:00
Scenelist[3].gameObject.SetActive(true);
break;
case 4:
Scenelist[4].gameObject.SetActive(true);
break;
case 5:
Scenelist[5].gameObject.SetActive(true);
2024-10-31 20:40:09 +08:00
break;
}
}
2024-10-30 01:08:16 +08:00
2024-11-08 16:29:30 +08:00
2024-10-28 22:05:14 +08:00
}