Learn how to add a delegate to create a call back event when the battle is over so the main game loop knows when to exit the battle. You’ll track the player and monster's health as well as if a successful run action is able to trigger the end of the battle loop. Once the battle is over the engine will close the battle window.
- View Offline
- Exercise Files
- [Voiceover] Now we need a way to tell if a battle is over.…This usually happens when the player…or the monster's health reaches zero.…In order to do this we're gonna need…to open up our battle window.…Let's scroll up to the top of our class,…and we're gonna add a new public delegate.…Our delegate will have a return type of void,…and we're gonna call this BattleOver.…We'll also pass in a boolean called playerWin.…Now let's create a new public field,…typed to our BattleOver delegate,…and we'll call this battleOverCallback.…
Next, now let's scroll to the bottom of our class,…and create a new IEnumerator,…and we're gonna call this, OnBattleOver.…Now inside of this, we're gonna create a message.…We'll do var message equals and inside a parenthesis,…let's test to see if the player is alive.…If they are we'll use a question mark…to return the player.name.…If the player is not alive, we'll use…a colon to return the monsters name.…
Then let's add a string to the end of this,…starting with a space, and type has won the battle.…
- Preparing the user interface
- Creating game and message windows
- Building a battle window
- Adding a monster and action buttons
- Creating an actor class
- Adding player and monster attack actions
- Triggering battles from the map
- Ending a battle
- Cleaning up the battle and attack systems
- Rewarding the player
Skill Level Intermediate
1. Preparing the UI
2. Message Window
3. The Battle Window
4. Actor Classes
5. Battle Actions
6. Cleaning Up Combat
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.