From 0b81d091b87019cc036cdaf6182a8063d7a6aee9 Mon Sep 17 00:00:00 2001
From: Ny Bruker <robinhs@stud.ntnu.no>
Date: Sat, 29 Oct 2022 17:33:27 +0200
Subject: [PATCH] Added `GetToolTips()` so we can display helpful text. - Added
to abilities, character stats and items.
---
.../Code/Core/Abilities/Base/BaseAbility.cs | 22 +++++++++++++
.../Code/Core/Abilities/Base/IAbility.cs | 6 ++++
MrBigsock/Assets/Code/Core/CharacterStats.cs | 33 +++++++++++++++++++
MrBigsock/Assets/Code/Core/ICharacterStats.cs | 6 ++++
.../Assets/Code/Item/Base/ActiveItemBase.cs | 18 ++++++++++
.../Code/Item/Base/ConditionalItemBase.cs | 12 +++++--
MrBigsock/Assets/Code/Item/Base/IItem.cs | 7 ++++
MrBigsock/Assets/Code/Item/Base/ItemBase.cs | 13 ++++++++
.../Assets/Code/Item/Base/PassiveItemBase.cs | 20 +++++++++++
9 files changed, 135 insertions(+), 2 deletions(-)
diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs
index 9937544a..72ff08e6 100644
--- a/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs
+++ b/MrBigsock/Assets/Code/Core/Abilities/Base/BaseAbility.cs
@@ -1,6 +1,8 @@
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();
+ }
+
}
/*
diff --git a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs
index 0bcd5fcb..5751ef5b 100644
--- a/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs
+++ b/MrBigsock/Assets/Code/Core/Abilities/Base/IAbility.cs
@@ -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
diff --git a/MrBigsock/Assets/Code/Core/CharacterStats.cs b/MrBigsock/Assets/Code/Core/CharacterStats.cs
index d60f4676..9580ee1b 100644
--- a/MrBigsock/Assets/Code/Core/CharacterStats.cs
+++ b/MrBigsock/Assets/Code/Core/CharacterStats.cs
@@ -1,6 +1,8 @@
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
diff --git a/MrBigsock/Assets/Code/Core/ICharacterStats.cs b/MrBigsock/Assets/Code/Core/ICharacterStats.cs
index da7c4ae6..92356b43 100644
--- a/MrBigsock/Assets/Code/Core/ICharacterStats.cs
+++ b/MrBigsock/Assets/Code/Core/ICharacterStats.cs
@@ -82,6 +82,12 @@ namespace BigSock {
*/
float Accuracy { get; }
+
+ /*
+ Returns text representing the modifications it does in percent.
+ */
+ string GetToolTip();
+
}
/*
diff --git a/MrBigsock/Assets/Code/Item/Base/ActiveItemBase.cs b/MrBigsock/Assets/Code/Item/Base/ActiveItemBase.cs
index f49b48f3..89c493d1 100644
--- a/MrBigsock/Assets/Code/Item/Base/ActiveItemBase.cs
+++ b/MrBigsock/Assets/Code/Item/Base/ActiveItemBase.cs
@@ -1,6 +1,8 @@
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
diff --git a/MrBigsock/Assets/Code/Item/Base/ConditionalItemBase.cs b/MrBigsock/Assets/Code/Item/Base/ConditionalItemBase.cs
index 3b9ba976..d60ad118 100644
--- a/MrBigsock/Assets/Code/Item/Base/ConditionalItemBase.cs
+++ b/MrBigsock/Assets/Code/Item/Base/ConditionalItemBase.cs
@@ -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
diff --git a/MrBigsock/Assets/Code/Item/Base/IItem.cs b/MrBigsock/Assets/Code/Item/Base/IItem.cs
index 5782cede..53c4c094 100644
--- a/MrBigsock/Assets/Code/Item/Base/IItem.cs
+++ b/MrBigsock/Assets/Code/Item/Base/IItem.cs
@@ -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
diff --git a/MrBigsock/Assets/Code/Item/Base/ItemBase.cs b/MrBigsock/Assets/Code/Item/Base/ItemBase.cs
index 606f8ef5..f0a6760f 100644
--- a/MrBigsock/Assets/Code/Item/Base/ItemBase.cs
+++ b/MrBigsock/Assets/Code/Item/Base/ItemBase.cs
@@ -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
diff --git a/MrBigsock/Assets/Code/Item/Base/PassiveItemBase.cs b/MrBigsock/Assets/Code/Item/Base/PassiveItemBase.cs
index c5a96e99..a3882238 100644
--- a/MrBigsock/Assets/Code/Item/Base/PassiveItemBase.cs
+++ b/MrBigsock/Assets/Code/Item/Base/PassiveItemBase.cs
@@ -1,6 +1,8 @@
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
--
GitLab