| | |
| | | using TowerDefense.Level; |
| | | using UnityEngine.UI; |
| | | using Protobuf; |
| | | using DG.Tweening; |
| | | |
| | | /** |
| | | * 无尽模式结算界面列表脚本 |
| | |
| | | private string iconPath = "UI/Props/"; |
| | | |
| | | private string bgPath = "UI/Props/Di/"; |
| | | private float slowTime = 0.3f;//物品挨个出现频率 |
| | | |
| | | //private float parentHeight;//父物体高度 |
| | | GridLayoutGroup myGroup; |
| | | |
| | | RectTransform myRect, gridRect; |
| | | |
| | | /// <summary> |
| | | /// Awake is called when the script instance is being loaded. |
| | | /// </summary> |
| | | void Awake() |
| | | { |
| | | //parentHeight = transform.parent.GetComponent<RectTransform>().sizeDelta.y; |
| | | myGroup = Grid.GetComponent<GridLayoutGroup>(); |
| | | gridRect = Grid.GetComponent<RectTransform>(); |
| | | myRect = GetComponent<RectTransform>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新道具列表 |
| | | /// </summary> |
| | | public void RefreshList() |
| | | { |
| | | Invoke("StartLater", slowTime); |
| | | |
| | | // if (Application.platform == RuntimePlatform.WindowsEditor) |
| | | // { |
| | | // Debug.Log(gameObject.activeSelf); |
| | | // //UnityEditor.EditorApplication.isPaused = true; |
| | | // } |
| | | |
| | | return; |
| | | List<EndlessDrop> list = EndlessDropManager.instance.GetAllObtainedDrop(); |
| | | |
| | | for (int i = 0; i < list.Count; ++i) |
| | |
| | | } |
| | | } |
| | | |
| | | private void StartLater() |
| | | { |
| | | StartCoroutine(ShowSlow()); |
| | | } |
| | | |
| | | IEnumerator ShowSlow() |
| | | { |
| | | List<EndlessDrop> list = EndlessDropManager.instance.GetAllObtainedDrop(); |
| | | |
| | | for (int i = 0; i < list.Count; ++i) |
| | | { |
| | | if (list[i].Reward.type == CURRENCY.Gold) |
| | | { |
| | | AddItem($"{(int)list[i].Reward.type}"); |
| | | yield return new WaitForSeconds(slowTime); |
| | | } |
| | | else |
| | | { |
| | | for (int j = 0; j < list[i].Reward.count; ++j) |
| | | { |
| | | AddItem($"{(int)list[i].Reward.type}_{list[i].Reward.id}"); |
| | | yield return new WaitForSeconds(slowTime); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void AddItem(string resId) |
| | | { |
| | | GameObject item = Instantiate(ItemPrefab); |
| | |
| | | propIcon.SetIcon(iconSp); |
| | | propIcon.SetBg(bgSp); |
| | | item.transform.SetParent(Grid.transform, false); |
| | | |
| | | if (gridRect.sizeDelta.y > myRect.sizeDelta.y && Grid.transform.childCount % myGroup.constraintCount == 1) |
| | | { |
| | | gridRect.DOAnchorPosY(gridRect.sizeDelta.y - myRect.sizeDelta.y + (item.transform as RectTransform).sizeDelta.y, 0.2f); |
| | | } |
| | | } |
| | | } |
| | | } |