tailieunhanh - Building XNA 2.0 Games- P11

Building XNA Games- P11: 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.) | 288 CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH rotation frame 4f new Vector2 size Our map scripting system is now in place. We just need to add our MapFlags class. public class MapFlags String flags public MapFlags int size flags new String size for int i 0 i i flags i public bool GetFlag String flag for int i 0 i i if flags i flag return true return false public void SetFlag String flag if GetFlag flag return for int i 0 i i if flags i flags i flag return There s one last bit of cleanup to do remove the for loop in our Gamel initialize routine that spawns our ten zombies. We ll be spawning all of our zombies from map scripts from here on out. CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH 289 With our map in place using its brand-new script run ZombieSmashers. You ll see something like Figure 9-7. Figure 9-7. Final product ofthis chapter Conclusion We ve covered some fairly varied ground in this chapter. The main goal was to introduce map scripting but we ended up adding quite a bit of functionality to our characters blood sprays initialization and death and rudimentary AI. We know that we say this every chapter but we re a lot closer to having a fleshed-out game. To recap we accomplished the following Added all sorts of blood sprays and spurts to the character editor Created zombie attack decap and bloodsplode animations Added initialization scripts Implemented the new blood effects in our game Implemented character initialization and death Added AI Defined a map scripting language Added script-editing functionality to the map editor Introduced map level and global level flags Added fog 290 CHAPTER 9 SCRIPTING AI AND DEPTH AND DEATH In the next chapter we ll introduce player death map transitions a HUD and game menus. As we near the completion of our game it is important to keep our head in the game and not get distracted by the want or need to change things that are done. One of the biggest .