Develop Trading Card Game Battle System With Unity 3D: Part XX (Spell, Hero Power, Creature Effects) | Vladimir Limarchenko | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Develop Trading Card Game Battle System With Unity 3D: Part XX (Spell, Hero Power, Creature Effects)

teacher avatar Vladimir Limarchenko, Game Developer, Unity3d and C#

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

3 Lessons (52m)
    • 1. Spell Effects and Hero Power Effects

    • 2. Creature Effects – Part 1

    • 3. Creature Effects – Part 2

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this class/series we set an ambitious goal of developing our own trading card game with Unity3d and C#, mostly focusing on card game battle mechanics.

This class is about the most interesting and exciting part of trading card games – unique creature and spell effects.

In our project we'll mostly use spell effects that deal damage to creatures or players. One unique spell effect will be devoted to our Coin card (it'll give one bonus mana crystal to a player just for one turn).

We'll cover several different creature effects:

  • Effects similar to Battlecry in Hearthstone that are caused once when your creature enters the battlefield.
  • Effects similar to Deathrattle in Hearthstone that are caused once when your creature dies.
  • Unique effects that are triggered by certain events in the game. W'`ll make an example effect for one of the creatures that will occur by the end of your hero's turn. But with this recipe you can create a vast variety of different effects (do something when the turn starts or ends for you or for your opponent, when a creature or a spell is played, when your creature attacks and so on). This system of listening to events that we use for these effects is very flexible, so you are only limited by your imagination.

With this class you will gain access to a compete, fully functional Unity project that is an example of a card game battle. The game mechanics are somewhat similar to Hearthstone: custom spells, hero powers, creature effects and so on.

Additional information:

  • The files showed in the course are downloadable from the link that you can find in the "Class Project".
  • The next class of this series will be published on 2017.01.19.

Meet Your Teacher

Teacher Profile Image

Vladimir Limarchenko

Game Developer, Unity3d and C#


I am a Unity3d and C# developer with about 2,5 years of experience in game development. I also have a scientific background. I got a Ph.D. in Theoretical Mechanics in 2014, but then decided to pursue my childhood dream of becoming a game developer. I'm mostly interested in making 2D games. In my opinion, a perfect game should have some tactical or puzzle element to it.

Over the last couple of years I've also worked as an instructor and created several courses on game development. Some of the topics of my courses are: making a 2048 game, building quiz apps, creating a simple virtual pet game, animating 2d characters, building an in-game character customization system.

I'm always willing to experiment and work on some interesting and challenging game mechanics.

See full profile

Class Ratings

