Skip to content
Snippets Groups Projects
Commit 0b81d091 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Added `GetToolTips()` so we can display helpful text.

- Added to abilities, character stats and items.
parent fccc0861
No related branches found
No related tags found
1 merge request!53ToolTips, new ability parameter system & misc clean ups.
using System.Collections;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.InputSystem;
......@@ -102,6 +104,26 @@ namespace BigSock {
*/
protected abstract bool Activate(Character actor, Vector3? target);
/*
Returns text that represents info about the ability.
*/
public string GetToolTip() {
var sb = new StringBuilder()
.AppendLine(Name)
.AppendLine()
.AppendLine(Description)
.AppendLine($"Cooldown: {Cooldown}");
if(ManaCost != 0) sb.AppendLine($"Mana Cost: {ManaCost}");
if(StaminaCost != 0) sb.AppendLine($"Stamina Cost: {StaminaCost}");
if(HPCost != 0) sb.AppendLine($"HP Cost: {HPCost}");
return sb.ToString();
}
}
/*
......
......@@ -76,5 +76,11 @@ namespace BigSock {
Try to use the ability.
*/
bool Use(Character actor, Vector3? target);
/*
Returns text that represents info about the ability.
*/
string GetToolTip();
}
}
\ No newline at end of file
using System.Collections;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.InputSystem;
......@@ -92,5 +94,36 @@ namespace BigSock {
The range of the character.
*/
public float Accuracy { get; set; }
/*
Returns text representing the modifications it does in percent.
*/
public string GetToolTip() {
var sb = new StringBuilder();
if(MaxHP != 0) sb.AppendLine($"Max HP: {MaxHP:P0}");
if(MaxMana != 0) sb.AppendLine($"Max Mana: {MaxMana:P0}");
if(RegenMana != 0) sb.AppendLine($"Regen Mana: {RegenMana:P0}");
if(MaxStamina != 0) sb.AppendLine($"Max Stamina: {MaxStamina:P0}");
if(RegenStamina != 0) sb.AppendLine($"Regen Stamina: {RegenStamina:P0}");
if(Damage != 0) sb.AppendLine($"Damage: {Damage:P0}");
if(Knockback != 0) sb.AppendLine($"Knockback: {Knockback:P0}");
if(Range != 0) sb.AppendLine($"Range: {Range:P0}");
if(ProjectileSpeed != 0) sb.AppendLine($"Projectile Speed: {ProjectileSpeed:P0}");
if(Accuracy != 0) sb.AppendLine($"Accuracy: {Accuracy:P0}");
if(MoveSpeed != 0) sb.AppendLine($"Move Speed: {MoveSpeed:P0}");
if(AttackSpeed != 0) sb.AppendLine($"Attack Speed: {AttackSpeed:P0}");
if(CritChance != 0) sb.AppendLine($"Crit Chance: {CritChance:P0}");
if(CritDamageModifier != 0) sb.AppendLine($"Crit Damage Modifier: {CritDamageModifier:P0}");
return sb.ToString();
}
}
}
\ No newline at end of file
......@@ -82,6 +82,12 @@ namespace BigSock {
*/
float Accuracy { get; }
/*
Returns text representing the modifications it does in percent.
*/
string GetToolTip();
}
/*
......
using System.Collections;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.InputSystem;
......@@ -18,5 +20,21 @@ namespace BigSock.Item {
public abstract IAbility Ability { get; }
/*
The type of the item.
*/
public override string ItemType => "Active";
/*
Returns a string used to inform the user about this item in greater detail.
*/
public override string GetToolTip() {
return new StringBuilder()
.AppendLine(base.GetToolTip())
.AppendLine()
.AppendLine(Ability.GetToolTip())
.ToString();
}
}
}
\ No newline at end of file
......@@ -19,10 +19,18 @@ namespace BigSock.Item {
*/
public abstract TriggerType Trigger { get; }
/*
The type of the item.
*/
public override string ItemType => "Conditional";
/*
The handler to activate when the condition is triggered.
Returns a string used to inform the user about this item in greater detail.
*/
//public Action<ICharEventParams> Handler { get; set; }
public override string GetToolTip() {
return $"{base.GetToolTip()}\n\nTrigger: {Trigger}";
}
}
}
\ No newline at end of file
......@@ -32,5 +32,12 @@ namespace BigSock.Item {
Sprite Icon { get; }
/*
Returns a string used to inform the user about this item in greater detail.
*/
string GetToolTip();
}
}
\ No newline at end of file
......@@ -40,12 +40,25 @@ namespace BigSock.Item {
public virtual string IconName { get; } = "item/tilesetnice";
/*
The type of the item.
*/
public abstract string ItemType { get; }
public ItemBase() {
//Icon = SpriteService.SINGLETON.Get(IconName);
}
/*
Returns a string used to inform the user about this item in greater detail.
*/
public virtual string GetToolTip() {
return $"{Name} ({ItemType})\n\n{Description}";
}
}
}
\ No newline at end of file
using System.Collections;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.InputSystem;
......@@ -17,5 +19,23 @@ namespace BigSock.Item {
public ICharacterStats Modifier { get; set; }
/*
The type of the item.
*/
public override string ItemType => "Passive";
/*
Returns a string used to inform the user about this item in greater detail.
*/
public override string GetToolTip() {
var stats = Modifier.GetToolTip();
var sb = new StringBuilder().AppendLine(base.GetToolTip());
if(stats.Length > 0) sb.AppendLine($"\n{stats}");
return sb.ToString();
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment