public HeroSlotClickableBattle(UIHeroSlotContainer _heroSlotContainer, HeroData _heroData) { heroSlotContainer = _heroSlotContainer; heroData = _heroData; heroSlotContainer.isSelectedToBattle = false; }
void DeployHeroCountChack() { int count = deployHeroIDList.Count; if (count >= 3) { for (int i = 0; i < UIHeroInventory.heroSlotContainerList.Count; i++) { UIHeroSlotContainer slot = UIHeroInventory.heroSlotContainerList[i]; HeroData heroData = slot.heroData; if (string.IsNullOrEmpty(heroData.placeID) || (heroData.placeID != currentPlaceID || slot.isSelectedToTerritory == false)) { slot.isUnableToSelect = true; } else { slot.isUnableToSelect = false; } } } else { for (int i = 0; i < UIHeroInventory.heroSlotContainerList.Count; i++) { UIHeroInventory.heroSlotContainerList[i].isUnableToSelect = false; } } }
public void Close() { for (int i = 0; i < UIHeroInventory.heroSlotContainerList.Count; i++) { if (UIHeroInventory.heroSlotContainerList[i].gameObject.activeSelf == false) { UIHeroInventory.heroSlotContainerList[i].gameObject.SetActive(true); } } if (!string.IsNullOrEmpty(selectedTrainingHeroID)) { UIHeroSlotContainer s = UIHeroInventory.heroSlotContainerList.Find(x => x.heroInvenID == selectedTrainingHeroID); if (s) { s.isSelectedToHero = false; } } SceneLobby.Instance.OnChangedMenu -= OnChangedMenu; UITrainingStatSlot.onClickStatSelectButton -= ChangeTrainingStat; SceneManager.UnloadSceneAsync("HeroTraining"); }
int SortDelegate(UIHeroSlotContainer a, UIHeroSlotContainer b) { HeroData heroDataA = HeroManager.heroDataDic[a.heroInvenID]; HeroData heroDataB = HeroManager.heroDataDic[b.heroInvenID]; //1차 정렬. 무조건 전투 참여중인애가 제일 위로 bool isUsingA = !string.IsNullOrEmpty(heroDataA.placeID) || !string.IsNullOrEmpty(heroDataA.battleGroupID); bool isUsingB = !string.IsNullOrEmpty(heroDataB.placeID) || !string.IsNullOrEmpty(heroDataB.battleGroupID); if (isUsingA && !isUsingB) { return(-1); } else if (!isUsingA && isUsingB) { return(1); } switch (heroSortType) { case HeroSortingType.Name: return(heroDataA.heroName.CompareTo(heroDataB.heroName)); default: return(0); } }
public void AddSlot(string key) { GameObject go = Instantiate(heroSlotContainerPrefab) as GameObject; HeroData heroData = HeroManager.heroDataDic[key]; string heroID = heroData.heroID; if (heroID.EndsWith("_Territory")) { go.transform.SetParent(territoryheroInventoryScrollViewContent.transform, false); } else if (heroID.EndsWith("_Hero")) { go.transform.SetParent(heroInventoryScrollViewContent.transform, false); } go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; UIHeroSlotContainer heroSlot = go.GetComponent <UIHeroSlotContainer>(); heroSlot.heroInvenID = heroData.id; heroSlot.InitContainer(); heroSlotContainerList.Add(heroSlot); SizeControl(); }
UIHeroSlotContainer InitSameHeroSlot(HeroData _heroData) { UIHeroSlotContainer heroSlot = new UIHeroSlotContainer(); string heroID = _heroData.heroID; if (heroID.EndsWith("_Hero")) { GameObject go = Instantiate(heroSlotContainerPrefab) as GameObject; go.transform.SetParent(battleScrollViewContent.transform, false); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; heroSlot = go.GetComponent <UIHeroSlotContainer>(); heroSlot.heroInvenID = _heroData.id; heroSlot.state = HeroSlotState.LimitBreak; } else if (heroID.EndsWith("_Territory")) { GameObject go = Instantiate(heroSlotContainerPrefab) as GameObject; go.transform.SetParent(territoryScrollViewContent.transform, false); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; heroSlot = go.GetComponent <UIHeroSlotContainer>(); heroSlot.heroInvenID = _heroData.id; heroSlot.state = HeroSlotState.LimitBreak; } return(heroSlot); }
public void ShowSelectPanel() { if (!string.IsNullOrEmpty(selectedTrainingHeroID)) { UIHeroSlotContainer s = UIHeroInventory.heroSlotContainerList.Find(x => x.heroInvenID == selectedTrainingHeroID); if (s) { s.isSelectedToHero = false; } } if (heroTrainingSlotList[slotNumber].heroTrainingData == null) { selectedTrainingHeroID = string.Empty; } //MAX 수련인 애들은 안보이게 할까? for (int i = 0; i < UIHeroInventory.heroSlotContainerList.Count; i++) { string id = UIHeroInventory.heroSlotContainerList[i].heroInvenID; int num = 0; for (int j = 0; j < HeroManager.heroDataDic[id].trainingDataList.Count; j++) { num += HeroManager.heroDataDic[id].trainingDataList[j].training; } if (num >= HeroManager.heroDataDic[id].trainingMax) { UIHeroInventory.heroSlotContainerList[i].gameObject.SetActive(false); } } //정리되면 켜주고 UIHeroInventory.Instance.ShowHeroInvenForTraining(); //인벤토리 사이즈 조절 RectTransform t = UIHeroInventory.Instance.objListRoot.GetComponent <RectTransform>(); t.sizeDelta = new Vector2(t.sizeDelta.x, -Instance.rectTransformScreen.sizeDelta.y - t.anchoredPosition.y); //선택 영웅에 대한 표현을 하고 Show(); //패널을 켜주자 selectHeroPanel.SetActive(true); }
public void RemoveSlot(string key) { UIHeroSlotContainer container = heroSlotContainerList.Find(x => x.heroInvenID == key); UIHeroSlot slot = container.GetComponentInChildren <UIHeroSlot>(); container.isDestroy = true; if (slot != null) { slot.transform.SetParent(heroSlotStackArea.transform); } heroSlotContainerList.RemoveAt(heroSlotContainerList.FindIndex(x => x.heroInvenID == key)); Destroy(container.gameObject); SizeControl(); }
int SortDelegateGradeDesc(UIHeroSlotContainer a, UIHeroSlotContainer b) { HeroData heroDataA = HeroManager.heroDataDic[a.heroInvenID]; HeroData heroDataB = HeroManager.heroDataDic[b.heroInvenID]; if (heroDataA.isChecked && !heroDataB.isChecked) { return(1); } else if (!heroDataA.isChecked && heroDataB.isChecked) { return(-1); } int result; int gradeA = heroDataA.heroGrade; int gradeB = heroDataB.heroGrade; result = gradeB.CompareTo(gradeA); if (result == 0) { int enhanceA, enhanceB; enhanceA = (heroDataA.rebirth * 100) + heroDataA.enhance; enhanceB = (heroDataB.rebirth * 100) + heroDataB.enhance; if (enhanceA > enhanceB) { return(-1); } else if (enhanceA < enhanceB) { return(1); } } if (result == 0) { result = heroDataA.heroName.CompareTo(heroDataB.heroName); } return(result); }
int SortDelegatAcquiredTimeDesc(UIHeroSlotContainer a, UIHeroSlotContainer b) { HeroData heroDataA = HeroManager.heroDataDic[a.heroInvenID]; HeroData heroDataB = HeroManager.heroDataDic[b.heroInvenID]; if (heroDataA.isChecked && !heroDataB.isChecked) { return(1); } else if (!heroDataA.isChecked && heroDataB.isChecked) { return(-1); } int idA, idB; int.TryParse(heroDataA.id, out idA); int.TryParse(heroDataB.id, out idB); return(idB.CompareTo(idA)); }
public UIHeroSlotContainer GetHeroContainerFromPool(HeroData heroData) { UIHeroSlotContainer heroSlot = null; for (int i = 0; i < heroContainerPool.Count; i++) { if (heroContainerPool[i].transform.parent == slotStackArea.transform) { heroSlot = heroContainerPool[i]; break; } } if (!heroSlot) { heroSlot = InitSameHeroSlot(heroData); GameObject go = Instantiate(heroSlotPrefab) as GameObject; UIHeroSlot slot = go.GetComponent <UIHeroSlot>(); heroSlot.SetHeroSlot(slot); heroContainerPool.Add(heroSlot); } else { heroSlot.heroInvenID = heroData.id; heroSlot.ResetSlotData(); string heroID = heroData.heroID; if (heroID.EndsWith("_Hero")) { heroSlot.transform.SetParent(battleScrollViewContent.transform, false); } else { heroSlot.transform.SetParent(territoryScrollViewContent.transform, false); } } return(heroSlot); }
IEnumerator Start() { isInitialized = false; canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = Camera.main; //popupCanvas.renderMode = RenderMode.ScreenSpaceCamera; //popupCanvas.worldCamera = Camera.main; //리스트 사이즈 저장해두기. 다른 메뉴 같은데서 크기 막 변경해서 써먹거나 할 경우 초기화를 위해 originalListSize = objListRoot.GetComponent <RectTransform>().sizeDelta; tabType = InventoryTabType.Battle; //state = HeroInventorState.Show; while (!HeroManager.isInitialized) { yield return(null); } int count = 0; if (HeroManager.heroDataDic == null || HeroManager.heroDataDic.Count == 0) { notHeroText.gameObject.SetActive(true); territoryNotHeroText.gameObject.SetActive(true); } else { count = HeroManager.heroDataDic.Count; List <HeroData> heroList = HeroManager.heroDataDic.Values.ToList(); for (int i = 0; i < heroList.Count; i++) { string heroID = heroList[i].heroID; if (heroID.EndsWith("_Hero")) { GameObject go = Instantiate(heroSlotContainerPrefab) as GameObject; go.transform.SetParent(heroInventoryScrollViewContent.transform, false); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; UIHeroSlotContainer heroSlot = go.GetComponent <UIHeroSlotContainer>(); heroSlot.heroInvenID = heroList[i].id; heroSlotContainerList.Add(heroSlot); } else if (heroID.EndsWith("_Territory")) { GameObject go = Instantiate(heroSlotContainerPrefab) as GameObject; go.transform.SetParent(territoryheroInventoryScrollViewContent.transform, false); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; UIHeroSlotContainer heroSlot = go.GetComponent <UIHeroSlotContainer>(); heroSlot.heroInvenID = heroList[i].id; heroSlotContainerList.Add(heroSlot); } continue; } } HeroManager.heroDataDic.onAdd += OnAddHero; HeroManager.heroDataDic.onRemove += OnRemoveHero; HeroManager.onHeroManagerInitCallback += OnHeroDataSetEnd; SizeControl(); Close(); isInitialized = true; }
/// <summary> 한계돌파할 같은 영웅 불러오기 </summary> public void ShowSameHeroList(string heroID, string id) { UIHeroInventory.Instance.isLimitBreak = true; if (before != null) { Destroy(before); } //대상 슬롯 생성 초기화 GameObject go = Instantiate(heroSlotPrefab, limitBreakPanel.transform); before = go; go.GetComponent <UIHeroSlot>().SlotDataInit(limitBreakHero.id, HeroSlotState.Default); go.GetComponent <UIHeroSlot>().InitImage(); textLimitBreak.text = "한계돌파 " + limitBreakHero.limitBreak + "단계 → " + limitBreakHero.limitBreak + "단계"; //훈련포인트 표현 초기화 int count = 0; for (int i = 0; i < limitBreakHero.trainingDataList.Count; i++) { count += limitBreakHero.trainingDataList[i].training; } beforePoint = limitBreakHero.limitBreak + 1 - count; textBeforeTrainingPoint.text = beforePoint.ToString(); textBeforeTrainingPoint.color = noneColor; textAfterTrainingPoint.text = beforePoint.ToString(); textAfterTrainingPoint.color = noneColor; //무한의 정수 관련 UI 초기화 textUnlimitedJewelCount.text = MoneyManager.GetMoney(MoneyType.limitBreakTicket).value.ToString(); unlimitedJeweluse = 0; textUnlimitedJewelUse.text = unlimitedJeweluse.ToString(); List <HeroData> list = HeroManager.heroDataList.FindAll(x => x.heroID == heroID); int heroNum = 0; //같은 영웅만 컨테이너 생성 or 풀링 for (int i = 0; i < list.Count; i++) { UIHeroSlotContainer heroContainer = null; //자기 자신은 제외 if (list[i].id == id) { continue; } HeroData b = HeroManager.heroDataDic[list[i].id]; //내정영웅이면 if (b.heroType == HeroData.HeroType.NonBattle) { if (!string.IsNullOrEmpty(list[i].placeID)) { //클릭은 안되지만 생성하여 표시 heroContainer = GetHeroContainerFromPool(list[i]); heroContainer.state = HeroSlotState.Default; heroContainer.GetComponentInChildren <UIHeroSlot>().UpdateSlotContents(); containerList.Add(heroContainer); heroNum += 1; continue; } } else//전투영웅이면 { //전투중인지 확인 if (!string.IsNullOrEmpty(b.battleGroupID)) { //전투중이면 클릭은 안되지만 생성하여 전투표시 heroContainer = GetHeroContainerFromPool(list[i]); heroContainer.state = HeroSlotState.Default; heroContainer.GetComponentInChildren <UIHeroSlot>().UpdateSlotContents(); containerList.Add(heroContainer); heroNum += 1; continue; } } //위 조건에 해당하지 않으면 한계돌파용 슬롯으로 생성 heroContainer = GetHeroContainerFromPool(list[i]); heroContainer.state = HeroSlotState.LimitBreak; containerList.Add(heroContainer); heroNum += 1; } if (heroNum > 0) { notHeroLimitBreakText.gameObject.SetActive(false); } else { notHeroLimitBreakText.gameObject.SetActive(true); } SortHeroList(HeroSortingType.Name); limitBreakCanvas.SetActive(true); //표현 패널 켜기 limitBreakPanel.SetActive(true); //한계돌파 버튼 키고 인터렉티브 끄기 buttonLimitBreak.gameObject.SetActive(true); buttonLimitBreak.interactable = false; if (limitBreakHero.heroType == HeroData.HeroType.Battle) { scrollBattleHero.gameObject.SetActive(true); scrollterritoryHero.gameObject.SetActive(false); } else { scrollBattleHero.gameObject.SetActive(false); scrollterritoryHero.gameObject.SetActive(true); } SizeControl(heroNum); }
public HeroSlotClickableTerritory(UIHeroSlotContainer _heroSlotContainer) { heroSlotContainer = _heroSlotContainer; id = heroSlotContainer.heroInvenID; }
/// <summary> 정렬을 위해 데이터 비교하기 위한 함수 </summary> int SortDelegateAuto(UIHeroSlotContainer a, UIHeroSlotContainer b) { HeroData heroDataA = HeroManager.heroDataDic[a.heroInvenID]; HeroData heroDataB = HeroManager.heroDataDic[b.heroInvenID]; if (currentState == HeroSlotState.Training) { if (heroDataA.isTraining && !heroDataB.isTraining) { return(-1); } else if (!heroDataA.isTraining && heroDataB.isTraining) { return(1); } } // 1차 정렬 새로 얻은 영웅을 위쪽으로 정렬 //######################################################################## if (heroDataA.isChecked && !heroDataB.isChecked) { return(1); } else if (!heroDataA.isChecked && heroDataB.isChecked) { return(-1); } //2차 정렬. 무조건 전투 참여중인애가 제일 위로 //######################################################################## bool isUsingA = !string.IsNullOrEmpty(heroDataA.placeID) || !string.IsNullOrEmpty(heroDataA.battleGroupID); bool isUsingB = !string.IsNullOrEmpty(heroDataB.placeID) || !string.IsNullOrEmpty(heroDataB.battleGroupID); if (currentState == HeroSlotState.Territory && !string.IsNullOrEmpty(placeID)) { if (heroDataA == null) { if (placeID == heroDataA.placeID && placeID != heroDataB.placeID) { return(-1); } else if (placeID != heroDataA.placeID && placeID == heroDataB.placeID) { return(1); } } } if (isUsingA && !isUsingB) { return(-1); } else if (!isUsingA && isUsingB) { return(1); } //3차 강화 높은 순 정렬 //######################################################################### int enhanceA, enhanceB; enhanceA = (heroDataA.rebirth * 100) + heroDataA.enhance; enhanceB = (heroDataB.rebirth * 100) + heroDataB.enhance; if (enhanceA > enhanceB) { return(-1); } else if (enhanceA < enhanceB) { return(1); } //4차 정렬 원하는 기준에 따른 정렬 //########################################################################## int result; int gradeA = heroDataA.heroGrade; int gradeB = heroDataB.heroGrade; result = gradeB.CompareTo(gradeA); if (result == 0) { result = heroDataA.heroName.CompareTo(heroDataB.heroName); } return(result); }
public HeroSlotClickableTraining(UIHeroSlotContainer _heroSlotContainer) { heroSlotContainer = _heroSlotContainer; }
public HeroSlotClickableLimitBreak(string _id, UIHeroSlotContainer _heroSlotContainer) { id = _id; heroSlotContainer = _heroSlotContainer; }
IEnumerator UpdatePreviewSlotsA() { //LoadingManager.Show(); for (int i = 0; i < UIHeroInventory.heroSlotContainerList.Count; i++) { UIHeroSlotContainer s = UIHeroInventory.heroSlotContainerList[i]; bool isChack = false; for (int j = 0; j < selectedHeroDataList.Count; j++) { if (selectedHeroDataList[j].id == s.heroInvenID) { s.isSelectedToBattle = true; isChack = true; break; } } if (isChack == false) { s.isSelectedToBattle = false; } s.isUnableToSelect = selectedHeroDataList.Count >= 8; } //for (int i = 0; i < heroSelectSlotList.Count; i++) //{ // UIHeroSelectSlot s = heroSelectSlotList[i]; // bool isChack = false; // HeroData heroData = null; // for (int j = 0; j < selectedHeroDataList.Count; j++) // { // heroData = selectedHeroDataList[j]; // if (selectedHeroDataList[j].id == s.id) // { // isChack = true; // break; // } // else if(string.IsNullOrEmpty(s.id)) // { // GameObject go = null; // yield return (CharacterEmptyPool.Instance.GetHero(heroData.heroID, x => go = x)); // heroSelectSlotList[i].AssignHero(heroData.id, go); // } // } // if (isChack == false) // { // s.Dispose(); // } //} //for (int i = 0; i < heroSelectSlotList.Count; i++) //{ // if (i >= selectedHeroDataList.Count) // { // heroSelectSlotList[i].Dispose(); // break; // } // HeroData heroData = selectedHeroDataList[i]; // if (heroSelectSlotList[i].id == heroData.id) // continue; // if (heroSelectSlotList[i].heroObj != null) // heroSelectSlotList[i].Dispose(); // GameObject go = null; // yield return (CharacterEmptyPool.Instance.GetHero(heroData.heroID, x => go = x)); // heroSelectSlotList[i].AssignHero(heroData.id, go); //} //coroutineUpdatePreviewSlots = null; //for (int i = 0; i < heroSelectSlotList.Count; i++) //{ // for (int j = 0; j < UIHeroInventory.heroSlotContainerList.Count; j++) // { // UIHeroSlotContainer s = UIHeroInventory.heroSlotContainerList[j]; // if (s.heroInvenID == heroSelectSlotList[i].id) // { // if (selectedHeroDataList.Find(x => x.id == s.heroInvenID) == null) // s.isSelectedToBattle = false; // } // } //} for (int i = 0; i < heroSelectSlotList.Count; i++) { if (i >= selectedHeroDataList.Count) { heroSelectSlotList[i].Dispose(); break; } HeroData heroData = selectedHeroDataList[i]; if (heroSelectSlotList[i].id == heroData.id) { continue; } if (heroSelectSlotList[i].heroObj != null) { heroSelectSlotList[i].Dispose(); } GameObject go = null; yield return(StartCoroutine(CharacterEmptyPool.Instance.GetHero(heroData.heroID, x => go = x))); heroSelectSlotList[i].AssignHero(heroData.id, go); } for (int i = 0; i < heroSelectSlotList.Count; i++) { for (int j = 0; j < UIHeroInventory.heroSlotContainerList.Count; j++) { UIHeroSlotContainer s = UIHeroInventory.heroSlotContainerList[j]; if (s != null && s.heroInvenID == heroSelectSlotList[i].id) { s.isSelectedToBattle = true; } } } ////LoadingManager.Close(); coroutineUpdatePreviewSlots = null; }
public HeroSlotClickableInventory(HeroData _heroData, UIHeroSlotContainer _heroSlotContainer) { heroData = _heroData; OnOpenHeroInfo += _heroSlotContainer.ShowHeroInfo; }