void addSkillLevelIcon(Rect r, LevelUpSystem.ActiveSpell spell, Texture2D icon) { GUI.Button(new Rect(r.x + icon.width - 3 - icon_skill_lvl.width - 2, r.y + icon.height - 3 - icon_skill_lvl.height - 1, icon_skill_lvl.width, icon_skill_lvl.height), icon_skill_lvl, spellButtonStyle); GUI.Label(new Rect(r.x + 10, r.y + 11, r.width, r.height), string.Format("{0}", spell.level), skilllvlTextStyle); }
void createToolTip(Rect r, LevelUpSystem.ActiveSpell skill) { if (r.Contains(Event.current.mousePosition)) { GUI.color = Color.yellow; GUI.Box(new Rect(156, 120, 200, 130), ""); GUI.Box(new Rect(156, 120, 200, 130), skill.name + " (lvl " + skill.level + ")", skillTitleTextStyle); GUI.color = Color.white; GUI.Box(new Rect(156, 120, 200, 130), "\n\n" + skill.getInfo(), skillDescriptionTextStyle); GUI.Box(new Rect(156, 120, 200, 130), "\n\n\n\n\n" + skill.getDescription(), skillDescriptionTextStyle); } }
void SpellButton(Rect r, LevelUpSystem.ActiveSpell active, Texture2D icon, KeyCode key, GUIStyle style) { createToolTip(r, active); if (!active.isAvailable()) { GUI.color = new Color(0.4f, 0.4f, 0.4f, 1); } if ((Event.current.type == EventType.KeyDown && Event.current.keyCode == key || GUI.Button(r, icon, style)) && active.isAvailable() && player.GetComponent <Controls>().cantMove == 0) { if (active.manaCost <= mana) { if (active.Equals(lvlSystem.actives[0])) { if (health < maxHealth) { lvlSystem.activate_skill(active); } } else if (active.Equals(lvlSystem.actives[1]) || active.Equals(lvlSystem.actives[2])) { if (player.GetComponent <Controls>().grounded) { lvlSystem.activate_skill(active); } } else { lvlSystem.activate_skill(active); } } else { audio.PlayOneShot(outOfMana); } } if (active.onCoolDown() && active.level > 0) { GUI.Label(r, string.Format("{0:F1}", active.cooldown - (Time.time - active.lastCastTime)), coolDownTextStyle); } addSkillLevelIcon(r, active, icon); GUI.color = Color.white; }