Closed flip40 closed 9 years ago
Nice descriptions for each of the features/bugs. I should do something like this more often since this would definitely help me have a clearer idea of the problem and typing out things can help me think through the problem (my mind tends to get jumbled as I think through problems)
Do you think that we should create a new script HealthBarSpawner instead of creating the healthbars in PlayerSpawner like I started doing over here?https://github.com/DemoProductions/fighter/commit/9e4dfde34bf2cac8f9700e54db82e17d048fee9a
Hm. I find it hard to decide a proper OOD place to put this, it can likely go in a few places. I think that using a HealthBarSpawner might be a good idea, though it needs to be controlled in some sense by PlayerSpawner (and not be a monobehavior). PlayerSpawner might do something like HealthBarSpawner.createHealthbars( Array of player gameObjects );
which can have implementation that loops through the players and creates a health bar for each, also being sure to link that healthbar to its parent player, something like
void createHealthbars(Array players) {
for (player in players) {
"create healthbar for this player (should change, player 1 goes here, player 2 goes there... and so on)"
healthbar.setPlayer(player.GetComponent<Health>());
}
}
Assuming that the healthbar then uses that player health reference to get its hp and max hp values.
Idea is that PlayerSpawner doesn't know how to create healthbars, but it does know who needs a healthbar, so it asks HealthBarSpawner to create a healthbar for each player, making sure each healthbar knows which player to get its hp values from.
If that makes any sense. Other implementations might work just as well.
Also don't trust my for loop or Array object syntax, I don't know how to do those in C# off the top of my head and I didn't look them up.
Enhance the hp bar to work for both players
A few ways to go about this, either there is one HealthBar.cs that keeps track of healthbars for all players (probably have an array of players that is populated when each character is created), or you can have a healthbar created for each player that then knows how to draw itself based on the player it is assigned to. You can use the gameObject name for this since it will always be player1 and player2.