/// <summary> /// 店イベント終了時の初期化処理 /// </summary> private void InitSet() { this.currentScene = E_ShopScene.FirstSet; this.selectItemIndex = 0; this.isBought = new bool[4] { false, false, false, false }; }
public override void SquareEvent(DungeonManager dm) { switch (this.currentScene) { case E_ShopScene.FirstSet: Debug.Log("店イベント発生"); InitSet(); ChooseSoldItems(); dm.NeedAnnounce = true; this.currentScene = E_ShopScene.SelectItem; break; case E_ShopScene.SelectItem: if (!this.finishFirstSet) { this.currentScene = E_ShopScene.FirstSet; return; } if (dm.NeedAnnounce) { ShowSoldItem(dm); } InputSelectItem(dm); break; case E_ShopScene.BuyOrNot: if (dm.NeedAnnounce) { ShowBuyOrNot(dm); } InputBuyOrNot(dm); break; } if (Input.GetKeyDown(KeyCode.Backspace)) { Debug.Log("店を出た"); InitSet(); dm.ElapseTurn(); dm.MoveScene(E_DungeonScene.SelectAction); } }
private void InputBuyOrNot(DungeonManager dm) { if (Input.GetKeyDown(KeyCode.Y)) { //購入処理 if (selectItemIndex == 0) { dm.HaveDungeonActiveItems.Add(this.appearDungeonActiveItem); dm.AnnounceByText(this.appearDungeonActiveItem.EffectName + "を購入しました"); dm.HaveGold -= this.appearDungeonActiveItem.BuyPrice; } else if (selectItemIndex == 1) { dm.AddDungeonPassiveItem(this.appearDungeonPassiveItem); dm.AnnounceByText(this.appearDungeonPassiveItem.EffectName + "を購入しました"); dm.HaveGold -= this.appearDungeonPassiveItem.BuyPrice; } else if (selectItemIndex == 2) { dm.HaveBattleActiveItems.Add(this.appearBattleActiveItem); dm.AnnounceByText(this.appearBattleActiveItem.EffectName + "を購入しました"); dm.HaveGold -= this.appearBattleActiveItem.BuyPrice; } else { dm.HaveBattlePassiveItems.Add(this.appearBattlePassiveItem); dm.AnnounceByText(this.appearBattlePassiveItem.EffectName + "を購入しました"); dm.HaveGold -= this.appearBattlePassiveItem.BuyPrice; } this.isBought[selectItemIndex] = true; SetSelectItemIndex(dm); dm.NeedAnnounce = true; this.currentScene = E_ShopScene.SelectItem; } if (Input.GetKeyDown(KeyCode.N)) { dm.NeedAnnounce = true; this.currentScene = E_ShopScene.SelectItem; } }
/// <summary> /// プレイヤーの入力に応じて商品選択 /// </summary> /// <param name="dm">DungeonManager</param> private void InputSelectItem(DungeonManager dm) { if (Input.GetKeyDown(KeyCode.W)) { int count = 0; for (int i = this.selectItemIndex - 1; i != selectItemIndex; i--, count++) { if (i < 0) { i = this.isBought.Length - 1; } if (!this.isBought[i]) { this.selectItemIndex = i; break; } if (count > 10) { throw new System.Exception(); } } dm.NeedAnnounce = true; } if (Input.GetKeyDown(KeyCode.S)) { int count = 0; for (int i = this.selectItemIndex + 1; i != this.selectItemIndex; i++, count++) { if (i > this.isBought.Length - 1) { i = 0; } if (!this.isBought[i]) { this.selectItemIndex = i; break; } if (count > 10) { throw new System.Exception(); } } dm.NeedAnnounce = true; } if (Input.GetKeyDown(KeyCode.Return)) { if (selectItemIndex == 0) { if (this.appearDungeonActiveItem.BuyPrice > dm.HaveGold) { dm.AnnounceByText("所持Gが足りません"); dm.NeedAnnounce = true; return; } } else if (selectItemIndex == 1) { if (this.appearDungeonPassiveItem.BuyPrice > dm.HaveGold) { dm.AnnounceByText("所持Gが足りません"); dm.NeedAnnounce = true; return; } } else if (selectItemIndex == 2) { if (this.appearBattleActiveItem.BuyPrice > dm.HaveGold) { dm.AnnounceByText("所持Gが足りません"); dm.NeedAnnounce = true; return; } } else { if (this.appearBattlePassiveItem.BuyPrice > dm.HaveGold) { dm.AnnounceByText("所持Gが足りません"); dm.NeedAnnounce = true; return; } } dm.NeedAnnounce = true; this.currentScene = E_ShopScene.BuyOrNot; } }