public void LoadScreen(string screenName) { Initialize(); screenName = screenName.ToLower(); ClearScreen(); if (!screens.ContainsKey(screenName)) { Debug.LogError("Story Screen named [" + screenName + "] was not found!"); return; } currentScreen = screens[screenName]; StoryManager.MarkStoryAsRead(screenName); isScreenFinished = false; isFinished = false; Background.sprite = currentScreen.BackgroundImage != null ? currentScreen.BackgroundImage : StoryManager.Instance.DefaultBackground; if (currentScreen.Music != null) { FMODManager.Play(currentScreen.Music.Value); } else if (currentScreen.StopMusic) { FMODManager.StopMusic(); } gameObject.SetActive(true); }
private void Awake() { DontDestroyOnLoad(this); GameEntity.Spawn += OnEntitySpawn; #if ENABLE_FMOD m_SoundManager = Instantiate(m_SoundManagerPrefab); #endif }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // NOTE: You HAVE TO init fmod in the Initialize(). // Otherwise, it may not work on some platforms. FMODManager.Init(FMODMode.CoreAndStudio, "Content"); //FMODManager.Init(FMODMode.Core, "Content"); // Use this if you don't want Studio functionality. UIController.Init(GraphicsDevice); SceneController.ChangeScene(new DemoSelectorScene()); base.Initialize(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { FMODManager.Update(); UIController.Update(); SceneController.Update(); if ( GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) ) { Exit(); } base.Update(gameTime); }
protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } FMODManager.Update(); Input.Update(gameTime); if (Input.IsKeyPressed(Keys.F11)) { ScreenManager.ToggleFullScreen(); } if (Input.IsKeyPressed(Keys.F4)) { DebugMode = !DebugMode; } _currentScene?.Update(gameTime); base.Update(gameTime); }
void Update() { if (isFinished) { return; } MoveBackground(); if (!isScreenFinished && !paused) { var SecondsPerPart = 1f / StoryManager.Instance.CharsPerSecond; bool isTimeForNewChar = Time.time - LastPartTime - LastPartDelay > SecondsPerPart; while (isFastingForward || isTimeForNewChar) { char nextChar = currentScreen.Dialog[currBit]; int lastDialogCharIndex = (currentScreen.Dialog.Length - 1); //Handle command if (nextChar == '[') { while (nextChar == '[') { //found a command, don't count this char for typing //try to get all character until finding a ']' to end the command List <char> commandChars = new List <char>(); currBit++; bool foundCommandEnd = false; for (; currBit <= lastDialogCharIndex; currBit++) { nextChar = currentScreen.Dialog[currBit]; if (nextChar == ']') { foundCommandEnd = true; //skip ']' and set the char after it as the next char if (currBit < lastDialogCharIndex) { currBit++; nextChar = currentScreen.Dialog[currBit]; } else { //Last char in dialog was a ']' //no need to type anymore. isScreenFinished = true; } break; } else { commandChars.Add(currentScreen.Dialog[currBit]); } } if (!foundCommandEnd) { throw new System.InvalidOperationException("Invalid dialog syntx! command was opened with a [ character, but never closed with a ] character."); } var commandParts = new string(commandChars.ToArray()) .Split(':') .Select(x => x.Trim().ToLower()) .Where(x => x != string.Empty) .ToArray(); var result = RunCommand(commandParts); if (isScreenFinished || paused || result.IsStopping) { return; } } } else //handle next char { //skip sounds if fasting forward if (!isFastingForward) { FMODClip[] clipsSource; switch (nextChar) { case ' ': case '\n': case '\t': case '\r': clipsSource = null; LastPartDelay = 0f; break; case ',': clipsSource = currentCharacterSound.RandomizedBits; LastPartDelay = StoryManager.Instance.CommaDelay; break; case '.': clipsSource = currentCharacterSound.RandomizedBits; LastPartDelay = StoryManager.Instance.PeriodDelay; break; case '?': if (currentCharacterSound.AskBits != null && currentCharacterSound.AskBits.Length > 0) { clipsSource = currentCharacterSound.AskBits; } else { clipsSource = currentCharacterSound.RandomizedBits; } LastPartDelay = StoryManager.Instance.PeriodDelay; break; case '!': if (currentCharacterSound.SayBits != null && currentCharacterSound.SayBits.Length > 0) { clipsSource = currentCharacterSound.SayBits; } else { clipsSource = currentCharacterSound.RandomizedBits; } LastPartDelay = StoryManager.Instance.PeriodDelay; break; default: clipsSource = currentCharacterSound.RandomizedBits; LastPartDelay = 0f; break; } if (clipsSource != null && clipsSource.Length > 0) { FMODManager.Play(clipsSource[Random.Range(0, clipsSource.Length - 1)]); } } //DialogTextOld.text += nextChar; DialogText.text += nextChar; currBit++; LastPartTime = Time.time; } //stop loop //if we're fasting forward and the dialog was not paused, continue loop isTimeForNewChar = false; if (paused) { isFastingForward = false; } } } }
/// <summary> /// Awake del componente /// </summary> private void Awake() { _instance = this; _runningSounds = new Dictionary<string, FMOD.Studio.EventInstance>(); }
protected override void Initialize() { FMODManager.Init(FMODMode.CoreAndStudio, "Content/FMOD/FMOD Project"); base.Initialize(); }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { FMODManager.Unload(); }