Why isn't my list reflecting the changes I make to my object?
This is a question that will require looking at a lot of code. So first and foremost, thank you very much for anyone who takes the time to help.
TurnManager
TacticsMove
FamiliarTacticsMove
UnitCaster
So let me explain the error. I'm making a team turn-based game. Your turn ends when you've moved every one of your units. If you've played Fire Emblem, you've got the right idea.
I have two lists in TurnManager; one for the player team and one the NPC team, and a queue representing who's turn it is. Every time a unit ends their turn by calling EndTurn() in TurnManager, EndTurn() will run through the list with a for to see if any other unit still has an active turn. This works when it's just the player piece and the enemy NPC piece on the board.
But when I summon a familiar to the board, that's when I experience my logic error. PlayerMove calls the SummonFamiliar() method in UnitCaster, who copies a default familiar from a library of familiars, then adds it to the playerTeam in TurnManager.
Attached to every object is a grandchild of the script TacticsMove, either FamiliarMove or PlayerMove.
So it goes TacticsMove -> FamiliarTacticsMove -> FamiliarMove
TacticsMove contains the boolean variable "turn", indicating whether or not the unit's turn is active. That's the parameter that EndTurn() checks.
But for some reason, even though I set "turn" to false in EndFamiliarTurn() in FamiliarTacticsMove, a child class of TacticsMove, it's still registering as true when EndTurn() runs in TurnManager- in other words, the list isn't updating.
This has created a strange effect where the actual object's "turn" flag is false (you can see it in the Unity Editor at runtime) but internally, that list just isn't updating, so the game basically locks up.
I strongly think it's something wrong with the list, because I tested a dummy string variable with the value "cake", and it failed to update to "pie" in the list when I changed it. So I doubt I have any stray code anywhere accidentally flipping "turn" back to true.
Any help would be greatly appreciated. I'm about ready to tear my hair out.
Your answer
![](https://koobas.hobune.stream/wayback/20220613021000im_/https://answers.unity.com/themes/thub/images/avi.jpg)