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> public void AddArtifact(ArtifactBaseData data, bool forceSave = true) { Artifact artifact = null; if (artifactList == null) { return; } bool isAdd = false; if (artifactList.Count <= 0) { isAdd = true; } else { isAdd = true; for (int i = 0; i < artifactList.Count; i++) { if (artifactList[i].baseData.id == data.id) { if (artifact != null) { continue; } artifact = artifactList[i]; isAdd = false; } } } //아티펙트 포인트 감소 artifactPoint -= cost; //목록에 추가 if (isAdd) { artifact = new Artifact(data); artifactList.Add(artifact); } artifact.stack++; if (artifact.baseData.type == "hero") { for (int i = 0; i < battleGroup.redTeamList.Count; i++) { battleGroup.redTeamList[i].buffController.AttachBuff(battleGroup.redTeamList[i], artifact.baseData.buffID); } } //유물 선택지 리스트 초기화 showArtifactIDList.Clear(); //유물 선택창 닫기 UIArtifactSelect.Close(); if (onChangedArtifactList != null) { onChangedArtifactList(battleGroup); } //유물 선택 후 강제 저장 함 if (forceSave) { Battle.SaveArtifactInfo(battleGroup); } }