using UnityEngine; using System.Collections; using System.Collections.Generic; public class SweepFinishRewPanelCtr : MonoBehaviour { public static SweepFinishRewPanelCtr Instance; private void Awake() { Instance = this; } private void OnDestroy() { Instance = null; } public Transform rewItemPrefabParent; public GameObject rewitemPrefab; public void InitPanel(CopySceneSweepReward packet) { CreateRew(packet); } public void ClearAllRewPrefab() { for(int index = 0; index < rewPrefabLit.Count; index++) { GameObject.Destroy(rewPrefabLit[index].gameObject); } rewPrefabLit.Clear(); } private List rewPrefabLit = new List(); public void CreateRew(CopySceneSweepReward packet) { ClearAllRewPrefab(); for(int index = 0; index < packet.SweepType.Count; index++) { if(packet.SweepType[index] == 1) //物品,策划固定的是物品,后期奖励有别的话加枚举 { GameObject item = GameObject.Instantiate(rewitemPrefab); item.transform.SetParent(rewItemPrefabParent); item.transform.localPosition = Vector3.zero; item.transform.localScale = Vector3.one; item.transform.localRotation = Quaternion.Euler(Vector3.zero); item.GetComponent().InitItem(packet.SweepItemId[index], packet.SweepCount[index]); rewPrefabLit.Add(item); } } RefreshCopyPanel(); } public void RefreshCopyPanel() { if(AdvanceCopySceneRootCtr.Instance) { AdvanceCopySceneRootCtr.Instance.AskForInfo(); } if(MainMissionCopySceneRootCtr.Instance) { MainMissionCopySceneRootCtr.Instance.AskForInfo(); } } public void OnOkBtnClick() { UIManager.CloseUI(UIInfo.SweepFinishRewPanel); } }