Bez popisu
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.

FloorManager.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class FloorManager : MonoBehaviour
  6. {
  7. [SerializeField] GameObject 畫面_pl;
  8. [SerializeField] GameObject[] Floor_一般,Floor_困難,Floor_地獄,Floor_夢魘;
  9. [SerializeField] GameObject[] Item_一般,Item_困難,Item_地獄,Item_夢魘;
  10. int 道具總數 = 7;
  11. public void SpawnFloor(){
  12. float 生成最大 = 畫面_pl.GetComponent<RectTransform>().rect.width - 230f;
  13. GameObject[] 使用方塊;
  14. GameObject[] 使用道具;
  15. if(Main.Global.關卡難度=="一般"){
  16. 使用方塊 = Floor_一般;
  17. 使用道具 = Item_一般;
  18. }else if(Main.Global.關卡難度=="困難"){
  19. 使用方塊 = Floor_困難;
  20. 使用道具 = Item_困難;
  21. }else if(Main.Global.關卡難度=="地獄"){
  22. 使用方塊 = Floor_地獄;
  23. 使用道具 = Item_地獄;
  24. }else{
  25. 使用方塊 = Floor_夢魘;
  26. 使用道具 = Item_夢魘;
  27. }
  28. int r = UnityEngine.Random.Range(0,使用方塊.Length-1);
  29. int r2 = UnityEngine.Random.Range(0,使用道具.Length-1);
  30. GameObject floor = Instantiate(使用方塊[r],transform);
  31. floor.transform.GetComponent<RectTransform>().anchoredPosition = new Vector3(UnityEngine.Random.Range(30f,生成最大),-畫面_pl.GetComponent<RectTransform>().rect.height,0f);
  32. if(r2 < 道具總數){
  33. GameObject item = Instantiate(使用道具[r2],floor.transform);
  34. item.transform.GetComponent<RectTransform>().anchoredPosition = new Vector3(75f,50f,0f);
  35. }
  36. }
  37. public static void 初始平台生成(GameObject 螢幕_pl,GameObject FloorPrefabs2){
  38. float 生成最大 = 螢幕_pl.GetComponent<RectTransform>().rect.width - 230f;
  39. double 生成數量 = Math.Floor(螢幕_pl.GetComponent<RectTransform>().rect.height / 170);
  40. Debug.Log(螢幕_pl.GetComponent<RectTransform>().rect.height-50);
  41. Debug.Log(生成數量);
  42. for (int i=0 ;i<=生成數量-1;i++){
  43. GameObject floor = Instantiate(FloorPrefabs2,螢幕_pl.transform);
  44. floor.transform.GetComponent<RectTransform>().anchoredPosition = new Vector3(UnityEngine.Random.Range(30f,生成最大),-(i*170f),0f);
  45. }
  46. }
  47. }