暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using TMPro;
  4. using Unity.Collections.LowLevel.Unsafe;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. public class Bgmanager : MonoBehaviour{
  8. [SerializeField] GameObject 背景_pl;
  9. [SerializeField] TextMeshProUGUI 目前層數_tb;
  10. [SerializeField] Sprite[] 一般bg,困難bg,地獄bg,夢魘bg,活動bg;
  11. bool 已切換;
  12. void Start(){
  13. if(Main.Global.關卡難度=="一般"){
  14. 背景_pl.GetComponent<Image>().sprite=一般bg[0];
  15. }else if(Main.Global.關卡難度=="困難"){
  16. 背景_pl.GetComponent<Image>().sprite=困難bg[0];
  17. }else if(Main.Global.關卡難度=="地獄"){
  18. 背景_pl.GetComponent<Image>().sprite=地獄bg[0];
  19. }else{
  20. 背景_pl.GetComponent<Image>().sprite=夢魘bg[0];
  21. }
  22. }
  23. // Update is called once per frame
  24. void Update(){
  25. float 目前層數 = float.Parse(目前層數_tb.text);
  26. if(目前層數 % 50 == 0 ){
  27. if(!已切換){
  28. int 切換號碼 = (int)(目前層數 / 50) % 10;
  29. 已切換=true;
  30. 切換bg(int.Parse(切換號碼.ToString()));
  31. }
  32. }else{
  33. 已切換=false;
  34. }
  35. }
  36. private void 切換bg(int 切換號碼){
  37. if(Main.Global.關卡難度=="一般"){
  38. 背景_pl.GetComponent<Image>().sprite=一般bg[切換號碼];
  39. }else if(Main.Global.關卡難度=="困難"){
  40. 背景_pl.GetComponent<Image>().sprite=困難bg[切換號碼];
  41. }else if(Main.Global.關卡難度=="地獄"){
  42. 背景_pl.GetComponent<Image>().sprite=地獄bg[切換號碼];
  43. }else{
  44. 背景_pl.GetComponent<Image>().sprite=夢魘bg[切換號碼];
  45. }
  46. }
  47. }