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

[GH-280] Display Energy bar in Battle #420

Merged
merged 15 commits into from
May 16, 2024
Merged

[GH-280] Display Energy bar in Battle #420

merged 15 commits into from
May 16, 2024

Conversation

ncontinanza
Copy link
Collaborator

Closes #280

⚠️ Test together with this backend PR: lambdaclass/mirra_backend#564

Motivation

Until now, we couldn't see the energy accumulated by each unit in the battle.

Summary of changes

  • Add an energy bar to the unit prefab, right below the health bar.
  • Increase the energy level each time the unit attacks with the basic skill, and decrease the bar to zero when the ultimate skill is casted.
  • Receive a new message from the backend, StatOverride, to support the case in which we need to set a specific value to a stat, such as setting it to zero when the energy is consumed to perform the ultimate attack. This message will be reused in the near future for other stats.

How has this been tested?

Start the backend (use this branch!) and fight a battle. You should see a blue energy bar above each unit's head, that increases with each use of the basic skill and decreases with each use of the ultimate skill (that is, after is reaches its top).

Test additions / changes

List tests added/updated.

Checklist

  • I have tested the changes locally.
  • I self-reviewed the changes on GitHub, line by line.
  • Tests have been added/updated.
  • This change requires new documentation.
    • Documentation has been added/updated.
  • I have tested the changes in another devices.
    • Tested in iOS.
    • Tested in Android.

@ncontinanza ncontinanza added the Waiting on PR Use this tag to alert reviewers that this PR shouldn't be merged until another one is merged first label May 3, 2024
Copy link
Collaborator

@tkz00 tkz00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.2024-05-03.at.2.54.56.PM.mov

I see that after casting their first ultimate of the battle, units stop charging it's energy bar, except sometimes that they charge a little and then it goes away without it being complete.

@ncontinanza
Copy link
Collaborator Author

ncontinanza commented May 7, 2024

Screen.Recording.2024-05-03.at.2.54.56.PM.mov
I see that after casting their first ultimate of the battle, units stop charging it's energy bar, except sometimes that they charge a little and then it goes away without it being complete.

Thanks! I wasn't limiting the amount to add/substract from the unit's energy, so in some cases I was allowing negative amounts of energy. Should be fixed now.

tkz00
tkz00 previously approved these changes May 10, 2024
tkz00
tkz00 previously approved these changes May 14, 2024
Copy link
Collaborator

@tkz00 tkz00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found an error when battling with less than 6 units in either team.

client/Assets/Scripts/Battle/BattleManager.cs Outdated Show resolved Hide resolved
tkz00
tkz00 previously approved these changes May 15, 2024
target.CurrentHealth = (int)action.StatOverride.StatAffected.Amount;
break;
case Protobuf.Messages.Stat.Energy:
target.CurrentEnergy = Math.Max(0, (int)action.StatOverride.StatAffected.Amount);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we introducing game logic here? If our battle design does not allow us to have negative energy, then it's not a good idea to hide it here, as the battle will be buggy and we will have less ways of finding out!

@ncontinanza ncontinanza merged commit 3243b18 into main May 16, 2024
@ncontinanza ncontinanza deleted the gh-280-energy-bar branch May 16, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on PR Use this tag to alert reviewers that this PR shouldn't be merged until another one is merged first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display Energy bar in battle
3 participants