From the course: Object-Oriented Programming with C#
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Execute action - C# Tutorial
From the course: Object-Oriented Programming with C#
Execute action
- [Instructor] The last thing we need to do in order to have our actions work is to be able to register them with the singleton and execute them when the player uses one. Let's go ahead and create a public method to register an action. Inside of this register method, we're going to get the name of the action and change it to lowercase. The reason why we convert the name to lowercase is that we don't want the player to have to worry about what case to use when they're typing in the action name. This way, all the actions will eventually be converted to lowercase so that they match up when we compare them. Now we need to see if the action is already inside of our registered actions dictionary. Here we'll use the dictionary's contain key method and pass it in the name that we just converted to lowercase. If the action already exists, we're going to replace the existing action using the name for the key and the instance…