Learn how to build a reusable attack action based on the the generic action classes created in the previous video. This battle action will accept two targets, the player and the monster. Once set up, the battle action will be able to calculate attack damage from target1 and apply it to target2 as well as generate out a message detailing the action’s results.
- [Voiceover] Now that we have our generic battle action,…it's time for us to create our attack action.…Let's right-click inside of the battle system scripts…folder and create a new C# script.…And we're gonna call this AttackBattleAction.…Let's open up this class in Mono Develop.…At the top of this class we're gonna need to bring in…the system text name space.…So type in using System.Text.…We're also going to extend our generic battle action.…
And we can delete the start and update methods.…The first thing we're gonna do is override…our attack action.…Since we don't have any code in the generic battle action,…let's go ahead and delete the call…to the base action method.…First we're gonna create a variable that'll store…our attack value.…Let's call this var attackValue and we'll set it equal…to a cast of int Random.range and we'll supply the…target1.attackRange.x comma target1.attackRange.y.…
Next we're gonna apply the attack value…to the target2's health.…So let's call target2.decreaseHealth and pass in…the attack value we just calculated.…
- 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?
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.