Issue with events
I've been trying to solve this puzzle for days now, but I can't seem to be able to solve it. I'm working on a very simple game with two heroes and two monsters. I've created a system where a TurnsManager method checks if all monsters are dead and if there's at least one character left, it will proceed to the second battle. Everything works well until I reach the second battle. If both heroes die the game continues until it ends itself. Any help would be highly appreciated https://github.com/aleviti2/FInal-Battle
GitHub
GitHub - aleviti2/FInal-Battle
Contribute to aleviti2/FInal-Battle development by creating an account on GitHub.
7 Replies
Are you sure your party doesn't end up with >2 Heroes because you're re-using the party?
Mm the logic inside the TurnsManager method should check for the property hero.IsDead, not if the character is present... Characters are not eliminated from the list when they die, only their property goes from IsDead = false to true
Ah ok, sorry I didn't really look much, just that you mentioned it specifically being 2 of each character then saw you were reusing the party from the last fight, so wasn't sure if you had some hardcoded logic elsewhere specifically around 2 characters being dead
I really don't know what to do...
I've just noticed that if I move the BattleSeries.CurrentBattleNumber++; in the second constructor, the game stops when the two heroes win the first battle...
you could really simplify the code by using variables instead of calculating stuff multiple times, it would make it more readable
also did you debug the ending step by step to look at the Party content and how the ending conditions behave?
I did, and I'm thinking there must be something in the third constructor, or in the event manager in BattleSeries
Looking at the GameEngine constructor, could it be a case of circular dependency?
you did? because it could look like this, for example, and i don't see it there yet
also are you sure it can't happen that both monsters and heroes are dead?
sometimes in these type of games you have to account for weird stuff