Đang chuẩn bị liên kết để tải về tài liệu:
Building XNA 2.0 Games- P10

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Building XNA 2.0 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 Commands.Ethereal break case solid command Commands.Solid break case speed command Commands.Speed iParam Convert.ToInt32 split 1 break case hp command Commands.HP iParam Convert.ToInt32 split 1 break case deathcheck command Commands.DeathCheck break case ifdyinggoto command Commands.IfDyingGoto iParam Convert.ToInt32 split 1 break case killme command Commands.KillMe break case ai command Commands.AI 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 Commands.Ethereal character.Ethereal true break case Commands.Solid character.Ethereal false break case Commands.Speed character.Speed float line.IParam break case Commands.HP character.HP character.MHP line.IParam break case Commands.DeathCheck if character.HP 0 character.KillMe break case Commands.IfDyingGoto if character.HP 0 character.SetFrame line.IParam done true break case Commands.KillMe character.KillMe break case Commands.AI switch line.SParam case zombie character.Ai new Zombie break default character.Ai 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 .