示例#1
0
    public void CreateAttackWindow()
    {
        Destroyer.Dialog();

        // ability box - name header
        DialogBox db = new DialogBox(new Vector2(15, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), monster.monsterData.name);

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        float offset = 2.5f;

        db = new DialogBox(
            new Vector2(10, offset),
            new Vector2(UIScaler.GetWidthUnits() - 20, 4),
            new StringKey(null, monster.currentActivation.masterActions, false));
        db.AddBorder();

        offset += 4.5f;

        new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate { activated(); });

        MonsterDialogMoM.DrawMonster(monster);
    }
示例#2
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);
        }
    }