Expectations Met?
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Spell Effects and Hero Power Effects: Hello, everyone. And thanks a lot for watching this course. We are gradually approaching the end of the scores and we have only several topics left to discuss. One of them is the topic off, causing some effects when we play a spell or when we use our hero power. Turns out that in our project we can have a system that will take care off both of these tasks. So first, to check out how everything will work, I wanted to go to our assets, scripts, logic and inside of our logic folder. There's another folder that is called Spell Scripts, so spells groups will actually be apart off our logic, and I'd like to open this script that is cold spell effect. It's a very simple script, and it will serve as a base glass for all the spell effects that will have in our game. So this class will have just one method which is virtual so we can override this method and replace all the code in this method with our own costume implementation. For each spell, this method takes into parameters. The 1st 1 is integer special amount, which is the amount that will define such things like how much damage do we want to deal with this spell? Or how much health do you want? To hell with this spell, or how much manna would be like to give to our character? So this special amount is any amount that we should have for the spell in order to cause its effect. And then we'll also have this second argument, which is I character, and our I character is an interface, and in our game logic, our creatures and our players, they implement this interface. The interface I character is located in our file interfaces don't CS, and it makes sure that our object is identifiable, so it has an I. D. It also makes sure that our object has a certain amount of health, which should be true for our creatures and our players. And the last feature off this interface is this method that is called Die. So both are creatures and our players they can die in the game. So the spell effect also takes an eye character argument that is called target. And if the target is no, it means that we're not targeting any creature or character in particular. with this spell. So it is just in effect that we can cause without having any target in particular. And let's go and check out some of the spell effects that we'll have in our game. For example, let's start from the end and check out this steel damage to target script. Another thing that I like about these spell effects is that you don't have to write an individual script for all your spells. For example, if our fireable spell should deal six damage to our opponent or to any other target, and we also have another spell in our game that is supposed to do to damage, essentially, they are both doing the same thing. They're just dealing damage, and the only thing that is different is the amount of this spell that, in our case, is defined by this special amount variable here. So both of these spells, for example, our fireable and some other spell that will be less damage. They can both use this same spell effect, and this lets us save a lot of time while writing these spell effects. So to ride a custom spell effect first, we have to inherit from our base class. That is spell effect, which we are doing here. And then we have to override this method activate effect that will be called when our spell displayed. This method is also part off our logic. So here we don't have to excess the visual part of our game. Instead, we should operate the things that are in the logical part of our game and to tell anything to the visual part of our game. We can't create commands. So here, because we are dealing damage we're creating in you Deal damage command. And it has several arguments. We've made it so that our interface I character will know about our creatures and players. I ds So here we can say target I d. Then, as the second argument, we can pass our special amount, which will be the amount of damage that we want to deal to this creature or player and as a health. After here I am using the named argument which will be equal to our targets. Health minus special amount. And we're working with our commands. We have to always say attic you in the end, so that our command is added to our cue off commands. And after we've done that, just like in all the other scripts, we have to first create this command that will show the damage. And only then we have to actually make some changes to the health off our players or creatures. Because otherwise there might be situation when your player or creature will die first, and then you will show that he got a certain amount of damage. And in our game, of course, this should happen the other way. First, the creatures should take damage and then they should die if this happened in our logic. So this is our first class. Let's take a look at some other glass. For example, this one that is called damage old creatures. Here, we're doing the same thing we have to inherit from our spell effect based glass. And then we have to override this activate effect method. Actually, with this glass, I meant that we should damage all the creatures off our opponents. So here I should say, damage all opponent creatures, and we can easily change the names of these scripts. And for now, we will not get any errors in our project, and you later. See why so in this method activate effect? The only thing that's important is our special amount. I character in this case actually doesn't matter, because we are damaging all the creatures off our opponents in this case, and this spell doesn't have any target in particular. First, we have to find our creatures to damage, and we want to put them in this array off creature logic to find them. We are exiting our turn manager instance. Who? Stern. So if you are casting this spell than your this who stern player and we're trying to access the creatures that our other player has. So we're saying, Other player, his creatures are on his stable. So we're saying Table and we are getting that list Creatures on table. And there's a method that is called to array that will return the contents off this creatures on table list as an array. And then we can damage each creature individually so we can say for each creature logic in our list, we have to deal, damaged this feature and send a command about this, and then our creature should actually take damage. And if the stretcher died, it will later show it's die animation or DI event in our game. Next, we have the spell effect that will use in our coin card. It is called Give Man of Bonus, and in Harsh Stone, there are actually other cards that also give man of bonuses. I remember that Druid class. It has this card that is called Innovate, and it gives your player to man a bonus for one turn. So the fact that implements our calling card and that card is actually the same. And the only thing that's different is this special amount for our calling card. It will be equal to one, and for that innovate card, it will be equal to two. Target doesn't really matter in this case, so it is not used in this method. And here we say, Turn manager instance who? Stern And we're calling a method on our player that is called get bonus manna and will make sure that our player gets this special amount off manna for one turn. And then, as I said, our spell effects will also be used to reflect what happens when we are using our hero powers in this game. So for our project. I've actually selected the hero powers that are not targeted. So, for example, in Harsh Stone there are targeted hero powers like the hero power off major, the deals one damage to a target or the hero power off priests that Hughes the target for to health. Those are targeted hero powers. And if you want to implement them in this game than the approach is very similar to what we've done with our spell cards. You should also have that target game object with a line render and a little triangle that will show the arrow. And you should also write a special dragging action script that will determine what happens when you are dragging your hero power to be above some creatures or players. So that's also an option. But for this course, I decided to make the following hero powers. One of them is the hero power that he's used for war look and harsh stone. So you draw a card butter player receives to damage. First, we have to create a new command to show that we have taken damage, and the player that will take damage is the player who Stern is right now, So we're passing his I d into this method. In this case, we're not using our variable special amount, so we know for sure that we want to take to damage in this case. But actually, we could have used this variable off special amount here as well. And then after creating this command and adding it to our Command Cube, we should subtract two from the amount of health that our player has. And after this, we should draw a card. And another hero power that I've made for this game is the hero power off hunter in harsh stone. So for hunter class, there is a simple hero power that is also not targeted. Any deems to damage to the face off your opponents player. So here we create a command and as a player to take damage. We're using this'll who's turned the other player. And then we also use this amount of to here and in the end, we subtract two from our other players. Health. Now, once we have taken look at all these scripts. There is a question about how they are actually used in our project. And if you remember when we were creating our card logic objects. I can actually open our card logic class. And here our card logic has a public reference to a spell effect object. And we have already discussed this. So when the card is created, we have to create a spell effect object somehow. And then we have to attach this object to our card and assign it to this reference. That is cold effect. It is old on in our cards, constructor. So here we are using this thing that is cold system activator that will let us transform a simple string that will hold a name off our spell effect. So all these names off our classes like give man a bonus, for example, they are very important because we'll have to type them in our unity project. And we don't have to make any typos there and again. This is old down through our system, off guard assets and through our system, off creature assets for our hero powers. So, to show you this, I can actually copy this name, give man a bonus not to make any mistakes. I can press control, see, And then it can minimize mono, develop and switch to our unity project here we can go to our SS folder s O assets and let's go to our Spells folder because we have copied the spell effect that will be used for our coin card. And here in the Inspector for our spell card, we have this last had, er that is cold spell info. And this first field it's cold spell script name. So it's exactly the place where we want to base this. Give man of bonus. And for our corn card, the bonus off manners should be equal to one. So we're setting this special amount to be equal to one, and this spell will have no target in particular. Stay. We're just dragging our card onto the battlefield and it causes its effect. For example, if we want to make our fireable spell functional, then we should get another spell script name, which is our deal. Damage to target. So it can just copied from our script by hitting control. See? And then I can based it onto this field spell script, name, deal, damage to target. And let's actually leave the spell amount at seven. And for the targets, old characters can be selected. I know that we haven't taken Look at our dragging action script that who control our spells behavior. So now let's just take a brief look at this script, all the dragging action streets. They are actually pretty similar, but in this stripped, I'll select our drag spell on target. Here in our on and drag, we have to determine if we have dragged this spell onto Valley Target, for example, if the spell is meant to target Onley our creatures, than we cannot drag this spell onto our players. So this long switch statement here is meant to do just that for each of the cases that our targets variable can take, like targeting options, old characters or targeting options old creatures who include a special check. If we have selected a value target for the spell, then we'll set this variable target value to true and only if this variable is true. By the end of this long switch statement, we'll cast our spell and cause its effect. And if the target is not fairly, then we'll just disable our gizmos and the spell will just remain in our players hand and to set up hero powers in our project. I'll go back to our unity project. I'll go to S O assets and we also have custom assets for our characters. The only characters in our game are these elf and want characters and for each off our character assets. We have this field that is called hero Power name. Actually, if we decide to use our special amounts right after this hero power name, we should include another integer field that will be called Special Amount. And then in our hero power Spell scripts. We can also use this value off special amount. And this we will be able to decide about these amounts for our hero powers note inside of our script. But here in the Inspector, which is convenient, I think so. I might actually do this later for our Elf character. I wanted it to have a hero power that it's similar to Hunter in Harsh Stone. So I'll switch tamano develop. I will use this hero power to face. I'll just copy this phrase and I'll paste it into this hero power name field, and I'll do the same thing for a monk, except I'll use this other hero power here a power drawer card. Take damage. I'll just copy this and paste it into our project. And the last thing that I wanted to discuss with you before we actually launched the game and test everything is where these methods that are called activates effect in our spell effect scripts. So where these methods are actually cold and they're cold in our player class. So let me open our player class. And when a spell is cast or when hero power is used, then certain method is called on our player and inside off these methods for casting a spell or using hero power. We should have a cold too, our activates effect method. So let's check this out. I'll scroll all the way down. I think our method for using hero power is somewhere in the lower part of our script, and this method used here power looks quite simple. First, we have to subtract two from our manner, so our hero powers will always cost to manner. Then we should said the flag used hero power this turn to true to let our player know that he cannot use his hero power again and then we should call the Method hero power effect activate effect. And this hero power effect is a script of type spell effect. If we scroll all the way up, we can see that we have a public spell effect, hero power effect and the value for this hero power effect is signed inside off our method load character info from Asset that is called by our turn manager in the start off our game . And the process is pretty similar to our spells. So we're using system activator too, creating instance over class by its string name. And then we're assigning this instance to our hero power effect. And let's also check out how this works for spells. So for playing spells, we also have methods in our player class that are cold blade spell from hand. And here, inside of this method, we are checking if this effect that is actually a spell effect on our card logic is not equal to know. So if something is assigned to this effect, then we should say played guard dot fact, and we should call this method activate effect. And as arguments into this method, we're passing the special spell amount from our card asset and we're passing the target, which is the argument of this method. So this value off target can point to an actual character or it can be no. And now that we've had this discussion about spells, I'd like to go to unity and launch the game to test this behavior. For now, we have just our corn spell in the game that will behave like a spell, and we also have our hero powers. Later, I wanted to add a couple more spells to our game, and I'll do that. So first for this player, we can play this Wampler than we can end turn. And then for this player we can playing the scoring spell. So let's do that. Currently, our manor is set to one. So once they dragged the scoring spell onto the battlefield, then the SpellEnt transition to our preview spot and will have to manage for this turn, which means that we can play our creature l hit and turn now. And for this player, of course, I'd like to test our hero powers. So now that I press on, this hero power button will take to damage and another card will be drawn for our player, so we'll get exactly what it's scripted in our hero power effect. We can attack and the turn. And for this other player, let's try his hero power. If we use this other players here power, then our opponent will take to damage. So far, everything is working. And in the next lecture I will add a couple more cards to our project that will be spells and I will show you how they work. One of them will deal a certain amount of damage to a target like our fireball, but I think that we should make it cheaper so that we can play it. Fries in the beginning off our game, for example, do damage for one manner. So that's my goal to make this spell. And another spell will do one damage to all the opponents creatures. And I think because well, damage old creatures, it should cost a bit more like two or maybe three manner. So for now, these are the spells that I'm planning to make for our project in the next lecture will check out and test those spells, and we'll also talk about another interesting topic that is our creature effects in Har Stone. There is a major, a variety of different creature effects, and we have already implemented several of them, like charge and win fury just by playing with our card assets. And this time we'd like to take on some more complex creature effects, like battle cry. So something that should happen when you play your creature from hunt or death rattle. So something else should happen when your creature dies. And we'll also talk about how to implement even more complicated effects. Like, for example, you can have a creature that will grow if other creatures steak damage. Or you can have creatures that do something when it's start off your players stern, or when it's the end of your players during or when a card is drawn. So when there are these certain phases in the game, your creatures, they can also react to thes events and cause their unique effects. For now, I'd like to thank you very much for watching the scores, and I will see you in our next lecture 2. Creature Effects – Part 1: Hello, everyone. And thank you very much for watching this course in this lecture will talk about our creature effects. But before we do that, I wanted to address a couple of issues and a couple of fixes that I have introduced into this project before this lecture. I have promised in the previous lecture that I'll make two new spells for our game. So I have added two new card assets into our spells folder. Actually, I think that we already had this card that is called Eclipse. And now I've just played with all the settings and as its spell script name, I've set our damage. Old opponent creatures. I have set special spell among to one and the man A cost of this card will be three. I have also selected the guard image for this card. And my intention is to make this card belongs to our opponents character. So, by changing this character asset field here, I have made this card belongs to our elf characters. I've done some changes to our fireable as well. I've reduced its mana costs because I think that the mana cost was way too high and we had to wait for a long time to be able to play this card. And I've also changed the amount of damage that this card will deal so it will deal five damage and, as the targets for the spell will have old characters so weaken damage creatures and players as well, and in this description will have to change this number from 7 to 5. So actually, all these settings off your card acid, their primary, and then you can ride descriptions in the very end off development off your game. And then I've created another spell card, and I am not very good with names, so I have just called it Pew Pew. It is a week and not very powerful spell that will deal just one damage. Or maybe we should make it to damage. So here I can change this value to say to for one manner just to our creatures. So we cannot target our players with this spell, and my intention was to make this spell belong to our among character. For now, I haven't decided about this fireball spell, so it doesn't belong to any off our character classes, and both characters can have these spells in their decks. Actually, the way our system works. Even our Elf characters, for example, can have this Pew Pew card, even though it belongs to our monk class. So right now there are no limitations, and it's totally our choice. Which guards do we decide to put in our players decks and all these limitations off? Which guards can you put into your players? Deck? How many of the cards can you put into your players that they should all be introduced on a stage off deck building that we are not covering in this course? So for now in this project will work on our players stacks in this manual way. So we have to just select this deck game, object in our hair icky and fill this list with the cards that we want our player to have during the game. And I have changed the contents off our decks for both off our players for our lower player . I've added several of these Pew Pew spells. I've added Templars that he didn't have in his deck yet. I have added one Vulcan, one fire bowl and all the other cards. I think they remained unchanged So this is the deck for our lower player and for our top player. I have also made changes to his deck and previously he had just these Templars in his deck which made his deck very un interesting. And now he has all these different creatures and spells. He has several copies off our eclipse spell. So when we launched the game will actually get to test all these behaviors. I have introduced another small fix into our scene because I've already launched the game and tested everything. I saw that our spot that is used for previewing played spells. It was located in the same plane as our background. So it's that coordinate was zero, and I've made this that according it's similar to our draw preview spot. So when the spell displayed then will be able to see this card nice and large, and it will appear on this side off our screen, and then it will go away after the spell is cast and one final change that I want to talk about that is not related to our creature effects is I have discovered a minor error with our dragging actions scripts for our spell cards, so I will open my mama develop and I'll show it to you. There are these two dragging actions scripts that handle dragging off our cards. One of them is called drag spell No target, and another one is called Drag Spell on Target. And previously they did not have these properties that are cold can drag. So they were just using. The property can drag off our base glass, and it turns out that it wasn't enough. So in the game you might have seen an unwanted behavior when your spell costs, For example, five men alike our previous version off our fire bowl. And even if our player had last man of, for example, just one man, we could still drag our fireable spell and we could cause its effect. So now, to fix this into both of these scripts, I have added a reference to our one card manager because we'll send a message from a logic , and our one card manager will always know if our cards can be played now or not. So to use this functionality, I've added one card manager to both off our spell Scripps and here in awake for both of these scripts. I am getting a reference to our manager for our drag spell on target. Our manager will be attached to our parents game object. So here I should say, get component in parent and for drag Spell no target. Our manager will be attached to the same game object. So the script drag spell no target will also be attached to the card. And finally, including this'll, property can drag with this code. Return base can drag and manager can be played. Now it totally fixes to issue. So now on Lee, if our card is highlighted and playable, and this means that our player has enough manner to play this card right now, only then we can drag this card and played in our game. And now I'll just clothed boasts of thes scripts and will start discussing our creature effects. So as for creature effects, I can actually minimize Monta developed for now, we can go to our assets, scripts, logic, creature scripts. And here you have just These three scripts actually can invent much more of these creature effects and include them into your game. But for now, I have just these scripts that I wanted to show you at. They used different approaches off, causing our creatures effects. And they also wanted to say that I've introduced several changes to our creature effects script. And I've also included in use creep that is called damage Opponent Battle cry and to accommodate for this change, I had to make some changes to our player class and also to our creature logic class that will talk about in this lecture and actually a thing that we are gradually approaching towards the end off our course. So if you want to see the latest and the fullest diversion off these scripts, with all the errors fixed and probably with better comments, then you should just grab the final version off our app from your downloads folder and check out how everything works there. So for creatures just like with our spell effects, will have a base class that is called creature effect, and I'd like to show it to you in mono develop. Unlike our spell effects, this glass Petri effect will actually have several fields that will be our player that is an owner of this creature. The second field will be a reference to our creature logic. So it will be a reference to a creature that this effect is attached to. It will be called creature, and the last reference will be an integer that will be called special amount. So maybe you want to deal some damage or give your player semana or adduced something else when this creature is played. So this variable special amount is here to reflect that. And then because our creature effect has several feuds, it will have its own custom. Constructors who were initializing all the fields at our constructor takes all these arguments off our player owner off a creature logic object that this effect is attached to and then interred your special amount and for our creature of facts will have two different ways off causing these effects the first way and the one that I've used in my test app was listening to different events and by events I mean not unity events, but see sharp events in C sharp. You can also have events, and in our case, we want most of these events to happen with our players. So when our player draws a card, for example, it is an event when our player casts a spell. It is another event, and you can add as many of those events into your player class as you'd like, and will later see how it's done. So these two methods 1st 1 is called register event effect, and the 2nd 1 is called Coast Event Effect, which is similar to our method on our spell effects that is called activate effect. They're both used to work with our events, and they will let us cause some effects. For example, in the end of the turn, in the end of your opponent's turn, maybe when a card is drawn or when the creature displayed. So they present us with one way off causing these effects. And there's actually another way, which is done through just directly calling these methods. The first method is called when a creature is played, and actually it could have called this method just battle cry. So calling this method when a creature is played, it's similar to executing a battle cry effect in harsh stone and calling this second method that is called when a creature dies is similar to executing at death, rattle effect in harsh stone and These are the changes that I had to introduce into our creature effect script. And so I had to accommodate for these changes in some other scripts. For example, let's start with our battle cry and death rattle mechanics because they are much easier so first for each creature. In our logic, creatures will be represented with this creature logic object. And here, inside of our creature logic constructor for each creature will check if creature stripped name for our Carter acid is not equal to know or it is not empty. Then we'll assign something to our variable that is called effect. So we'll say system activator create instance. And here we have an interesting syntax. So actually this method create instance. It might also take several parameters off our constructor, and here we have to also pass an array off system objects. And as thes objects, I'll pass owner, which is our player that owns this creature than the second argument will be this so reference to this creature logic that we are attaching this effect too. And lastly, I'll pass special creature amount from our card asset and this way and you object will be created. Its constructor will get all these parameters from our array, and it will be assigned to our variable effect. Now we have another step here because our creature effect might listen to some events. We have to call the Method Effect Register event effect that will discuss in a couple of seconds and, for example, for our battle cry, I had to go to our player class, and here we have to find a method that is responsible for playing a new creature, Soil Scroll all the way down. And let's search for this method. It is gold play, a creature from hand and among all the other things. First, we're adding this new command that is called Play a Creature Command. So the creature will first appear and will be shown on the battlefield in our game. And then we'll have to check if this new creatures effect is not equal to know. So in case if we haven't assigned any effects to this creature, then we cannot call any methods on his effects. So we have to check if it is not equal to know, and then we can call a method. When a creature ISS played so essentially these couple of flying's will cause our battle cry effect when we're playing the creature and for causing a battle cry effect. I have created this class that is called damage opponent Battle cry so first in this class because it is a creature of fact, we are inheriting from creature effect. And because our creature effect has a constructor with three parameters, we should also have a similar constructor in all these custom classes. So here I am creating this new constructor and actually it can contain absolutely no code. Instead, it will just call the base constructor. So here it can but this colon and say base owner creature, special amounts that will just pass all these parameters into our base constructor incidence. In our creature effect class, I have marked all these methods as virtual. It means that we can implement Onley those methods that we need. So in our damage opponent battle cry class, we can implement just this method when a creature is played and in this case, when the creature displayed, we want to first creating you deal damage command and in this case, we want to damage our opponent character the way to get our opponent character. If we know the character that is the owner of this creature than we can say owner, other player, we have to pass other players. I d into this parameter than we have to pass our special amount. And we have to figure out the health off our other player after this event so we can say owner, other player health minus special amount and will add this command to our Cube. And then after this has happened and this command has been added to the Q, we can say owner, other player health and will subtract our special amount from our opponents. Health. So with this class, we have a very simple battle cry effect that will deal bond damage to our opponents player when the stretcher is played onto the battlefield. So this is one way off. Working with our effects, we have to inherit our creature effect based glass. We have to include this constructor and you'll see that this constructor is included in our second effect class as well. That will just call the base constructor, actually, and you can override one off your methods. One for battle cry that is called when a creature is played or if you want to cause some effect. When a creature dies, you can override another method that is called when creature dies, This one. And if we're calling this method when a creature is played in our player class, this method when a creature dies will be called in our creature logic class. So here we have this method, very schooled die that will be called when the creature dies and then we'll access our effect. If it is not equal to know, then we'll say effect dot When a creature dies and so called death rattle effect off your creature will be played. 3. Creature Effects – Part 2: and another approach off. Working with your Creature effects is working with these two other methods. One of them is called register event Effect, and another one is called cause event effect. So let's take a look at another class, and this class is called bite owner. So I've meant to use this class for that powerful creature that we've agreed that costs just do manner, and it has very high values off health and attack. And I wanted to include some setback for these creatures, some negative effect that will make our players think whether or not they want to play that creature. So I've decided that it will be the effect off damaging our player by the end of the turn. So this effect, it also inherits from our creature effect. And it also has this same constructor that calls our base constructor. And then here we have to override both of these methods one of them register event effect and another one cause event effect. Let us start from this causing event effect method. So here it's pretty standard were first creating our deal damage command and were damaging our owner player, Saru pass our owner players I d. And we'll figure the amount off our owners health after this effect by using our owner dot Health and after creating this command will see owner and of health and will subtract our special amount. So far, it's not very different from what we've had in our previous script. Instead, off our opponent were just damaging our owner. And what's interesting here is this Method register event effect that will determine when our method cause event effect will be called. So you might already be familiar with C Sharp and C Sharp events, delegates and so on. But if you're not, I'll just include a quick walk through on what we're doing here. So we'll have several events that will all be located in our player class. So I'll jump back to our player class right quick, and I'll scroll all the way up to find these events. So here, after our properties have included the code for our events, so first to work with events, we have to declare a so called delegate, our delegate will be void, and it will be called avoid with no arguments. So if I have to describe what our delegates in one sentence, I would say that delegates, they are objects that contain references to our methods. And here we are creating an you delegate that will contain references on Lee to certain type of methods and all these methods. They will be void and they will have no arguments. So it will be a method that will not have any return value and it will not take any arguments. And then we can also declare any number off events here. I am declaring just one of them because we are just learning. And I'm doing this just for testing our game mechanics. So here is a public event. So we're creating a new event, and this event will have our type avoid with no arguments and it will be called and turn event. So when this event happened on Lee, methods there avoid, with no arguments can be called. And just like with unity events, we have to actually call this event or invoke this event somewhere so else grow a bit lower . And here in this method that is called on turn and we're checking if our intern event is not equal to know, and it is an interesting syntax any checks if we have someone or something listening to this event, If there's nothing listening to this event than calling a method and turn event invoke, it will lead to an error. So we first have to check if this event is not equal to know, and then we should see enter an event invoke. So this intern event will always fire when your players turn ends and then we can return back to our script bite owner and we'll see how we can use this event. So because we have a reference to our player owner in this class, we can say owner and turn event and the Syntex for listening to an event is quite simple. We can just say plus equals. So we're adding something to our delegate and we are making our method cause event effect. And here we're just including this methods name. We're making this method. Listen to this event, and it will just get cold when this event is invoked. So whenever it's the end off, our owners turn this method cause event effect will get cold and our owner will get this special amount of damage. And here in this Register event effect method. You don't have to listen to just one event. So for example, we can also see and I can copy this line. I can faced it over here and instead of saying owner and turn event, I can see owner dot other player dot intern event. So if we include this line this effect off dealing two damage to our player, it will because not only on our turn, but also on our opponents stirred, which makes the negative effect of having this creature even more powerful. For now, I think I'll just come until this line later you can play with it and you can try to uncommon this line. Maybe it will result in a more balanced creature. For now, I would like to go to file and select this save all option. L minimized Mona Develop and I would like us to launch the game and check out how everything works. I can check this maximize on play option and launch the game. So when the game starts will get new cards from our new decks that are a bit more interesting. Currently it's our top player, Stern, and we cannot play these eclipse spells, and previously we could play them. I can only play this swamp creature, and then I can press and turn for this character. I think we can only play one off these two creatures. Either. Our Templar are very important. Fact. Sorry. I have to pause the game and show you what I've made to include those effects into her game . So the effects are included on the level off our creatures. We have to go to our assets folder s O assets creatures. And I've attached these effects that we've taken. Look in this lecture to our creatures that are cold beast. So for this feature in this creature script name, I wrote bite owner, and it will bite our owner for to damage. So special creature amount is set to and for this Templar creature that was already present in our game. But it didn't cause any effect in this creature script name. I wrote damage opponent battle cry, and it will deal just one damage to our opponent. So now that we have discussed this, I can reenter play mode by on posing the game. And then I can play this Templar creature, for example. and our opponent will get one damage and it's exactly what's happening and next for this second character. I don't think that he has any cards that he can play right now, so we can just attack and skip the turn. I can actually use his hero power, So let's do that. And now I can press and turn. And for this player, I can also plea this second card that is called beast, a very powerful minion. But it will deal to damage to our player by the end of the turn, And I also didn't write any descriptions for are creatures for now. I will do that in the very end of this course, because I want to make sure that I will not change these effects later. Now, if I wait until the end of the turn, let us check out what happens to our player and he gets to damage. His health was 27 now it is just 25 and also we can use our new spells. So this character, he now has the spell that is called Eclipse and if he plays it onto the battlefield than all the minions, Oh, Armenians they take one damage. And if he hit in turn, I also wanted to get another spell that is present in this player stack. So I guess I'll just skip a couple of turns or we can check out. How far is this spell into our players deck? This one can play another eclipse, which kills our two small creatures here, and he can press and turn also. Now we we actually have our fireball spell in the hand, and we can cast it either onto a creature or onto our opponents player. I think that I will target our opponents player with this spell. Then I'll attack him and I will press in turn hero press in turn again. And I want to get that small spell that it's cold. Pew, pew. I actually think that we'll get to test that other spell in one of our next lectures. So now all the functional part off our game, attacking with creatures, using hero powers, using our spells, both targeted and untargeted. Everything works. And the last couple of things that we have to figure out is first. What happens when one off our players dies? So actually, on this turn. I can un pause the game and I can attack my opponent with both of my medians and I can deal him more damage by using this fireball card and then it just freezes all the timers and nothing happens. So we have to fix this and we have to make something actually happened when our opponent dies. And in our case, because we are not making an actual full game, we might want to include a simple menu that will just let us restart the same battle with the same decks and the same characters. Just the decks will get reshuffled and then the same match will start over. And after we do that, I think it will be the final topic off our course. We have to discuss how our A I system works. So for our opponents player, we can actually attach an A I turn maker instead of player turn maker to hiss Player, which will make him entirely controlled by the computer. So these will be the topics off our next lectures. I would like to thank you very much for watching the scores and I will see you in our next video