using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class FloorManager : MonoBehaviour { [SerializeField] GameObject 畫面_pl; [SerializeField] GameObject[] Floor_一般,Floor_困難,Floor_地獄,Floor_夢魘; [SerializeField] GameObject[] Item_一般,Item_困難,Item_地獄,Item_夢魘; int 道具總數 = 7; public void SpawnFloor(){ float 生成最大 = 畫面_pl.GetComponent().rect.width - 230f; GameObject[] 使用方塊; GameObject[] 使用道具; if(Main.Global.關卡難度=="一般"){ 使用方塊 = Floor_一般; 使用道具 = Item_一般; }else if(Main.Global.關卡難度=="困難"){ 使用方塊 = Floor_困難; 使用道具 = Item_困難; }else if(Main.Global.關卡難度=="地獄"){ 使用方塊 = Floor_地獄; 使用道具 = Item_地獄; }else{ 使用方塊 = Floor_夢魘; 使用道具 = Item_夢魘; } int r = UnityEngine.Random.Range(0,使用方塊.Length-1); int r2 = UnityEngine.Random.Range(0,使用道具.Length-1); GameObject floor = Instantiate(使用方塊[r],transform); floor.transform.GetComponent().anchoredPosition = new Vector3(UnityEngine.Random.Range(30f,生成最大),-畫面_pl.GetComponent().rect.height,0f); if(r2 < 道具總數){ GameObject item = Instantiate(使用道具[r2],floor.transform); item.transform.GetComponent().anchoredPosition = new Vector3(75f,50f,0f); } } public static void 初始平台生成(GameObject 螢幕_pl,GameObject FloorPrefabs2){ float 生成最大 = 螢幕_pl.GetComponent().rect.width - 230f; double 生成數量 = Math.Floor(螢幕_pl.GetComponent().rect.height / 170); Debug.Log(螢幕_pl.GetComponent().rect.height-50); Debug.Log(生成數量); for (int i=0 ;i<=生成數量-1;i++){ GameObject floor = Instantiate(FloorPrefabs2,螢幕_pl.transform); floor.transform.GetComponent().anchoredPosition = new Vector3(UnityEngine.Random.Range(30f,生成最大),-(i*170f),0f); } } }