Ejemplo n.º 1
0
    // Trigger next event in stack
    public void TriggerEvent()
    {
        Game game = Game.Get();

        // First check if things need to be added to the queue at end round
        if (game.roundControl.CheckNewRound())
        {
            return;
        }

        // No events to trigger
        if (eventStack.Count == 0)
        {
            return;
        }

        // Get the next event
        Event e = eventStack.Pop();

        currentEvent = e;

        // Move to another quest
        if (e is StartQuestEvent)
        {
            // This loads the game
            game.quest.ChangeQuest((e as StartQuestEvent).name);
            return;
        }

        // Event may have been disabled since added
        if (e.Disabled())
        {
            currentEvent = null;
            TriggerEvent();
            return;
        }

        // Play audio
        if (game.cd.TryGet(e.qEvent.audio, out AudioData audioData))
        {
            game.audioControl.Play(audioData.file);
        }
        else if (e.qEvent.audio.Length > 0)
        {
            game.audioControl.Play(Quest.FindLocalisedMultimediaFile(e.qEvent.audio, Path.GetDirectoryName(game.quest.qd.questPath)));
        }

        // Set Music
        if (e.qEvent.music.Count > 0)
        {
            List <string> music = new List <string>();
            foreach (string s in e.qEvent.music)
            {
                if (game.cd.TryGet(s, out AudioData musicData))
                {
                    music.Add(musicData.file);
                }
                else
                {
                    music.Add(Quest.FindLocalisedMultimediaFile(s, Path.GetDirectoryName(game.quest.qd.questPath)));
                }
            }
            game.audioControl.PlayMusic(music);
            if (music.Count > 0)
            {
                game.quest.music = new List <string>(e.qEvent.music);
            }
        }

        // Perform var operations
        game.quest.vars.Perform(e.qEvent.operations);
        // Update morale change
        if (game.gameType is D2EGameType)
        {
            game.quest.AdjustMorale(0);
        }
        if (game.quest.vars.GetValue("$restock") == 1)
        {
            game.quest.GenerateItemSelection();
        }

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG))
        {
            UnityEngine.Object.Destroy(go);
        }

        // If this is a monster event then add the monster group
        if (e is MonsterEvent)
        {
            MonsterEvent qe = (MonsterEvent)e;

            qe.MonsterEventSelection();

            // Is this type new?
            Quest.Monster oldMonster = null;
            foreach (Quest.Monster m in game.quest.monsters)
            {
                if (m.monsterData.sectionName.Equals(qe.cMonster.sectionName))
                {
                    // Matched existing monster
                    oldMonster = m;
                }
            }

            // Add the new type
            if (!game.gameType.MonstersGrouped() || oldMonster == null)
            {
                var monster = new Quest.Monster(qe);
                game.quest.monsters.Add(monster);
                game.monsterCanvas.UpdateList();
                // Update monster var
                game.quest.vars.SetValue("#monsters", game.quest.monsters.Count);
            }
            // There is an existing group, but now it is unique
            else if (qe.qMonster.unique)
            {
                oldMonster.unique      = true;
                oldMonster.uniqueText  = qe.qMonster.uniqueText;
                oldMonster.uniqueTitle = qe.GetUniqueTitle();
                oldMonster.healthMod   = Mathf.RoundToInt(qe.qMonster.uniqueHealthBase + (Game.Get().quest.GetHeroCount() * qe.qMonster.uniqueHealthHero));
            }

            // Display the location(s)
            if (qe.qEvent.locationSpecified && e.qEvent.display)
            {
                game.tokenBoard.AddMonster(qe);
            }
        }

        // Highlight a space on the board
        if (e.qEvent.highlight)
        {
            game.tokenBoard.AddHighlight(e.qEvent);
        }

        // Is this a shop?
        List <string> itemList = new List <string>();

        foreach (string s in e.qEvent.addComponents)
        {
            if (s.IndexOf("QItem") == 0)
            {
                // Fix #998
                if (game.gameType.TypeName() == "MoM" && itemList.Count == 1)
                {
                    ValkyrieDebug.Log("WARNING: only one QItem can be used in event " + e.qEvent.sectionName + ", ignoring other items");
                    break;
                }
                itemList.Add(s);
            }
        }
        // Add board components
        game.quest.Add(e.qEvent.addComponents, itemList.Count > 1);
        // Remove board components
        game.quest.Remove(e.qEvent.removeComponents);

        // Move camera
        if (e.qEvent.locationSpecified && !(e.qEvent is QuestData.UI))
        {
            CameraController.SetCamera(e.qEvent.location);
        }

        if (e.qEvent is QuestData.Puzzle)
        {
            QuestData.Puzzle p = e.qEvent as QuestData.Puzzle;
            if (p.puzzleClass.Equals("slide"))
            {
                new PuzzleSlideWindow(e);
            }
            if (p.puzzleClass.Equals("code"))
            {
                new PuzzleCodeWindow(e);
            }
            if (p.puzzleClass.Equals("image"))
            {
                new PuzzleImageWindow(e);
            }
            if (p.puzzleClass.Equals("tower"))
            {
                new PuzzleTowerWindow(e);
            }
            return;
        }

        // Set camera limits
        if (e.qEvent.minCam)
        {
            CameraController.SetCameraMin(e.qEvent.location);
        }
        if (e.qEvent.maxCam)
        {
            CameraController.SetCameraMax(e.qEvent.location);
        }

        // Is this a shop?
        if (itemList.Count > 1 && !game.quest.boardItems.ContainsKey("#shop"))
        {
            game.quest.boardItems.Add("#shop", new ShopInterface(itemList, Game.Get(), e.qEvent.sectionName));
            game.quest.ordered_boardItems.Add("#shop");
        }
        else if (!e.qEvent.display)
        {
            // Only raise dialog if there is text, otherwise auto confirm

            var firstEnabledButtonIndex = e.qEvent.buttons
                                          .TakeWhile(b => !IsButtonEnabled(b, game.quest.vars))
                                          .Count();
            EndEvent(firstEnabledButtonIndex);
        }
        else
        {
            if (monsterImage != null)
            {
                MonsterDialogMoM.DrawMonster(monsterImage, true);
                if (monsterHealth)
                {
                }
            }
            new DialogWindow(e);
        }
    }
