tailieunhanh - Building XNA 2.0 Games- P15
Building XNA Games- P15: 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.) | 408 APPENDIX A DESIGNING THE WRAITH Our shockwave in action is shown in Figure A-8. Figure A-8. Shockwave in action Hit Logic We ll need to add some functionality to to implement the nolifty status rocket strikes and chainsaw smashes. The way that we ll set up the nolifty character will primarily prevent the monster from being lifted into the air by uppercut attacks but also will cause the monster s animation to sometimes not be affected by attacks. This means you ll be able to smash away on the wraith for a couple of seconds and he will be reacting to every hit but then for the next three seconds he will be able to attack in the midst of your barrage. We ll add a flag to the Character class called stunFrame which will decrease at a rate of 1f per second if above Of. If stunFrame is between Of and 3f the monster won t be affected by attacks. We get the previous state and previous location of the wraith. If we don t want him lifted we ll check to see if he is currently airborne and previously grounded if this is the case we return him to his previous state. Also we now need to check for noAnim before every trajectory and animation change to prevent us from moving characters that shouldn t be moving. int pState c i .state Vector2 pLoc c i .loc bool noAnim false if c i .stunFrame Of c i .stunFrame 3f noAnim true if c i .noLifty APPENDIX A DESIGNING THE WRAITH 409 if c i .stunFrame of c i .stunFrame c i .stunFrame if typeof Bullet .Equals . else if typeof Rocket .Equals 1f hVal 5f if noAnim c i . .X of 600f -600f c i .SetAnim jhit c i .SetJump 300f r true else if typeof Hit .Equals . if noAnim c i .SetAnim idle c i .SetAnim hit switch case case hVal 15f new Vector2 -50f tX 150f c i .SetAnim jfall c i .SetJump -900f .
đang nạp các trang xem trước