private void EquipmentModeInitialize() { leftItems = new List <Item>(); rightItems = new List <Item>(); leftPageItems = new List <Item>(); leftButtons = new List <Button>(); leftWindows = new List <Window>(); rightPageItems = new List <Item>(); rightButtons = new List <Button>(); rightWindows = new List <Window>(); mode = DepotModeType.equipment; foreach (Item i in playerItems) { if (i is WeaponItem || i is ProtectionItem || i is AccessaryItem) { leftItems.Add(i); } } foreach (Item i in equipments) { rightItems.Add(i); } leftPage = 1; rightPage = 1; leftMaxPage = (leftItems.Count) / 20 + 1; rightMaxPage = (rightItems.Count) / 20 + 1; LeftPage(1); RightPage(1); }
private void ConsumptionModeInitialize() { leftItems = new List <Item>(); rightItems = new List <Item>(); leftPageItems = new List <Item>(); leftButtons = new List <Button>(); leftWindows = new List <Window>(); rightPageItems = new List <Item>(); rightButtons = new List <Button>(); rightWindows = new List <Window>(); mode = DepotModeType.consumption; foreach (Item i in playerItems) { if (i is ConsumptionItem) { leftItems.Add(i); } } foreach (int i in consumptions.Keys) { rightItems.Add(itemManager.GetConsumption(i)); } leftPage = 1; rightPage = 1; leftMaxPage = (leftItems.Count) / 20 + 1; rightMaxPage = (rightItems.Count) / 20 + 1; LeftPage(1); RightPage(1); }
public void Initialize(SceneType scene) { endFlag = false; blurRate = 0.0f; mode = DepotModeType.select; playerItems = inventory.BagList(); equipments = inventory.EquipDepository(); consumptions = inventory.DepositoryItem(); itemManager.LoadAll(); Vector2 size = new Vector2(windowWidth / 2 - 128, 720 - 128); leftWindow = new Window(gameDevice, new Vector2(64, 64), size); leftWindow.Initialize(); rightWindow = new Window(gameDevice, new Vector2(windowWidth / 2 + 64, 64), size); rightWindow.Initialize(); messegeWindow = new Window(gameDevice, new Vector2(windowWidth / 2 - 160, windowHeight / 2 - 80), new Vector2(320, 160)); messegeWindow.Initialize(); backButton = new Button(new Vector2(0, windowHeight - 64), 64, 32); backWindow = new Window(gameDevice, new Vector2(0, windowHeight - 64), new Vector2(64, 32)); equipmentButton = new Button(new Vector2(windowWidth / 2 - 160, windowHeight / 2 + 80 + 32), 96, 32); consumptionButton = new Button(new Vector2(windowWidth / 2 + 160 - 64 - 32, windowHeight / 2 + 80 + 32), 96, 32); equipmentWindow = new Window(gameDevice, new Vector2(windowWidth / 2 - 160, windowHeight / 2 + 80 + 32), new Vector2(96, 32)); equipmentWindow.Initialize(); consumptionWindow = new Window(gameDevice, new Vector2(windowWidth / 2 + 160 - 64 - 32, windowHeight / 2 + 80 + 32), new Vector2(96, 32)); consumptionWindow.Initialize(); leftItems = new List <Item>(); rightItems = new List <Item>(); rightPageLeftWindow = new Window(gameDevice, new Vector2(windowWidth - windowWidth / 4 - 64 - 64, windowHeight - 96), new Vector2(64, 32)); rightPageLeftWindow.Initialize(); rightPageRightWindow = new Window(gameDevice, new Vector2(windowWidth - windowWidth / 4 + 64, windowHeight - 96), new Vector2(64, 32)); rightPageRightWindow.Initialize(); rightPageLeftButton = new Button(rightPageLeftWindow.GetOffsetPosition(), 64, 32); rightPageRightButton = new Button(rightPageRightWindow.GetOffsetPosition(), 64, 32); leftPageLeftWindow = new Window(gameDevice, new Vector2(windowWidth / 4 - 64 - 64, windowHeight - 96), new Vector2(64, 32)); leftPageLeftWindow.Initialize(); leftPageRightWindow = new Window(gameDevice, new Vector2(windowWidth / 4 + 64, windowHeight - 96), new Vector2(64, 32)); leftPageRightWindow.Initialize(); leftPageLeftButton = new Button(leftPageLeftWindow.GetOffsetPosition(), 64, 32); leftPageRightButton = new Button(leftPageRightWindow.GetOffsetPosition(), 64, 32); leftPageItems = new List <Item>(); leftButtons = new List <Button>(); leftWindows = new List <Window>(); rightPageItems = new List <Item>(); rightButtons = new List <Button>(); rightWindows = new List <Window>(); leftPage = 1; leftMaxPage = 1; rightPage = 1; rightMaxPage = 1; }
public Depot(IScene town, GameManager gameManager, GameDevice gameDevice) { this.gameDevice = gameDevice; this.gameManager = gameManager; renderer = gameDevice.Renderer; input = gameDevice.InputState; blurEffect = renderer.EffectManager.GetBlurEffect(); townScene = town; mode = DepotModeType.select; inventory = gameManager.PlayerItem; itemManager = new ItemManager(); windowWidth = Def.WindowDef.WINDOW_WIDTH; windowHeight = Def.WindowDef.WINDOW_HEIGHT; hintInfo = new ItemInfoUI(Vector2.Zero, gameManager, gameDevice); }
public void Update(GameTime gameTime) { UpdateBlurRate(); blurEffect.Update(blurRate); leftWindow.Update(); rightWindow.Update(); messegeWindow.Update(); equipmentWindow.Update(); consumptionWindow.Update(); rightPageRightWindow.Update(); rightPageLeftWindow.Update(); leftPageRightWindow.Update(); leftPageLeftWindow.Update(); foreach (Window w in leftWindows) { w.Update(); } foreach (Window w in rightWindows) { w.Update(); } backWindow.Update(); Point mousePos = new Point( (int)input.GetMousePosition().X, (int)input.GetMousePosition().Y); if (!backWindow.CurrentState() && !endFlag) { backWindow.Switch(); } //セレクト処理 if (mode == DepotModeType.select) { if (!messegeWindow.CurrentState()) { messegeWindow.Switch(); } if (!equipmentWindow.CurrentState()) { equipmentWindow.Switch(); } if (!consumptionWindow.CurrentState()) { consumptionWindow.Switch(); } if (leftWindow.CurrentState()) { leftWindow.Switch(); } if (rightWindow.CurrentState()) { rightWindow.Switch(); } if (equipmentButton.IsClick(mousePos) && input.IsLeftClick()) { mode = DepotModeType.equipment; EquipmentModeInitialize(); return; } if (consumptionButton.IsClick(mousePos) && input.IsLeftClick()) { mode = DepotModeType.consumption; ConsumptionModeInitialize(); return; } if (backButton.IsClick(mousePos) && input.IsLeftClick()) { mode = DepotModeType.end; endFlag = true; } if (leftPageLeftWindow.CurrentState()) { leftPageLeftWindow.Switch(); } if (leftPageRightWindow.CurrentState()) { leftPageRightWindow.Switch(); } if (rightPageLeftWindow.CurrentState()) { rightPageLeftWindow.Switch(); } if (rightPageRightWindow.CurrentState()) { rightPageRightWindow.Switch(); } return; } else if (mode != DepotModeType.end) //セレクト外共通処理 { if (messegeWindow.CurrentState()) { messegeWindow.Switch(); } if (equipmentWindow.CurrentState()) { equipmentWindow.Switch(); } if (consumptionWindow.CurrentState()) { consumptionWindow.Switch(); } if (!leftWindow.CurrentState()) { leftWindow.Switch(); } if (!rightWindow.CurrentState()) { rightWindow.Switch(); } inventory.BagItemCount(ref bagNowNum, ref bagMaxNum); inventory.DepositoryEquipCount(ref depotNowNum, ref depotMaxNum); //ページ関連 if (leftPage > leftMaxPage) { leftPage = leftMaxPage; LeftPage(leftPage); } if (rightPage > rightMaxPage) { rightPage = rightMaxPage; RightPage(rightPage); } //左側 if (leftPage > 1) { if (!leftPageLeftWindow.CurrentState()) { leftPageLeftWindow.Switch(); } if (leftPageLeftButton.IsClick(mousePos) && input.IsLeftClick()) { leftPage--; LeftPage(leftPage); } } else { if (leftPageLeftWindow.CurrentState()) { leftPageLeftWindow.Switch(); //消す } } if (leftPage < leftMaxPage) { if (!leftPageRightWindow.CurrentState()) { leftPageRightWindow.Switch(); } if (leftPageRightButton.IsClick(mousePos) && input.IsLeftClick()) { leftPage++; LeftPage(leftPage); } } else { if (leftPageRightWindow.CurrentState()) { leftPageRightWindow.Switch(); //消す } } //右側 if (rightPage > 1) { if (!rightPageLeftWindow.CurrentState()) { rightPageLeftWindow.Switch(); } if (rightPageLeftButton.IsClick(mousePos) && input.IsLeftClick()) { rightPage--; RightPage(rightPage); } } else { if (rightPageLeftWindow.CurrentState()) { rightPageLeftWindow.Switch(); //消す } } if (rightPage < rightMaxPage) { if (!rightPageRightWindow.CurrentState()) { rightPageRightWindow.Switch(); } if (rightPageRightButton.IsClick(mousePos) && input.IsLeftClick()) { rightPage++; RightPage(rightPage); } } else { if (rightPageRightWindow.CurrentState()) { rightPageRightWindow.Switch(); //消す } } isHintDraw = false; if (input.GetMousePosition().X + 35 + 416 > windowWidth) { hintInfo.Position = new Vector2(windowWidth - 416, input.GetMousePosition().Y + 50); } else { hintInfo.Position = input.GetMousePosition() + new Vector2(35, 50); } //メッセージ関連 isBagMax = false; isBagMaxMessaga = false; if (bagNowNum >= bagMaxNum) { isBagMax = true; } foreach (Button b in rightButtons) { if (b.IsClick(mousePos) && isBagMax) { isBagMaxMessaga = true; } } isDepotMax = false; isDepotMaxMessaga = false; if (depotNowNum >= depotMaxNum) { isDepotMax = true; } foreach (Button b in leftButtons) { if (b.IsClick(mousePos) && isDepotMax) { isDepotMaxMessaga = true; } } //戻るボタン if (backButton.IsClick(mousePos) && input.IsLeftClick()) { mode = DepotModeType.select; } } //装備品 if (mode == DepotModeType.equipment) { playerItems = inventory.BagList(); leftItems = new List <Item>(); foreach (Item i in playerItems) { if (i is WeaponItem || i is ProtectionItem || i is AccessaryItem) { leftItems.Add(i); } } rightItems = new List <Item>(); equipments = inventory.EquipDepository(); foreach (Item i in equipments) { rightItems.Add(i); } //バッグ側 for (int i = 0; i < leftButtons.Count; i++) { if (leftButtons[i].IsClick(mousePos)) { isHintDraw = true; hintItem = leftPageItems[i]; if (input.IsLeftClick() && !isDepotMax) { if (rightPageItems.Count < 20) { AddRightList(leftItems[i + (leftPage - 1) * 20]); } inventory.DepositEquip(inventory.BagItemIndex(leftItems[i + (leftPage - 1) * 20])); rightItems.Add(leftItems[i + (leftPage - 1) * 20]); RemoveLeftList(i); leftMaxPage = (leftItems.Count - 1) / 20 + 1; rightMaxPage = (rightItems.Count - 1) / 20 + 1; } } } //倉庫側 for (int i = 0; i < rightButtons.Count; i++) { if (rightButtons[i].IsClick(mousePos)) { isHintDraw = true; hintItem = rightPageItems[i]; if (input.IsLeftClick() && !isDepotMax) { if (leftPageItems.Count < 20) { AddLeftList(rightItems[i + (rightPage - 1) * 20]); } inventory.MoveDepositEquipToBag(inventory.DepositEquipIndex(rightItems[i + (rightPage - 1) * 20])); RemoveRightList(i); leftMaxPage = (leftItems.Count - 1) / 20 + 1; rightMaxPage = (rightItems.Count - 1) / 20 + 1; } } } } //消費アイテム if (mode == DepotModeType.consumption) { playerItems = inventory.BagList(); leftItems = new List <Item>(); foreach (Item item in playerItems) { if (item is ConsumptionItem) { leftItems.Add(item); } } consumptions = inventory.DepositoryItem(); rightItems = new List <Item>(); foreach (int id in consumptions.Keys) { rightItems.Add(itemManager.GetConsumption(id)); } //バッグ側 for (int i = 0; i < leftButtons.Count; i++) { if (leftButtons[i].IsClick(mousePos)) { isHintDraw = true; hintItem = leftPageItems[i]; if (input.IsLeftClick()) { inventory.DepositItem(inventory.BagItemIndex(leftItems[i + (leftPage - 1) * 20])); if (consumptions[leftItems[i + (leftPage - 1) * 20].GetItemID()] - 1 * ((ConsumptionItem)leftItems[i + (leftPage - 1) * 20]).GetStack() <= 0) { if (rightPageItems.Count < 20) { AddRightList(leftItems[i + (leftPage - 1) * 20]); } } rightItems.Add(leftItems[i + (leftPage - 1) * 20]); RemoveLeftList(i); leftMaxPage = (leftItems.Count - 1) / 20 + 1; rightMaxPage = (rightItems.Count - 1) / 20 + 1; } } } //倉庫側 for (int i = 0; i < rightButtons.Count; i++) { if (rightButtons[i].IsClick(mousePos)) { isHintDraw = true; hintItem = rightPageItems[i]; if (input.IsLeftClick()) { if (consumptions[rightItems[i + (rightPage - 1) * 20].GetItemID()] - 1 <= 0) { inventory.MoveDepositItemToBag(itemManager, rightItems[i + (rightPage - 1) * 20].GetItemID()); RemoveRightList(i + (rightPage - 1)); } else { inventory.MoveDepositItemToBag(itemManager, rightItems[i + (rightPage - 1) * 20].GetItemID()); } playerItems = inventory.BagList(); leftItems = new List <Item>(); foreach (Item item in playerItems) { if (item is ConsumptionItem) { leftItems.Add(item); } } LeftPage(leftPage); leftMaxPage = (leftItems.Count - 1) / 20 + 1; rightMaxPage = (rightItems.Count - 1) / 20 + 1; } } } } }