void UpdateSpellInfo() { if (currTargetGroup[0].GetComponent <UnitSpellHandler>() != null) { UnitSpellHandler tempUSH = currTargetGroup[0].GetComponent <UnitSpellHandler>(); for (int i = 0; i < spellButtons.Length; i++) { if (tempUSH.SpellIndexExists(i)) { //spellButtons[i].GetComponent<Tooltip>().tooltip = "<b>" + tempUSH.allAbilities[i].name+ "</b>" + "\n" + tempUSH.allAbilities[i].tooltip; tooltips updateras i sin egen funktion Image spellButtonImage = spellButtons[i].GetComponent <Image>(); spellButtonImage.sprite = tempUSH.allAbilities[i].abilitySprite; if (tempUSH.autoCast[i] == true && tempUSH.allAbilities[i].GetComponent <CastAbility>() == true) { spellButtons[i].image.color = autoCastColor; } else { spellButtons[i].image.color = normalColor; } float bestCooldown = 0.0f; //displaya den bästa cooldownen hos gruppen, castspell kommer ändå kanske alla som är redo for (int y = 0; y < currTargetGroup.Count; y++) { float currCooldown = currTargetGroup[y].GetComponent <UnitSpellHandler>().allAbilities[i].GetPercentageCooldownFinished(); if (bestCooldown < currCooldown) { bestCooldown = currCooldown; } } spellButtonImage.fillAmount = bestCooldown; } else { spellButtons[i].GetComponent <Image>().sprite = spellMissingSprite; spellButtons[i].image.color = normalColor; spellButtons[i].GetComponent <Image>().fillAmount = 1; } } } else { for (int i = 0; i < spellButtons.Length; i++) { spellButtons[i].GetComponent <Tooltip>().tooltip = ""; //den kommer inte visa någon bar ifall det är "" (y) spellButtons[i].GetComponent <Image>().sprite = spellMissingSprite; } } }
public void ToggleAutoCast(int spellIndexBut) { if (currTargetGroup[0].GetComponent <UnitSpellHandler>() == null) { return; } UnitSpellHandler firstSpellHandler = currTargetGroup[0].GetComponent <UnitSpellHandler>(); if (!firstSpellHandler.SpellIndexExists(spellIndexBut)) { return; } bool newAutocastSetting = !firstSpellHandler.autoCast[spellIndexBut]; for (int i = 0; i < currTargetGroup.Count; i++) { currTargetGroup[i].GetComponent <UnitSpellHandler>().autoCast[spellIndexBut] = newAutocastSetting; } }
void UpdateToolTips() { //updatera tooltips till dessa nya units! if (currTargetGroup.Count == 0) { return; } if (currTargetGroup[0].GetComponent <UnitSpellHandler>() != null) { UnitSpellHandler tempUSH = currTargetGroup[0].GetComponent <UnitSpellHandler>(); for (int i = 0; i < spellButtons.Length; i++) { if (tempUSH.SpellIndexExists(i)) { //spellButtons[i].GetComponent<Tooltip>().ChangeToolTip(GetSpellToolTip(i)); //updatera spelltooltipen spellButtons[i].GetComponent <Tooltip>().tooltip = "<b>" + tempUSH.allAbilities[i].name + "</b>" + "\n" + tempUSH.allAbilities[i].tooltip; //spell tooltips! } else { spellButtons[i].GetComponent <Tooltip>().tooltip = ""; //den kommer inte visa någon bar ifall det är "" (y) } } } string armorTypeToolTip = damageHandler.GetArmorToolTip(currTargetGroup[0].GetComponent <Health>().armorType); if (currTargetGroup[0].GetComponent <AIBase>() != null) { string damageTypeToolTip = damageHandler.GetDamageToolTip(currTargetGroup[0].GetComponent <AIBase>().damageType); damageTypeImage.gameObject.GetComponent <Tooltip>().ChangeToolTip(damageTypeToolTip); } else { damageTypeImage.gameObject.GetComponent <Tooltip>().ChangeToolTip("N/A"); } armorTypeImage.gameObject.GetComponent <Tooltip>().ChangeToolTip(armorTypeToolTip); //namn och tooltip på unitet Health ct = currTargetGroup[0].GetComponent <Health>(); unitPortrait.GetComponent <Tooltip>().ChangeToolTip("<b>" + ct.name + "</b>\n" + ct.tooltip); }