tailieunhanh - Building XNA 2.0 Games- P10

Building XNA Games- P10: I would like to acknowledge John Sedlak, who saved this book from certain doom, as well as all of the great guys in the XNA community and Microsoft XNA team, who helped me with all of my stupid programming questions. (That is actually the term used—“stupid programming question”—and it is a question that one should not have to ask if one has been approached to write a book about the subject.) | 258 CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH If you don t want to flip back but need a really quick refresher it goes like this commands are declared and run in Script and parsed in ScriptLine. First let s declare our new commands in our enumeration PlaySound Ethereal Solid Speed HP DeathCheck IfDyingGoto KillMe AI We need to parse the new script commands in ScriptLine case ethereal command break case solid command break case speed command iParam split 1 break case hp command iParam split 1 break case deathcheck command break case ifdyinggoto command iParam split 1 break case killme command break case ai command sParam split 1 break Back in Script we can run the new character script commands. We ll implement AI next. CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH 259 case true break case false break case float break case break case if 0 break case if 0 done true break case break case switch case zombie new Zombie break default new Zombie break break Adding AI We re calling it AI for artificial intelligence but make no mistake there will be absolutely nothing intelligent about our AI class. We re basically going to define a list of simple behaviors chase and attack evade stand still and so on in a base AI class and then create monsterspecific classes that will decide which behaviors to use and when. 260 CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH Making artificial intelligence that looks and feels real is what is important. It doesn t .