Visual C# Game Programming for Teens phần 9

Các chương trình giới thiệu Cổng thông tin tìm kiếm tài sản Collidable ngói và các báo cáo trên màn hình khi một gạch collidable được xác định. Hình 9,6 cho thấy các thông điệp được in khi người chơi đi qua một collidable | 358 Chapter 13 Equipping Gear and Looting Treasure Items Class The Items class is a helper class to handle the items database. The Items class reads in the entire .item file and is used to drop items when a monster is killed as well as to show items in the player s inventory. So this class is very important it keeps our main code tidy by providing a very useful helper function called getItem . When creating an object using this class during program initialization be sure to use Load to load the .item file needed by the game. This should be the same .item file you used to specify drop items in the character editor. public class Items keep public for easy access public List Item items public Items items new List Item private string getElement string field ref XmlElement element string value try value field 0 .InnerText catch Exception return value public bool Load string filename try open the xml file XmlDocument doc new XmlDocument filename XmlNodeList list item foreach XmlNode node in list Looting Treasure 359 get next item in table XmlElement element XmlElement node Item item new Item store fields in new Item getElement name ref element getElement description ref element getElement dropimagefilename ref element i getElement invimagefilename ref element getElement category ref element i getElement weight ref element getElement value ref element getElement attacknumdice ref element getElement attackdie ref element getElement defense ref element getElement STR ref element getElement DEX ref element getElement STA ref element getElement INT ref element

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
12    61    2    29-03-2024
11    63    2    29-03-2024
Đã 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.