When the author writes the game, he still needs to think about how to start the game again and how the character will be resurrected.
Most will use this method instead of the game to restart the application.loadlevel ("xxx Scene") .
But the resurrection of the character has to be written in its own code to change the component to a certain state.
Re-play:
Application.loadlevel ("xxx scene") = Start the game again
Components. Restore initialization State () + component. Restore initialization State () + component. Restore initialization status () + ... = restart the game
Role Resurrection: Nothing but some roles revert to a specific state
usingSystem;usingUnityengine; Public classGame Control Center { Public BOOLStart Game =false; Public voidStart Again () {Application.loadlevel ("XXX Scene Full component restore to initial state"); } //Complete the Role Resurrection function Public voidrole Resurrection () {Protagonist information component. Restore continue game state (); Enemy components. Restore continue game state (); Other components. Restore continue game state (); Start the game=true; } //The actual programming author is such a%>_<% Public voidrole Resurrection 2 () {lead information component. Blood value=Ten; Enemy components. Collider. eanble=true; Enemy components. Start attacking=true; //and so some xxxx work, relatively scattered }}
Role Resurrection the first way to make the code intuitive!
Introduce the following memo design mode: http://blog.csdn.net/zhengzhb/article/details/7697549;
Unity role Resurrection and restart game