TAILIEUCHUNG - Beginning XNA 2.0 Game Programming From Novice to Professional phần 10

Bằng cách này, vũ khí được cập nhật theo tay phải của người chơi. Bạn cũng cần để thiết lập hướng mục tiêu của vũ khí như hướng phía trước của người chơi (như minh họa trong hình 12-9). Lưu ý rằng bạn cần phải chuyển đổi xương bàn tay phải của người chơi của người chơi ma trận chuyển đổi trước | CHAPTER 12 CREATING A THIRD-PERSON SHOOTER GAME 379 You update the player s weapon by calling the weapon s Update method and passing the player s right hand bone as the weapon s parent bone. In this way the weapon is updated according to the player s right hand. You also need to set the weapon s target direction as the player s front direction as illustrated in Figure 12-9 . Note that you need to transform the player s right hand bone by the player s transformation matrix before using it to update the player s weapon. Following is the code for the player s Update methods public override void Update GameTime time Update the player s waist bone float elapsedTimeSeconds float UpdateWaistBone elapsedTimeSeconds Update player s base class It s where the player s position and animated model are updated time Update camera chase position UpdateChasePosition Update player weapon Matrix transformedHand RIGHT_HAND_BONE_ID time transformedHand HeadingVector UpVector rotateWaistBone Enemy The Enemy class is the one that has the enemy NPC s logic and attributes. Figure 12-10 exhibits a spider model used as an enemy in the game. 380 CHAPTER 12 CREATING A THIRD-PERSON SHOOTER GAME Figure 12-10. An alien spider model. Courtesy of Psionic http . Differently from the player the enemy is computer controlled so you need to implement its AI. The enemy s AI is simple having only four different states Wandering Chasing Player Attacking Player and Dead. Figure 12-11 shows the diagram of the AI built for the enemies. Figure 12-11. Enemy AI diagram CHAPTER 12 CREATING A THIRD-PERSON SHOOTER GAME 381 In the AI diagram in Figure 12-11 each circle represents a different enemy state and the arrows represent the actions that make an enemy change its state. The enemy s AI starts in the Wandering state. In this state the enemy keeps .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
31    248    0    25-04-2024
19    228    0    25-04-2024
34    212    1    25-04-2024
8    172    0    25-04-2024
22    119    0    25-04-2024
75    137    0    25-04-2024
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.