Ejemplo n.º 2
0
    // Trigger next event in stack
    public void TriggerEvent()
    {
        // First check if things need to be added to the queue at end round
        Game.Get().roundControl.CheckNewRound();

        // No events to trigger
        if (eventStack.Count == 0)
        {
            return;
        }

        // Get the next event
        Event e = eventStack.Pop();

        currentEvent = e;

        // Event may have been disabled since added
        if (e.Disabled())
        {
            return;
        }

        // Perform var operations
        game.quest.vars.Perform(e.qEvent.operations);

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
        {
            Object.Destroy(go);
        }

        // If this is a monster event then add the monster group
        if (e is MonsterEvent)
        {
            MonsterEvent qe = (MonsterEvent)e;

            // Is this type new?
            Quest.Monster oldMonster = null;
            foreach (Quest.Monster m in game.quest.monsters)
            {
                if (m.monsterData.sectionName.Equals(qe.cMonster.sectionName))
                {
                    // Matched existing monster
                    oldMonster = m;
                }
            }

            // Add the new type
            if (!game.gameType.MonstersGrouped() || oldMonster == null)
            {
                game.quest.monsters.Add(new Quest.Monster(qe));
                game.monsterCanvas.UpdateList();
                // Update monster var
                game.quest.vars.SetValue("#monsters", game.quest.monsters.Count);
            }
            // There is an existing group, but now it is unique
            else if (qe.qMonster.unique)
            {
                oldMonster.unique      = true;
                oldMonster.uniqueText  = qe.qMonster.uniqueText;
                oldMonster.uniqueTitle = qe.GetUniqueTitle();
            }

            // Display the location(s)
            if (qe.qEvent.locationSpecified && e.GetText().Length > 0)
            {
                game.tokenBoard.AddMonster(qe);
            }
        }

        // Highlight a space on the board
        if (e.qEvent.highlight)
        {
            game.tokenBoard.AddHighlight(e.qEvent);
        }

        // Add board components
        game.quest.Add(e.qEvent.addComponents);
        // Remove board components
        game.quest.Remove(e.qEvent.removeComponents);

        // Add delayed events
        foreach (QuestData.Event.DelayedEvent de in e.qEvent.delayedEvents)
        {
            game.quest.delayedEvents.Add(new QuestData.Event.DelayedEvent(de.delay + game.quest.round, de.eventName));
        }

        // Move camera
        if (e.qEvent.locationSpecified)
        {
            CameraController.SetCamera(e.qEvent.location);
        }

        if (e.qEvent is QuestData.Puzzle)
        {
            QuestData.Puzzle p = e.qEvent as QuestData.Puzzle;
            if (p.puzzleClass.Equals("slide"))
            {
                new PuzzleSlideWindow(e);
            }
            if (p.puzzleClass.Equals("code"))
            {
                new PuzzleCodeWindow(e);
            }
            if (p.puzzleClass.Equals("image"))
            {
                new PuzzleImageWindow(e);
            }
            return;
        }

        // Set camera limits
        if (e.qEvent.minCam)
        {
            CameraController.SetCameraMin(e.qEvent.location);
        }
        if (e.qEvent.maxCam)
        {
            CameraController.SetCameraMax(e.qEvent.location);
        }

        // Only raise dialog if there is text, otherwise auto confirm
        if (e.GetText().Length == 0)
        {
            EndEvent();
        }
        else
        {
            new DialogWindow(e);
        }
    }
