Ejemplo n.º 1
0
 public static void SilenceNarrator()
 {
     if (CurrentNarration != null)
     {
         CurrentNarration.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
         CurrentNarration.release();
         CurrentNarration = null;
         NarrationQueue.Clear();
     }
 }
Ejemplo n.º 2
0
    public static void PlayStatueAudioEntry(string id)
    {
        if (CurrentNarration != null && NarrationQueue.Count > 0)
        {
            return;
        }

        var narrationInstanse = RuntimeManager.CreateInstance(id);

        if (narrationInstanse != null)
        {
            NarrationQueue.Add(narrationInstanse);
        }
    }
Ejemplo n.º 3
0
 private void Update()
 {
     if (CurrentNarration == null)
     {
         if (NarrationQueue.Count > 0)
         {
             CurrentNarration = NarrationQueue[0];
             CurrentNarration.start();
         }
     }
     else
     {
         CurrentNarration.getPlaybackState(out narrationState);
         if (narrationState == FMOD.Studio.PLAYBACK_STATE.STOPPED || narrationState == FMOD.Studio.PLAYBACK_STATE.STOPPING)
         {
             CurrentNarration.release();
             NarrationQueue.Remove(CurrentNarration);
             CurrentNarration = null;
         }
     }
 }
Ejemplo n.º 4
0
    public static void ExecuteNarration(string id, NarrationPlace place, params string[] tags)
    {
        if (!DarkestDungeonManager.Data.Narration.ContainsKey(id))
        {
            return;
        }

        NarrationEntry narrationEntry = DarkestDungeonManager.Data.Narration[id];

        if (!RandomSolver.CheckSuccess(narrationEntry.Chance))
        {
            return;
        }

        var possibleEvents = narrationEntry.AudioEvents.FindAll(audioEvent => audioEvent.IsPossible(place, tags));

        if (possibleEvents.Count == 0)
        {
            return;
        }

        float maxPriority = possibleEvents.Max(audio => audio.Priority);

        possibleEvents.RemoveAll(lowPriorityEvent => lowPriorityEvent.Priority < maxPriority);

        NarrationAudioEvent narrationEvent = id == "combat_start" ?
                                             possibleEvents[0] : possibleEvents[RandomSolver.Next(possibleEvents.Count)];

        if (narrationEvent.QueueOnlyOnEmpty && NarrationQueue.Count > 0)
        {
            return;
        }

        if (id == "town_visit_start")
        {
            for (int i = 0; i < 3; i++)
            {
                if (RandomSolver.CheckSuccess(narrationEvent.Chance))
                {
                    break;
                }
                else
                {
                    narrationEvent = possibleEvents[RandomSolver.Next(possibleEvents.Count)];
                }

                if (i == 2)
                {
                    return;
                }
            }
        }
        else if (!RandomSolver.CheckSuccess(narrationEvent.Chance))
        {
            return;
        }

        var narrationInstanse = RuntimeManager.CreateInstance("event:" + narrationEvent.AudioEvent);

        if (narrationInstanse != null)
        {
            NarrationQueue.Add(narrationInstanse);
        }

        switch (place)
        {
        case NarrationPlace.Campaign:
            if (narrationEvent.MaxCampaignOccurrences > 0)
            {
                if (!DarkestDungeonManager.Campaign.NarrationCampaignInfo.ContainsKey(narrationEvent.AudioEvent))
                {
                    DarkestDungeonManager.Campaign.NarrationCampaignInfo.Add(narrationEvent.AudioEvent, 0);
                }

                DarkestDungeonManager.Campaign.NarrationCampaignInfo[narrationEvent.AudioEvent]++;
            }
            break;

        case NarrationPlace.Raid:
            if (narrationEvent.MaxRaidOccurrences > 0)
            {
                if (!DarkestDungeonManager.Campaign.NarrationRaidInfo.ContainsKey(narrationEvent.AudioEvent))
                {
                    DarkestDungeonManager.Campaign.NarrationRaidInfo.Add(narrationEvent.AudioEvent, 0);
                }

                DarkestDungeonManager.Campaign.NarrationRaidInfo[narrationEvent.AudioEvent]++;
            }
            goto case NarrationPlace.Campaign;

        case NarrationPlace.Town:
            if (narrationEvent.MaxTownVisitOccurrences > 0)
            {
                if (!DarkestDungeonManager.Campaign.NarrationTownInfo.ContainsKey(narrationEvent.AudioEvent))
                {
                    DarkestDungeonManager.Campaign.NarrationTownInfo.Add(narrationEvent.AudioEvent, 0);
                }

                DarkestDungeonManager.Campaign.NarrationTownInfo[narrationEvent.AudioEvent]++;
            }
            goto case NarrationPlace.Campaign;
        }
    }