public void Start() { if (this.panelItemPrefab == null) { Debug.LogError("Panel item prefab is null. Please check."); } //Panel Items for (int i = 0; i < AttributePanelUI.MAX_NUMBER_OF_LEVELS; i++) { //Panel items GameObject obj = MonoBehaviour.Instantiate(this.panelItemPrefab) as GameObject; RectTransform rectTrans = obj.GetComponent <RectTransform>(); obj.transform.SetParent(this.transform); if (rectTrans != null) { rectTrans.localScale = Vector3.one; } PanelItem item = obj.GetComponent <PanelItem>(); if (item != null) { LevelRate health = this.allAttributes[0][i]; item.levelText.text = "Level " + health.level.ToString(); item.rateText.text = health.rate.ToString(); item.isIncreasingText.text = "N/A"; this.allAttributes[0][i] = health; } } }
public void Awake() { this.allAttributes = new List <List <LevelRate> >(); foreach (Category cat in Category.Values) { List <LevelRate> tempList = new List <LevelRate>(); for (int j = 0; j < AttributePanelUI.MAX_NUMBER_OF_LEVELS; j++) { LevelRate rate = new LevelRate(cat, j + 1, 3f); if (j == 0) { switch (cat.value) { default: //Everything else rate.rate = 1f; break; case 0: //Health break; case 2: //Attack Cooldown rate.rate = 1.2f; break; } } else { LevelRate previous = tempList[j - 1]; switch (cat.value) { case 0: //Health rate.rate = previous.rate * 2f; break; case 1: //Attack rate.rate = previous.rate * 1.8f; break; case 2: //Attack cooldown rate.rate = previous.rate; break; case 3: //Speed rate.rate = previous.rate * 1.2f; break; case 4: //Split rate.rate = previous.rate; break; case 5: //Merge rate.rate = previous.rate * 2f; break; } } tempList.Add(rate); } this.allAttributes.Add(tempList); } }
public void RefreshAttributes(UnitAttributes unitAttributes) { foreach (Category cat in this.categoryContentObject.items) { List <LevelRate> tempList = this.levelingRatesObject.allAttributes[cat.value]; for (int i = 0; i < tempList.Count; i++) { LevelRate rate = tempList[i]; if (!this.enablePlayerCustomEquations) { rate.isIncreasing = 0; } switch (cat.value) { default: break; case 0: rate.rate = unitAttributes.healthPrefabList[i]; break; case 1: rate.rate = unitAttributes.attackPrefabList[i]; break; case 2: rate.rate = unitAttributes.attackCooldownPrefabList[i]; break; case 3: rate.rate = unitAttributes.speedPrefabList[i]; break; case 4: if (i == 0) { rate.rate = unitAttributes.splitPrefabFactor; } else { rate.rate = 0f; } break; case 5: rate.rate = unitAttributes.mergePrefabList[i]; break; } tempList[i] = rate; } this.levelingRatesObject.allAttributes[cat.value] = tempList; } this.levelingRatesObject.UpdateAllPanelItems(this.categoryContentObject.selectedToggle); }
public void Awake() { this.allAttributes = new List<List<LevelRate>>(); foreach (Category cat in Category.Values) { List<LevelRate> tempList = new List<LevelRate>(); for (int j = 0; j < AttributePanelUI.MAX_NUMBER_OF_LEVELS; j++) { LevelRate rate = new LevelRate(cat, j + 1, 3f); if (j == 0) { switch (cat.value) { default: //Everything else rate.rate = 1f; break; case 0: //Health break; case 2: //Attack Cooldown rate.rate = 1.2f; break; } } else { LevelRate previous = tempList[j - 1]; switch (cat.value) { case 0: //Health rate.rate = previous.rate * 2f; break; case 1: //Attack rate.rate = previous.rate * 1.8f; break; case 2: //Attack cooldown rate.rate = previous.rate; break; case 3: //Speed rate.rate = previous.rate * 1.2f; break; case 4: //Split rate.rate = previous.rate; break; case 5: //Merge rate.rate = previous.rate * 2f; break; } } tempList.Add(rate); } this.allAttributes.Add(tempList); } }
public void UpdateAllPanelItems(string selectedToggle) { foreach (Category cat in Category.Values) { if (cat.name.Equals(selectedToggle)) { List <LevelRate> tempList = this.allAttributes[cat.value]; if (tempList != null) { for (int i = 0; i < tempList.Count; i++) { //Panel items Transform child = this.transform.GetChild(i); PanelItem item = child.GetComponent <PanelItem>(); if (item != null) { LevelRate levelRate = tempList[i]; item.levelText.text = "Level " + levelRate.level.ToString(); item.rateText.text = levelRate.rate.ToString(); if (levelRate.isIncreasing > 0) { item.isIncreasingText.text = "++"; } else if (levelRate.isIncreasing == 0) { item.isIncreasingText.text = "=="; } else if (levelRate.isIncreasing < 0) { item.isIncreasingText.text = "--"; } else { item.isIncreasingText.text = "N/A"; } } } Debug.Log("Updated all panel items"); } break; } } }
public void aiRefreshAttributes(AIAttributeManager attributeManager) { foreach (Category cat in this.aiCategoryContentObject.items) { if (cat.name.Equals(this.aiCategoryContentObject.selectedToggle)) { List <LevelRate> tempRate = this.aiLevelingRatesObject.allAttributes[cat.value]; for (int i = 0; i < Attributes.MAX_NUM_OF_LEVELS; i++) { TierUpgrade tier = attributeManager.tiers[i]; LevelRate rate = tempRate[i]; if (cat.value == Category.Health.value) { rate.rate = tier.health; } else if (cat.value == Category.Attack.value) { rate.rate = tier.attack; } else if (cat.value == Category.AttackCooldown.value) { rate.rate = tier.attackCooldown; } else if (cat.value == Category.Speed.value) { rate.rate = tier.speed; } else if (cat.value == Category.Split.value) { rate.rate = tier.split; } else if (cat.value == Category.Merge.value) { rate.rate = tier.merge; } tempRate[i] = rate; } this.aiLevelingRatesObject.allAttributes[cat.value] = tempRate; break; } } this.aiLevelingRatesObject.UpdateAllPanelItems(this.aiCategoryContentObject.selectedToggle); }
public void ChangeCategory(Category cat) { //Panel Items List <LevelRate> tempList = this.allAttributes[cat.value]; if (tempList != null) { for (int i = 0; i < tempList.Count; i++) { //Panel items Transform child = this.transform.GetChild(i); PanelItem item = child.GetComponent <PanelItem>(); if (item != null) { LevelRate levelRate = tempList[i]; item.levelText.text = "Level " + levelRate.level.ToString(); item.rateText.text = levelRate.rate.ToString(); if (levelRate.isIncreasing > 0) { item.isIncreasingText.text = "++"; } else if (levelRate.isIncreasing < 0) { item.isIncreasingText.text = "--"; } else { item.isIncreasingText.text = "N/A"; } } } } else { Debug.LogError("There's something wrong with the attributes panel UI. Please check."); } }
public void AIFinishedEditing() { try { GameObject obj = GameObject.FindGameObjectWithTag("AIAttributeManager"); if (obj != null) { AIAttributeManager aiAttributeManager = obj.GetComponent <AIAttributeManager>(); if (aiAttributeManager != null) { foreach (Category cat in Category.Values) { if (cat.name.Equals(this.aiCategoryContentObject.selectedToggle)) { int catValue = cat.value; switch (catValue) { default: case 0: aiAttributeManager.SetHealthAttribute(this.aiEquationTextObject.text); break; case 1: aiAttributeManager.SetAttackAttribute(this.aiEquationTextObject.text); break; case 2: aiAttributeManager.SetAttackCooldownAttribute(this.aiEquationTextObject.text); break; case 3: aiAttributeManager.SetSpeedAttribute(this.aiEquationTextObject.text); break; case 4: aiAttributeManager.SetSplitAttribute(this.aiEquationTextObject.text); break; case 5: aiAttributeManager.SetMergeAttribute(this.aiEquationTextObject.text); break; } List <LevelRate> tempList = this.aiLevelingRatesObject.allAttributes[catValue]; for (int i = 0; i < tempList.Count; i++) { bool flag = i > 0; LevelRate rate = tempList[i]; switch (cat.value) { default: case 0: rate.rate = aiAttributeManager.tiers[i].health; if (flag) { rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].health ? 1 : -1; } break; case 1: rate.rate = aiAttributeManager.tiers[i].attack; if (flag) { rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].attack ? 1 : -1; } break; case 2: rate.rate = aiAttributeManager.tiers[i].attackCooldown; if (flag) { rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].attackCooldown ? 1 : -1; } break; case 3: rate.rate = aiAttributeManager.tiers[i].speed; if (flag) { rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].speed ? 1 : -1; } break; case 4: if (i == 0) { rate.rate = aiAttributeManager.tiers[i].split; rate.isIncreasing = 0; } else { rate.rate = 0f; rate.isIncreasing = 0; } break; case 5: rate.rate = aiAttributeManager.tiers[i].merge; if (flag) { rate.isIncreasing = rate.rate > aiAttributeManager.tiers[i - 1].merge ? 1 : -1; } break; } tempList[i] = rate; } this.aiLevelingRatesObject.allAttributes[cat.value] = tempList; break; } } this.aiLevelingRatesObject.UpdateAllPanelItems(this.aiCategoryContentObject.selectedToggle); } } } catch (System.Exception) { this.equationInputField.text = "[Invalid Equation.]"; } }
public void FinishedEditing() { try { GameObject obj = GameObject.FindGameObjectWithTag("UnitAttributes"); if (obj != null) { UnitAttributes unitAttributes = obj.GetComponent <UnitAttributes>(); if (unitAttributes != null) { foreach (Category cat in Category.Values) { if (cat.name.Equals(this.categoryContentObject.selectedToggle)) { int catValue = cat.value; switch (catValue) { default: case 0: unitAttributes.SetHealthAttributes(this.equationTextObject.text); break; case 1: unitAttributes.SetAttackAttributes(this.equationTextObject.text); break; case 2: unitAttributes.SetAttackCooldownAttributes(this.equationTextObject.text); break; case 3: unitAttributes.SetSpeedAttributes(this.equationTextObject.text); break; case 4: unitAttributes.SetSplitAttributes(this.equationTextObject.text); break; case 5: unitAttributes.SetMergeAttributes(this.equationTextObject.text); break; } List <LevelRate> tempList = this.levelingRatesObject.allAttributes[catValue]; for (int i = 0; i < tempList.Count; i++) { bool flag = i > 0; LevelRate rate = tempList[i]; switch (cat.value) { default: case 0: rate.rate = unitAttributes.healthPrefabList[i]; if (flag) { rate.isIncreasing = rate.rate > unitAttributes.healthPrefabList[i - 1] ? 1 : -1; } break; case 1: rate.rate = unitAttributes.attackPrefabList[i]; if (flag) { rate.isIncreasing = rate.rate > unitAttributes.attackPrefabList[i - 1] ? 1 : -1; } break; case 2: rate.rate = unitAttributes.attackCooldownPrefabList[i]; if (flag) { rate.isIncreasing = rate.rate > unitAttributes.attackCooldownPrefabList[i - 1] ? 1 : -1; } break; case 3: rate.rate = unitAttributes.speedPrefabList[i]; if (flag) { rate.isIncreasing = rate.rate > unitAttributes.speedPrefabList[i - 1] ? 1 : -1; } break; case 4: if (i == 0) { rate.rate = unitAttributes.splitPrefabFactor; rate.isIncreasing = 0; } else { rate.rate = 0f; rate.isIncreasing = 0; } break; case 5: rate.rate = unitAttributes.mergePrefabList[i]; if (flag) { rate.isIncreasing = rate.rate > unitAttributes.mergePrefabList[i - 1] ? 1 : -1; } break; } tempList[i] = rate; } this.levelingRatesObject.allAttributes[cat.value] = tempList; break; } } this.levelingRatesObject.UpdateAllPanelItems(this.categoryContentObject.selectedToggle); } } } catch (System.Exception) { this.equationInputField.text = "[Invalid Equation.]"; } }