Ejemplo n.º 3
0
    public void TriggerEvent()
    {
        RoundHelper.CheckNewRound();

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

        Event e = eventStack.Pop();

        currentEvent = e;

        // Event may have been disabled since added
        if (e.Disabled())
        {
            return;
        }

        // Add set flags
        foreach (string s in e.qEvent.setFlags)
        {
            Debug.Log("Notice: Setting quest flag: " + s + System.Environment.NewLine);
            game.quest.flags.Add(s);
        }

        // Remove clear flags
        foreach (string s in e.qEvent.clearFlags)
        {
            Debug.Log("Notice: Clearing quest flag: " + s + System.Environment.NewLine);
            game.quest.flags.Remove(s);
        }

        // If a dialog window is open we force it closed (this shouldn't happen)
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
        {
            Object.Destroy(go);
        }

        // If this is a monster event then add the monster group
        if (e is MonsterEvent)
        {
            // Set monster tag if not already
            game.quest.flags.Add("#monsters");

            MonsterEvent qe = (MonsterEvent)e;

            // Is this type new?
            Quest.Monster oldMonster = null;
            foreach (Quest.Monster m in game.quest.monsters)
            {
                if (m.monsterData.name.Equals(qe.cMonster.name))
                {
                    oldMonster = m;
                }
            }
            // Add the new type
            if (oldMonster == null)
            {
                game.quest.monsters.Add(new Quest.Monster(qe));
                game.monsterCanvas.UpdateList();
            }
            // There is an existing tpye, but now it is unique
            else if (qe.qMonster.unique)
            {
                oldMonster.unique      = true;
                oldMonster.uniqueText  = qe.qMonster.uniqueText;
                oldMonster.uniqueTitle = qe.GetUniqueTitle();
            }

            // Display the location
            game.tokenBoard.AddMonster(qe);
        }

        if (e.qEvent.highlight)
        {
            game.tokenBoard.AddHighlight(e.qEvent);
        }

        game.quest.Add(e.qEvent.addComponents);
        game.quest.Remove(e.qEvent.removeComponents);
        game.quest.threat += e.qEvent.threat;
        if (e.qEvent.absoluteThreat)
        {
            if (e.qEvent.threat != 0)
            {
                Debug.Log("Setting threat to: " + e.qEvent.threat + System.Environment.NewLine);
            }
            game.quest.threat = e.qEvent.threat;
        }
        else if (e.qEvent.threat != 0)
        {
            Debug.Log("Changing threat by: " + e.qEvent.threat + System.Environment.NewLine);
        }

        foreach (QuestData.Event.DelayedEvent de in e.qEvent.delayedEvents)
        {
            game.quest.delayedEvents.Add(new QuestData.Event.DelayedEvent(de.delay + game.quest.round, de.eventName));
        }

        if (e.qEvent.locationSpecified)
        {
            CameraController.SetCamera(e.qEvent.location);
        }

        // Only raise dialog if there is text, otherwise auto confirm
        if (e.GetText().Length == 0)
        {
            EndEvent();
        }
        else
        {
            new DialogWindow(e);
        }
    }