private void Move(string direction) { bool haveMoved = false; switch (battleState) { case BATTLESTATE.DEFAULT: break; case BATTLESTATE.CHOICES: haveMoved = choicesPanel.Move(direction); break; case BATTLESTATE.SONG: haveMoved = songPanel.Move(direction); break; case BATTLESTATE.PUNCH: haveMoved = punchPanel.Move(direction); break; default: break; } if (haveMoved) { if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_move); } } }
void Update() { if (Input.anyKeyDown) { RpgManager.Player.enabled = true; RpgManager.LoadScene("MainMenu", null); } }
private void Update() { if (!busy && Input.GetKeyDown(KeyCode.F9) && RpgManager.Instance) { StartCoroutine(endCoroutine(true)); //RpgManager.CurrentStory.StopMusic(); //RpgManager.UnloadPokemon(); } if (!busy) { float h = Input.GetAxisRaw("Horizontal"); float v = Input.GetAxisRaw("Vertical"); if (h > 0.5f) { Move("right"); } else if (h < -0.5f) { Move("left"); } if (v > 0.5f) { Move("up"); } else if (v < -0.5f) { Move("down"); } if (Input.GetButtonDown("Fire")) { if (waitForInput) { if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_move); } } waitForInput = false; Select(); } else if (Input.GetButtonDown("Back")) { if (waitForInput) { if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_move); } } waitForInput = false; Back(); } } }
/*private void Awake() * { * animator = GetComponent<Animator>(); * }*/ public override void Validate() { RpgManager.StopEndMusic(); isShowingHints = !isShowingHints; mainMenuStoryAnimator.SetBool("Hints", isShowingHints); menuController.enabled = !isShowingHints; mainMenuStoryAnimator.GetComponent <AudioSource>().volume = isShowingHints ? 0 : 1; }
private IEnumerator ennemyCoroutine() { battleState = BATTLESTATE.ENNEMYTURN; EnnemyAttack atk = ennemyAttacks.GetRandomAttack(); // Display text busy = waitForInput = true; smallTxt.Shutup(); bigTxt.Display(atk.label, true, DefaultCallback); while (busy) { yield return(null); } busy = true; if (RpgManager.Instance) { RpgManager.PlaySFX(atk.sfx); } yield return(new WaitForSeconds(1f)); // Play animations if (atk.damage > 0) { player.PlayAnim("Hit"); StartCoroutine(player.ModifyHpCoroutine(-atk.damage, DefaultCallback)); } else if (atk.heal > 0) { ennemy.PlayAnim("Hit"); StartCoroutine(ennemy.ModifyHpCoroutine(atk.heal, DefaultCallback)); } while (busy || waitForInput) { yield return(null); } if (player.Hp <= 0) { StartCoroutine(endCoroutine(false)); } else { busy = true; bigTxt.Shutup(); smallTxt.Display(BattleConsts.I.choiceText, false, DefaultCallback); while (busy) { yield return(null); } choicesPanel.gameObject.SetActive(true); battleState = BATTLESTATE.CHOICES; } }
private IEnumerator SelectButtonCoroutine() { story.StopMusic(); int index = RpgManager.Instance.GetGameOverCommentId(false, story.lastComment.Count); AudioClip clip = story.lastComment[index]; RpgManager.PlaySFX(sfx_Select); RpgManager.PlaySFX(clip); yield return(new WaitForSeconds(clip.length)); RpgManager.Player.Revive(); menuButtons[currentButtonId].Validate(); }
public virtual void Validate() { RpgManager.StopEndMusic(); switch (type) { case MenuButtonType.NewGame: RpgManager.LoadScene("NeuillyPlaisance", "Entrance"); RpgManager.Instance.gameState = RpgManager.GameState.Rpg; RpgManager.Data = new GameData(); RpgManager.Instance.dataDebug.SetData(RpgManager.Data); break; case MenuButtonType.Continue: RpgManager.Data = GameData.LoadFromFile(); RpgManager.Instance.dataDebug.SetData(RpgManager.Data); RpgManager.LoadScene(RpgManager.Data.scene, RpgManager.Data.place); break; case MenuButtonType.Hints: //FindObjectOfType<MainMenuStory>().GetComponent<Animator>().SetBool("Hints", true); break; case MenuButtonType.Quit: Application.Quit(); break; case MenuButtonType.BackToMenu: RpgManager.Player.EndTalk(); RpgManager.Instance.menu.gameObject.SetActive(false); RpgManager.Player.enabled = true; RpgManager.Instance.gameState = RpgManager.GameState.MainMenu; RpgManager.LoadScene("MainMenu", null); break; case MenuButtonType.BackToGame: RpgManager.Instance.ToggleMenu(); break; default: break; } }
private void Update() { if (Input.GetButtonDown("Vertical") || inputs.buttonDown || inputs.buttonUp) { RpgManager.PlaySFX(sfx_Move); menuButtons[currentButtonId].SetSelected(false); int increment = Input.GetAxis("Vertical") > 0 ? -1 : 1; for (int i = 0; i < menuButtons.Count; i++) { currentButtonId = Mathf.RoundToInt(Mathf.Repeat(currentButtonId + increment, menuButtons.Count)); if (menuButtons[currentButtonId].isEnabled) { break; } } menuButtons[currentButtonId].SetSelected(true); } else if (Input.GetButtonDown("Fire")) { SelectButton(); } }
private IEnumerator fightCoroutine(BattleChoice choice) { if (choice.currentPp <= 0) { battleState = BATTLESTATE.DEFAULT; songPanel.gameObject.SetActive(false); punchPanel.gameObject.SetActive(false); attackDescriptionPanel.SetActive(false); busy = waitForInput = true; smallTxt.Shutup(); bigTxt.Display("Plus de points de pouvoir !", true, DefaultCallback); while (busy || waitForInput) { yield return(null); } busy = true; bigTxt.Shutup(); smallTxt.Display(BattleConsts.I.choiceText, false, DefaultCallback); while (busy) { yield return(null); } choicesPanel.gameObject.SetActive(true); battleState = BATTLESTATE.CHOICES; yield break; } else { choice.currentPp--; } bool isSong = battleState == BATTLESTATE.SONG; battleState = BATTLESTATE.ATTACKSPLAY; choicesPanel.gameObject.SetActive(false); songPanel.gameObject.SetActive(false); punchPanel.gameObject.SetActive(false); attackDescriptionPanel.gameObject.SetActive(false); bool hasResult = !string.IsNullOrEmpty(choice.resultMessage); // Display text busy = waitForInput = true; smallTxt.Shutup(); bigTxt.Display(choice.message, !hasResult, DefaultCallback); while (busy) { yield return(null); } busy = true; float waitime = 1.0f; if (RpgManager.Instance && choice.sfx) { float oldvolume = RpgManager.CurrentStory.GetMusicVolume(); if (isSong) { RpgManager.CurrentStory.SetMusicVolume(0.3f * oldvolume); } waitime = Mathf.Max(choice.sfx.length, waitime); RpgManager.PlaySFX(choice.sfx); yield return(new WaitForSeconds(waitime)); if (RpgManager.Instance && choice.sfx) { RpgManager.CurrentStory.SetMusicVolume(oldvolume); } } else { yield return(new WaitForSeconds(waitime)); } // Play animations ennemy.PlayAnim("Hit"); StartCoroutine(ennemy.ModifyHpCoroutine(-choice.damage, DefaultCallback)); while (busy) { yield return(null); } // Display result if any if (hasResult) { busy = waitForInput = true; bigTxt.Display(choice.resultMessage, true, DefaultCallback); } while (busy || waitForInput) { yield return(null); } if (ennemy.Hp <= 0) { StartCoroutine(endCoroutine(true)); } else { StartCoroutine(ennemyCoroutine()); } }
private void Select() { switch (battleState) { case BATTLESTATE.DEFAULT: break; case BATTLESTATE.CHOICES: string selected = choicesPanel.GetSelectedItem().name; switch (selected) { case "song": battleState = BATTLESTATE.SONG; choicesPanel.gameObject.SetActive(false); songPanel.gameObject.SetActive(true); attackDescriptionPanel.SetActive(true); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; case "punch": battleState = BATTLESTATE.PUNCH; choicesPanel.gameObject.SetActive(false); punchPanel.gameObject.SetActive(true); attackDescriptionPanel.SetActive(true); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; case "bag": StartCoroutine(bagCoroutine()); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; case "flee": StartCoroutine(fleeCoroutine()); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; default: break; } break; case BATTLESTATE.SONG: StartCoroutine(fightCoroutine(songPanel.GetSelectedItem())); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; case BATTLESTATE.PUNCH: StartCoroutine(fightCoroutine(punchPanel.GetSelectedItem())); if (RpgManager.Instance) { RpgManager.PlaySFX(sfx_validate); } break; default: break; } }
private void Start() { gameManager = FindObjectOfType <RpgManager>(); }
protected virtual void SelectButton() { RpgManager.PlaySFX(sfx_Select); menuButtons[currentButtonId].Validate(); }