public void Update(GameTime gametime) { KeyboardState keyboardState = Keyboard.GetState(); if (Equipmentmenuflag == true) { if (keyboardState.IsKeyDown(Keys.Right)) { if (playerindex >= RAM.PlayerList.Count - 1) { playerindex = 0; } else { playerindex++; } } else if (keyboardState.IsKeyDown(Keys.Left)) { if (playerindex <= 0) { playerindex = RAM.PlayerList.Count - 1; } else { playerindex--; } } if (keyboardState.IsKeyDown(Keys.Down)) { if (pointerpoint >= equipment.Length - 1) { pointerpoint = 0; } else { pointerpoint++; } } else if (keyboardState.IsKeyDown(Keys.Up)) { if (pointerpoint <= 0) { pointerpoint = equipment.Length - 1; } else { pointerpoint--; } } else if (keyboardState.IsKeyDown(Keys.Enter)) { Equipmenttype = pointerpoint; Equipmentmenuflag = false; } statsnum[0] = RAM.PlayerList[playerindex].Level; statsnum[1] = RAM.PlayerList[playerindex].MaxHP; statsnum[2] = RAM.PlayerList[playerindex].MaxMP; statsnum[3] = RAM.PlayerList[playerindex].MaxSP; statsnum[4] = RAM.PlayerList[playerindex].ATK; statsnum[5] = RAM.PlayerList[playerindex].DEF; statsnum[6] = RAM.PlayerList[playerindex].INT; statsnum[7] = RAM.PlayerList[playerindex].RES; statsnum[8] = RAM.PlayerList[playerindex].SPD; statsnum[9] = RAM.PlayerList[playerindex].EVD; Equipment[0] = RAM.PlayerList[playerindex].Weaponitem; Equipment[1] = RAM.PlayerList[playerindex].Helmetitem; Equipment[2] = RAM.PlayerList[playerindex].Armoritem; Equipment[3] = RAM.PlayerList[playerindex].Bracersitem; Equipment[4] = RAM.PlayerList[playerindex].Shielditem; Equipment[5] = RAM.PlayerList[playerindex].Greavesitem; Equipment[6] = RAM.PlayerList[playerindex].Accessoryitem1; Equipment[7] = RAM.PlayerList[playerindex].Accessoryitem2; Equipment[8] = RAM.PlayerList[playerindex].Accessoryitem3; Equipment[9] = RAM.PlayerList[playerindex].Accessoryitem4; pointer.SetPosition(new Vector2(680, 320 + (pointerpoint * 30))); } else { if (keyboardState.IsKeyDown(Keys.Down)) { if (ListPoint >= EquipmentItemList.Count - 1) { ListPoint = 0; } else { ListPoint++; } } else if (keyboardState.IsKeyDown(Keys.Up)) { if (ListPoint <= 0) { ListPoint = EquipmentItemList.Count - 1; } else { ListPoint--; } } else if (keyboardState.IsKeyDown(Keys.Escape)) { Equipmentmenuflag = true; } else if (keyboardState.IsKeyDown(Keys.Enter)) { for (int x = 0; x <= RAM.GetItemListCount(); x++) { if (RAM.PlayerList[playerindex].Weaponitem == RAM.MasterItemList[x]) { RAM.MasterItemList.Remove(RAM.MasterItemList[x]); } } if (0 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Weaponitem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((WeaponItem)EquipmentItemList[ListPoint])); } else if (1 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Helmetitem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((HelmetItem)EquipmentItemList[ListPoint])); } else if (2 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Armoritem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((ArmorItem)EquipmentItemList[ListPoint])); } else if (3 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Bracersitem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((BracersItem)EquipmentItemList[ListPoint])); } else if (4 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Shielditem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((ShieldItem)EquipmentItemList[ListPoint])); } else if (5 == Equipmenttype) { RAM.MasterItemList.Add(RAM.PlayerList[playerindex].Greavesitem); ((TestPlayer)RAM.GetPlayer(playerindex)).SetEquipment(((GreavesItem)EquipmentItemList[ListPoint])); } ListPoint = 0; Equipmentmenuflag = true; } // EquipmentItemList = RefeshList(EquipmentItemList); if (0 == Equipmenttype) { //EquipmentItemList.Add(new WeaponItem()); } else if (1 == Equipmenttype) { //EquipmentItemList.Add(new HelmetItem()); } else if (2 == Equipmenttype) { //EquipmentItemList.Add(new ArmorItem()); } else if (3 == Equipmenttype) { //EquipmentItemList.Add(new BracersItem()); } else if (4 == Equipmenttype) { // EquipmentItemList.Add(new ShieldItem()); } else if (5 == Equipmenttype) { //EquipmentItemList.Add(new GreavesItem()); } for (int x = 0; x <= RAM.GetItemListCount(); x++) { if (2 == RAM.GetItem(x).type) // 2 == Equipment Items { //if (((EquipmentItems)RAM.GetItem(x)).EquipmentType == Equipmenttype) // { // if (RAM.GetItem(x).count >= 1) // { // EquipmentItemList.Add(RAM.MasterItemList[x]); // } // } } } pointer.SetPosition(new Vector2(680, 320 + (ListPoint * 30))); } }
public void Update(GameTime gameTime) { KeyboardState keyboardState = Keyboard.GetState(); maxshowingline = ItemList.Count; time += (float)gameTime.ElapsedGameTime.TotalMilliseconds; ////////////////////////////////////////////////////////////// if ((maxshowingline % ITEMSPERROW) >= 1) { maxshowingline /= ITEMSPERROW; maxshowingline++; } else { maxshowingline /= ITEMSPERROW; } ItemTypeSelected = ItemTypeNum; if (ItemType == true) { showingline = 0; point.X = 0; point.Y = 0; MasterPointY = 0; itemnum = 0; } px = (int)point.X; py = MasterPointY * 3; ////////////////////////////////////////////////////////////// if (menu is PlayerSelectionMenu) { if (((PlayerSelectionMenu)menu).GetSelectedItem().count == 0) { menu = null; } } if (menu == null) { if (keyboardState.IsKeyDown(Keys.Enter)) { if (time >= 150) { time = 0; if (ItemType == true) { ItemType = false; } else { if (px >= 0 && py >= 0) { if (ItemList.Count > px + py) { switch (ItemList[px + py].type) { case 1: { menu = new PlayerSelectionMenu(ItemList[px + py]); MenuFlag = true; break; } } } } } } } else if (keyboardState.IsKeyDown(Keys.Escape)) { ItemType = true; } else if (keyboardState.IsKeyDown(Keys.Right)) { if (ItemType == false) { if (point.X <= 1) { point.X++; itemnum += 1; } else { if (point.Y == LINE_COUNT_OF_CAMERA_VEIW && (showingline / 3) + LINE_COUNT_OF_CAMERA_VEIW <= maxshowingline) { point.X = 0; showingline += ITEMSPERROW; itemnum += 1; MasterPointY++; } else if (point.Y != LINE_COUNT_OF_CAMERA_VEIW) { point.Y++; MasterPointY++; point.X = 0; itemnum += 1; } } } else { if (ItemTypeNum == 5) { ItemTypeNum = 0; } else { ItemTypeNum++; } } } else if (keyboardState.IsKeyDown(Keys.Left)) { if (ItemType == false) { if (point.X >= 1) { point.X--; itemnum -= 1; } else { if (point.Y == 0) { point.X = 2; MasterPointY--; showingline -= ITEMSPERROW; itemnum -= 1; if (MasterPointY <= 0 && point.Y == 0) { point.X = 0; point.Y = 0; MasterPointY = 0; showingline = 0; maxshowingline = 0; } } else { point.Y--; MasterPointY--; point.X = 2; itemnum -= 1; } } } else { if (ItemTypeNum <= 0) { ItemTypeNum = 5; } else { ItemTypeNum--; } } } else if (keyboardState.IsKeyDown(Keys.Down)) { if (ItemType == false) { if (point.Y >= LINE_COUNT_OF_CAMERA_VEIW) { if (point.Y != LINE_COUNT_OF_CAMERA_VEIW) { point.Y = 0; MasterPointY = 0; } else { if ((showingline / 3) + LINE_COUNT_OF_CAMERA_VEIW <= maxshowingline) { showingline += ITEMSPERROW; itemnum += ITEMSPERROW; MasterPointY++; } } } else { point.Y++; MasterPointY++; itemnum += ITEMSPERROW; } } } else if (keyboardState.IsKeyDown(Keys.Up)) { if (point.Y <= 0) { if (showingline <= 0) { } else { showingline -= ITEMSPERROW; itemnum -= ITEMSPERROW; MasterPointY--; } } else { point.Y--; MasterPointY--; itemnum -= ITEMSPERROW; } } ////////////////////////////////////////////////////////////// for (int x = 0; x <= RAM.GetItemListCount(); x++) { if (RAM.MasterItemList[x].count == 0) { for (int z = 0; z <= ItemList.Count - 1; z++) { if (ItemList[z].name == RAM.MasterItemList[z].name) { RAM.MasterItemList.Remove(RAM.MasterItemList[x]); ItemList.Remove(ItemList[z]); } } } for (int y = 0; y <= ItemList.Count - 1; y++) { if (ItemList[y].name == RAM.MasterItemList[x].name) { RAM.MasterItemList[x] = ItemList[y]; ItemList.Remove(ItemList[y]); } } } if (ItemTypeSelected == 0) { for (int x = 0; x <= RAM.GetItemListCount(); x++) { if (RAM.GetItem(x).count >= 1) { ItemList.Add(RAM.GetItem(x)); } } } else { for (int x = 0; x <= RAM.GetItemListCount(); x++) { if (ItemTypeSelected == RAM.GetItem(x).type) { if (RAM.GetItem(x).count >= 1) { ItemList.Add(RAM.GetItem(x)); } } } } ///////////////////////////////////////////////////////////// } else { if (keyboardState.IsKeyDown(Keys.Escape)) { if (time >= 150) { time = 0; menu = null; MenuFlag = false; } } } //////////////////////////////////////////////////////////////// if (ItemType == false) { pointer.SetPosition(new Vector2(218 + (point.X * 285), 84 + (point.Y * 30))); } else { pointer.SetPosition(new Vector2((ItemTypeNum * 214), 60)); } ///////////////////////////////////////////////////////////////// if (menu is PlayerSelectionMenu) { ((PlayerSelectionMenu)menu).Update(gameTime); } }