1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections;
- using System.Collections.Generic;
- using TMPro;
- using Unity.Collections.LowLevel.Unsafe;
- using UnityEngine;
- using UnityEngine.UI;
-
- public class Bgmanager : MonoBehaviour{
- [SerializeField] GameObject 背景_pl;
- [SerializeField] TextMeshProUGUI 目前層數_tb;
- [SerializeField] Sprite[] 一般bg,困難bg,地獄bg,夢魘bg,活動bg;
- bool 已切換;
- void Start(){
- if(Main.Global.關卡難度=="一般"){
- 背景_pl.GetComponent<Image>().sprite=一般bg[0];
- }else if(Main.Global.關卡難度=="困難"){
- 背景_pl.GetComponent<Image>().sprite=困難bg[0];
- }else if(Main.Global.關卡難度=="地獄"){
- 背景_pl.GetComponent<Image>().sprite=地獄bg[0];
- }else{
- 背景_pl.GetComponent<Image>().sprite=夢魘bg[0];
- }
- }
-
- // Update is called once per frame
- void Update(){
- float 目前層數 = float.Parse(目前層數_tb.text);
- if(目前層數 % 50 == 0 ){
- if(!已切換){
- int 切換號碼 = (int)(目前層數 / 50) % 10;
- 已切換=true;
- 切換bg(int.Parse(切換號碼.ToString()));
- }
- }else{
- 已切換=false;
- }
- }
- private void 切換bg(int 切換號碼){
- if(Main.Global.關卡難度=="一般"){
- 背景_pl.GetComponent<Image>().sprite=一般bg[切換號碼];
- }else if(Main.Global.關卡難度=="困難"){
- 背景_pl.GetComponent<Image>().sprite=困難bg[切換號碼];
- }else if(Main.Global.關卡難度=="地獄"){
- 背景_pl.GetComponent<Image>().sprite=地獄bg[切換號碼];
- }else{
- 背景_pl.GetComponent<Image>().sprite=夢魘bg[切換號碼];
- }
-
- }
- }
|