Chronojam/SpaceGame — pull request #5 by martindevans (2014-01-15 16:18:54+00:00)
Title: Update healthObj.cs

Code review for healthObj. This update was just because I was bored and fancied some easy coding work while I solved a complex problem on Heist. Would you like me to continue doing code reviews like this in my spare time, or to back off and stop fucking with your code?

- Renamed to "Health" from "healthObj", capitalisation of type names is inline with other types and "~Obj" is a useless type postfix (of course it's an object).
- Applying this change will require changing everywhere in the codebase that uses healthObj. Easy for you to do with an IDE,hard for me to do with a text editor! Ideally the file would also be renamed to "Health.cs", but make sure to do this within the IDE (so the .csproj file stays up to date)
- Changed properties backed by fields into auto properties (just a bit simpler)
- Moved default values into Start() as property initialisers (could also put them in constructor, depends on Unity specific stuff so that's up to you)
- Made Health.Set private, it seems like all changes to the "Health" value should be done through "ModHealth(float)" ?
- Previously ModHealth contained this check:

if (!_alive && _health >= 200) {
_alive = true;
}

Which sets the ship to alive if health is set to be very large. This is pretty bad though, if MaxHealth is 100 then health will *never* be 200 and your respawn logic is broken! Instead I Created a Revive() method which sets health back to MaxHealth *if* the ship is dead.