Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extra buffs in character window #1417

Merged
merged 2 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
151 changes: 150 additions & 1 deletion Intersect.Client/Interface/Game/Character/CharacterWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

using Intersect.Client.Core;
Expand Down Expand Up @@ -71,6 +71,39 @@ public partial class CharacterWindow

public int Y;

//Extra Buffs
ClassBase mPlayer;

Label mHpRegen;

int HpRegenAmount;

Label mManaRegen;

int ManaRegenAmount;

Label mLifeSteal;

int LifeStealAmount = 0;

Label mAttackSpeed;

Label mExtraExp;

int ExtraExpAmount = 0;

Label mLuck;

int LuckAmount = 0;

Label mTenacity;

int TenacityAmount = 0;

Label mCooldownReduction;

int CooldownAmount = 0;

//Init
public CharacterWindow(Canvas gameCanvas)
{
Expand Down Expand Up @@ -132,6 +165,18 @@ public CharacterWindow(Canvas gameCanvas)
Items[i].Setup();
}

var extraBuffsLabel = new Label(mCharacterWindow, "ExtraBuffsLabel");
extraBuffsLabel.SetText(Strings.Character.ExtraBuffs);

mHpRegen = new Label(mCharacterWindow, "HpRegen");
mManaRegen = new Label(mCharacterWindow, "ManaRegen");
mLifeSteal = new Label(mCharacterWindow, "Lifesteal");
mAttackSpeed = new Label(mCharacterWindow, "AttackSpeed");
mExtraExp = new Label(mCharacterWindow, "ExtraExp");
mLuck = new Label(mCharacterWindow, "Luck");
mTenacity = new Label(mCharacterWindow, "Tenacity");
mCooldownReduction = new Label(mCharacterWindow, "CooldownReduction");

mCharacterWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
}

Expand Down Expand Up @@ -317,6 +362,8 @@ public void Update()
mAddSpeedBtn.IsHidden =
Globals.Me.StatPoints == 0 || Globals.Me.Stat[(int) Stats.Speed] == Options.MaxStatValue;

UpdateExtraBuffs();

for (var i = 0; i < Options.EquipmentSlots.Count; i++)
{
if (Globals.Me.MyEquipment[i] > -1 && Globals.Me.MyEquipment[i] < Options.MaxInvItems)
Expand All @@ -328,6 +375,8 @@ public void Update()
Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId,
Globals.Me.Inventory[Globals.Me.MyEquipment[i]].StatBuffs
);

UpdateExtraBuffs(Globals.Me.Inventory[Globals.Me.MyEquipment[i]].ItemId);
}
else
{
Expand All @@ -341,16 +390,116 @@ public void Update()
}
}

/// <summary>
/// Update Extra Buffs Effects like hp/mana regen and items effect types
/// </summary>
public void UpdateExtraBuffs()
{
mPlayer = ClassBase.Get(Globals.Me?.Class ?? Guid.Empty);

//Getting HP and Mana Regen
if (mPlayer != null)
{
HpRegenAmount = mPlayer.VitalRegen[0];
mHpRegen.SetText(Strings.Character.HealthRegen.ToString(HpRegenAmount));
ManaRegenAmount = mPlayer.VitalRegen[1];
mManaRegen.SetText(Strings.Character.ManaRegen.ToString(ManaRegenAmount));
}

CooldownAmount = 0;
LifeStealAmount = 0;
TenacityAmount = 0;
LuckAmount = 0;
ExtraExpAmount = 0;

mLifeSteal.SetText(Strings.Character.Lifesteal.ToString(0));
mExtraExp.SetText(Strings.Character.ExtraExp.ToString(0));
mLuck.SetText(Strings.Character.Luck.ToString(0));
mTenacity.SetText(Strings.Character.Tenacity.ToString(0));
mCooldownReduction.SetText(Strings.Character.CooldownReduction.ToString(0));

mAttackSpeed.SetText(Strings.Character.AttackSpeed.ToString(Globals.Me.CalculateAttackTime() / 1000f));
}

/// <summary>
/// Update Extra Buffs Effects like hp/mana regen and items effect types
/// </summary>
/// <param name="itemId">Id of item to update extra buffs</param>
public void UpdateExtraBuffs(Guid itemId)
{
var item = ItemBase.Get(itemId);

if (item == null)
{
return;
}

//Getting HP and Mana Regen
if (item.VitalsRegen[0] != 0)
{
HpRegenAmount += item.VitalsRegen[0];
mHpRegen?.SetText(Strings.Character.HealthRegen.ToString(HpRegenAmount));
}

if (item.VitalsRegen[1] != 0)
{
ManaRegenAmount += item.VitalsRegen[1];
mManaRegen?.SetText(Strings.Character.ManaRegen.ToString(ManaRegenAmount));
}

//Getting extra buffs
if (item.Effect.Type != EffectType.None && item.Effect.Percentage > 0)
{
switch (item.Effect.Type)
{
case EffectType.CooldownReduction:
CooldownAmount += item.Effect.Percentage;
mCooldownReduction?.SetText(Strings.Character.CooldownReduction.ToString(CooldownAmount));

break;
case EffectType.Lifesteal:
LifeStealAmount += item.Effect.Percentage;
mLifeSteal?.SetText(Strings.Character.Lifesteal.ToString(LifeStealAmount));

break;
case EffectType.Tenacity:
TenacityAmount += item.Effect.Percentage;
mTenacity?.SetText(Strings.Character.Tenacity.ToString(TenacityAmount));

break;
case EffectType.Luck:
LuckAmount += item.Effect.Percentage;
mLuck?.SetText(Strings.Character.Luck.ToString(LuckAmount));

break;
case EffectType.EXP:
ExtraExpAmount += item.Effect.Percentage;
mExtraExp?.SetText(Strings.Character.ExtraExp.ToString(ExtraExpAmount));

break;
}
}
}

/// <summary>
/// Show the window
/// </summary>
public void Show()
{
mCharacterWindow.IsHidden = false;
}

/// <summary>
/// </summary>
/// <returns>Returns if window is visible</returns>
public bool IsVisible()
{
return !mCharacterWindow.IsHidden;
}

/// <summary>
/// Hide the window
/// </summary>
public void Hide()
{
mCharacterWindow.IsHidden = true;
Expand Down
18 changes: 18 additions & 0 deletions Intersect.Client/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,24 @@ public partial struct Character

public static LocalizedString title = @"Character";

public static LocalizedString ExtraBuffs = @"Extra Buffs";

public static LocalizedString HealthRegen = @"Health Regen: {00}%";

public static LocalizedString ManaRegen = @"Mana Regen: {00}%";

public static LocalizedString Lifesteal = @"Lifesteal: {00}%";

public static LocalizedString AttackSpeed = @"Attack Speed: {00}s";

public static LocalizedString ExtraExp = @"Bonus EXP: {00}%";

public static LocalizedString Luck = @"Luck: {00}%";

public static LocalizedString Tenacity = @"Tenacity: {00}%";

public static LocalizedString CooldownReduction = @"Cooldown Reduction: {00}%";

}

public partial struct CharacterCreation
Expand Down