IEnumerator UIInit() { if (!layoutGroup) { yield break; } while (!Battle.currentBattleGroup) { yield return(null); } while (!Battle.currentBattleGroup.artifactController) { yield return(null); } if (slotPool.Count < Battle.currentBattleGroup.artifactController.artifactList.Count) { // 슬롯 생성 int count = Battle.currentBattleGroup.artifactController.artifactList.Count - slotPool.Count; for (int i = 0; i < count; i++) { UIArtifactSlot artifact = Instantiate(artifactSlotPrefab).GetComponent <UIArtifactSlot>(); artifact.transform.SetParent(layoutGroup.transform, false); slotPool.Add(artifact); } } UIArtifactSelect.Close(); ////UIArtifactSelect.Instance.InfoClose(); // 슬롯에 데이터 세팅 for (int i = 0; i < slotPool.Count; i++) { slotPool[i].gameObject.SetActive(false); } for (int i = 0; i < Battle.currentBattleGroup.artifactController.artifactList.Count; i++) { slotPool[i].gameObject.SetActive(true); slotPool[i].SlotInit(Battle.currentBattleGroup.artifactController.artifactList[i]); } //그리드 사이즈 조절. 컨텐츠 사이즈 필터 못써서 취한 조치 GridLayoutGroup grid = layoutGroup as GridLayoutGroup; if (grid) { int childCount = scrollRect.content.childCount; float y = grid.cellSize.y * childCount + grid.spacing.y * (childCount - 1); scrollRect.content.sizeDelta = new Vector2(scrollRect.content.sizeDelta.x, y); } }
/// <summary> 선택 안 됐을 때 연출 </summary> IEnumerator ShowResult(bool isSelected) { RectTransform t = GetComponent <RectTransform>(); t.localScale = Vector3.one; t.anchoredPosition = Vector2.zero; float resultTime = 1.5f; Animator animator = GetComponent <Animator>(); if (animator) { animator.enabled = true; animator.Rebind(); animator.SetBool("isSelected", isSelected); animator.SetTrigger("select"); } if (isSelected) { //파티클 재생 particleObject.SetActive(true); //ParticleSystem particle = particleObject.GetComponentInChildren<ParticleSystem>(); Battle.currentBattleGroup.artifactController.AddArtifact(artifactBaseData); ////연출 시간 동안 대기 //yield return new WaitForSecondsRealtime(resultTime); ////오브젝트 비활성 //gameObject.SetActive(false); } float threshold = 0f; float alpha = 1f; float startTime = Time.unscaledTime; float elapsedTime = 0f; UIArtifactSlot slot = UIArtifact.slotPool.Find(x => x.artifact.baseData.id == artifactBaseData.id); while (!slot) { yield return(null); } yield return(null); while (UIArtifact.Instance.scrollRect.velocity.magnitude > 0.1f) { yield return(null); } RectTransform slotRectTransform = slot.GetComponent <RectTransform>(); artifactImage.SetClipRect(UIArtifact.Instance.scrollRect.viewport.rect, true); if (isSelected) { float slotHeight = slotRectTransform.sizeDelta.y; float posY = slotRectTransform.anchoredPosition.y; Vector2 a = UIArtifact.Instance.scrollRect.content.anchoredPosition; UIArtifact.Instance.scrollRect.content.anchoredPosition = new Vector2(a.x, -posY - slotHeight * 0.5f); Debug.Log(UIArtifact.Instance.scrollRect.normalizedPosition + ", " + UIArtifact.Instance.scrollRect.content.childCount); UIArtifact.Instance.scrollRect.CalculateLayoutInputVertical(); } float destScale = slot.relicsImage.GetComponent <RectTransform>().sizeDelta.y / GetComponent <RectTransform>().sizeDelta.y; //Vector3 destPos = slot.relicsImage.transform.position; //디졸브 연출+서서히 사라짐 while (elapsedTime < resultTime) { if (isSelected) { Vector3 destPos = slot.relicsImage.transform.position; artifactImage.RecalculateMasking(); t.position = Vector2.Lerp(transform.position, destPos, elapsedTime); Vector3 s = Vector3.Lerp(transform.localScale, Vector3.one * destScale, elapsedTime); t.localScale = s; } if (!isSelected) { float a = Time.unscaledDeltaTime / 0.3f; float thresholdAmount = animDisolve.Evaluate(a); threshold += thresholdAmount; alpha -= Time.unscaledDeltaTime / 0.3f; artifactImage.material.SetFloat("_Threshold", threshold); for (int i = 0; i < canvasRenderers.Length; i++) { canvasRenderers[i].SetAlpha(alpha); } } yield return(null); elapsedTime += Time.unscaledDeltaTime; } t.localScale = Vector3.one; t.anchoredPosition = Vector2.zero; gameObject.SetActive(false); yield break; }
/// <summary> 선택 됐을 때 연출 </summary> IEnumerator ShowResult_Selected() { Animator animator = GetComponent <Animator>(); if (animator) { animator.enabled = false; //animator.Rebind(); //animator.SetBool("isSelected", true); //animator.SetTrigger("select"); } RectTransform t = GetComponent <RectTransform>(); t.localScale = Vector3.one; t.anchoredPosition = Vector2.zero; //추가된 유물 슬롯 UIArtifactSlot slot = UIArtifact.slotPool.Find(x => x.artifact.baseData.id == artifactBaseData.id); while (!slot) { yield return(null); } //한 프레임 기다려줘야 스크롤 갱신됨 yield return(null); //파티클 재생 //particleObject.SetActive(true); //방금 획득한 유물 리스트에 포커스 맞추기 & 유물 슬롯 위치 받아오기 RectTransform slotRectTransform = slot.GetComponent <RectTransform>(); float slotHeight = slotRectTransform.sizeDelta.y; float posY = slotRectTransform.anchoredPosition.y; Vector2 a = UIArtifact.Instance.scrollRect.content.anchoredPosition; UIArtifact.Instance.scrollRect.content.anchoredPosition = new Vector2(a.x, -posY - slotHeight * 0.5f); //t.SetParent(slot.transform); //UIArtifact.Instance.scrollRect.viewport.GetComponent<Mask>(). //artifactImage.SetClipRect(UIArtifact.Instance.scrollRect.viewport.rect, true); Canvas canvas = GetComponentInParent <Canvas>(); //화면 중앙으로 확대되면서 이동 float elapsedTime = 0f; while (elapsedTime < 0.4f) { Vector3 destPos = canvas.GetComponent <RectTransform>().anchoredPosition; t.position = Vector2.Lerp(transform.position, destPos, 5f * Time.unscaledDeltaTime); Vector3 s = Vector3.Lerp(transform.localScale, Vector3.one * 2f, 3f * Time.unscaledDeltaTime); t.localScale = s; yield return(null); elapsedTime += Time.unscaledDeltaTime; } //파티클 재생 //particleObject.SetActive(true); float destScale = slot.relicsImage.GetComponent <RectTransform>().sizeDelta.y / GetComponent <RectTransform>().sizeDelta.y; //Vector3 destPos = slot.relicsImage.transform.position; //해당 유물 슬롯 위치로 날아가는 연출 float resultTime = 1.5f; elapsedTime = 0f; while (elapsedTime < resultTime) { Vector3 destPos = slot.relicsImage.transform.position; t.position = Vector2.Lerp(transform.position, destPos, 8f * Time.unscaledDeltaTime /* elapsedTime*/); Vector3 s = Vector3.Lerp(transform.localScale, Vector3.one * destScale, elapsedTime); t.localScale = s; if (elapsedTime > 0.1f && t.parent != slot.transform) { t.SetParent(slot.transform); artifactImage.RecalculateMasking(); } yield return(null); elapsedTime += Time.unscaledDeltaTime; } t.localScale = Vector3.one; t.anchoredPosition = Vector2.zero; if (coroutineShowResult != null) { coroutineShowResult = null; } gameObject.SetActive(false); yield break; }