Example #1
0
    public void PickHorror(Quest.Monster m)
    {
        Game game = Game.Get();
        List <HorrorData> horrors = new List <HorrorData>();

        foreach (KeyValuePair <string, HorrorData> kv in game.cd.horrorChecks)
        {
            if (m.monsterData.sectionName.Equals("Monster" + kv.Value.monster))
            {
                horrors.Add(kv.Value);
            }
        }

        QuestMonster qm = m.monsterData as QuestMonster;

        if (horrors.Count == 0 && qm != null && qm.derivedType.Length > 0)
        {
            foreach (KeyValuePair <string, HorrorData> kv in game.cd.horrorChecks)
            {
                if (qm.derivedType.Equals("Monster" + kv.Value.monster))
                {
                    horrors.Add(kv.Value);
                }
            }
        }

        if (horrors.Count != 0)
        {
            Draw(horrors[Random.Range(0, horrors.Count)], m);
        }
    }
Example #2
0
    public void PickEvade(Quest.Monster m)
    {
        Game             game   = Game.Get();
        List <EvadeData> evades = new List <EvadeData>();

        foreach (KeyValuePair <string, EvadeData> kv in game.cd.investigatorEvades)
        {
            if (m.monsterData.sectionName.Equals("Monster" + kv.Value.monster))
            {
                evades.Add(kv.Value);
            }
        }

        QuestMonster qm = m.monsterData as QuestMonster;

        if (evades.Count == 0 && qm != null && qm.derivedType.Length > 0)
        {
            foreach (KeyValuePair <string, EvadeData> kv in game.cd.investigatorEvades)
            {
                if (qm.derivedType.Equals("Monster" + kv.Value.monster))
                {
                    evades.Add(kv.Value);
                }
            }
        }

        if (evades.Count > 0)
        {
            text = evades[Random.Range(0, evades.Count)].text.Translate().Replace("{0}", m.monsterData.name.Translate());

            game.quest.log.Add(new Quest.LogEntry(text.Replace("\n", "\\n")));

            Draw();
        }
    }
Example #3
0
    public void PickHorror(Quest.Monster m)
    {
        Game game = Game.Get();
        List <HorrorData> horrors = new List <HorrorData>();

        foreach (HorrorData hd in game.cd.Values <HorrorData>())
        {
            if (m.monsterData.sectionName.Equals(MonsterData.type + hd.monster))
            {
                horrors.Add(hd);
            }
        }

        QuestMonster qm = m.monsterData as QuestMonster;

        if (horrors.Count == 0 && qm != null && !string.IsNullOrWhiteSpace(qm.derivedType))
        {
            foreach (HorrorData horrorData in game.cd.Values <HorrorData>())
            {
                if (qm.derivedType.Equals("Monster" + horrorData.monster))
                {
                    horrors.Add(horrorData);
                }
            }
        }

        if (horrors.Count != 0)
        {
            Draw(horrors[Random.Range(0, horrors.Count)], m);
        }
    }
Example #4
0
    public void PickEvade(Quest.Monster m)
    {
        Game             game   = Game.Get();
        List <EvadeData> evades = game.cd.Values <EvadeData>()
                                  .Where(md => m.monsterData.sectionName.Equals(MonsterData.type + md.monster))
                                  .ToList();

        QuestMonster qm = m.monsterData as QuestMonster;

        if (evades.Count == 0 && qm != null && !string.IsNullOrWhiteSpace(qm.derivedType))
        {
            var derivedEvades = game.cd.Values <EvadeData>()
                                .Where(kv => qm.derivedType.Equals(MonsterData.type + kv.monster));
            evades.AddRange(derivedEvades);
        }

        if (evades.Count > 0)
        {
            text = evades[Random.Range(0, evades.Count)].text.Translate().Replace("{0}", m.monsterData.name.Translate());

            game.quest.log.Add(new Quest.LogEntry(text.Replace("\n", "\\n")));

            Draw();
        }
    }
Example #5
0
    private void CreateQuestMonster(int level)
    {
        QuestCoolTimeManager.instance.QuestStarted(level);
        QuestMonster questMonsterPrefab = ResourceManager.instance.GetMonoBehavioursObject <QuestMonster>("QuestMonster");
        QuestMonster questMonster       = Instantiate(questMonsterPrefab);

        questMonster.questIndex = level;
        questMonster.SetQuestMonster();
        questMonster.transform.SetParent(null);
        InGameManager.instance.monsterList.Add(questMonster);
    }
Example #6
0
    // Activate a monster
    override public bool ActivateMonster()
    {
        Game game = Game.Get();

        // Search for unactivated monsters
        List <int> notActivated = new List <int>();

        // Get the index of all monsters that haven't activated
        for (int i = 0; i < game.quest.monsters.Count; i++)
        {
            if (!game.quest.monsters[i].activated)
            {
                QuestMonster qm = game.quest.monsters[i].monsterData as QuestMonster;
                if (qm != null && qm.activations != null && qm.activations.Length == 1 && qm.activations[0].IndexOf("Event") == 0 &&
                    game.quest.eManager.events[qm.activations[0]].Disabled())
                {
                    // monster cannot be activated, mark as activated
                    game.quest.monsters[i].activated = true;
                }
                else
                {
                    notActivated.Add(i);
                }
            }
        }

        if (notActivated.Count > 0)
        {
            // Find a random unactivated monster
            Quest.Monster toActivate = game.quest.monsters[notActivated[Random.Range(0, notActivated.Count)]];

            // Find out of this monster is quest specific
            QuestMonster qm = toActivate.monsterData as QuestMonster;
            if (qm != null && qm.activations != null && qm.activations.Length == 1 && qm.activations[0].IndexOf("Event") == 0)
            {
                toActivate.masterStarted         = true;
                toActivate.activated             = true;
                game.quest.eManager.monsterImage = toActivate;
                game.quest.eManager.QueueEvent(qm.activations[0]);
            }
            else
            {
                ActivateMonster(toActivate);
            }
            // Return false as activations remain
            return(false);
        }
        return(true);
    }
Example #7
0
    public HorrorCheck(Quest.Monster m)
    {
        Game game = Game.Get();

        QuestMonster qm = m.monsterData as QuestMonster;

        if (qm != null && game.quest.qd.components.ContainsKey(qm.cMonster.horrorEvent))
        {
            game.quest.eManager.monsterImage = m;
            game.quest.eManager.QueueEvent(qm.cMonster.horrorEvent);
        }
        else
        {
            PickHorror(m);
        }
    }
Example #8
0
    public InvestigatorEvade(Quest.Monster monster)
    {
        m = monster;
        Game game = Game.Get();

        QuestMonster qm = m.monsterData as QuestMonster;

        if (qm != null && game.quest.qd.components.ContainsKey(qm.cMonster.evadeEvent))
        {
            game.quest.eManager.monsterImage = m;
            game.quest.eManager.QueueEvent(qm.cMonster.evadeEvent);
        }
        else
        {
            PickEvade(m);
        }
    }
Example #9
0
    public void EndGame()
    {
        if (gameEnd)
        {
            return;
        }
        gameEnd = true;

        StopCoroutine(waveCoroutine);
        int len = monsterList.Count;

        for (int i = 0; i < len; i++)
        {
            QuestMonster qm = monsterList[i] as QuestMonster;
            BossMonster  bm = monsterList[i] as BossMonster;

            if (bm != null && qm != null)
            {
                Destroy(monsterList[i]);
            }
            else
            {
                _objectpoolManager.ReturnMonster(monsterList[i]);
            }
        }

        bool renewal = DataManager.instance.CheckRenewal(round);

        if (renewal)
        {
            UnlockAcheive();
            DataManager.instance.SaveIntData(DataManager.SaveDataType.UploadScrore, round);
        }

        //if (DataManager.instance.CheckData(DataManager.SaveDataType.UploadScrore))
        //{
        //    GooglePlayManager.instance.UploadRanking(
        //        GPGSIds.leaderboard,
        //        DataManager.instance.GetIntData(DataManager.SaveDataType.UploadScrore),
        //        () => { DataManager.instance.DeleteKey(DataManager.SaveDataType.UploadScrore);});
        //}

        InGameUIManager.instance.panel_Result.ShowResult(round, renewal);
    }
Example #10
0
    public static Quest getRandomQuest(Player player)
    {
        Quest q = null;

        while (q == null)
        {
            switch (Main.rand.Next(5))
            {
            case 0:
            case 1: q = QuestMonster.getRandomQuest(player, false); break;

            case 2: q = QuestMonster.getRandomQuest(player, true); break;

            case 3:
            case 4: q = QuestGather.getRandomQuest(player); break;
            }
        }
        return(q);
    }
Example #11
0
    public HorrorCheck(Quest.Monster m)
    {
        Game game = Game.Get();
        List <HorrorData> horrors = new List <HorrorData>();

        foreach (KeyValuePair <string, HorrorData> kv in game.cd.horrorChecks)
        {
            if (m.monsterData.sectionName.Equals("Monster" + kv.Value.monster))
            {
                horrors.Add(kv.Value);
            }
        }

        QuestMonster qm = m.monsterData as QuestMonster;

        if (horrors.Count == 0 && qm != null && qm.derivedType.Length > 0)
        {
            foreach (KeyValuePair <string, HorrorData> kv in game.cd.horrorChecks)
            {
                if (qm.derivedType.Equals("Monster" + kv.Value.monster))
                {
                    horrors.Add(kv.Value);
                }
            }
        }

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

        string    text = horrors[Random.Range(0, horrors.Count)].text.Translate().Replace("{0}", m.monsterData.name.Translate());
        DialogBox db   = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 8),
                                       new StringKey(null, text, false));

        db.AddBorder();

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

        MonsterDialogMoM.DrawMonster(m);
    }
Example #12
0
    public InvestigatorEvade(Quest.Monster m)
    {
        Game             game   = Game.Get();
        List <EvadeData> evades = new List <EvadeData>();

        foreach (KeyValuePair <string, EvadeData> kv in game.cd.investigatorEvades)
        {
            if (m.monsterData.sectionName.Equals("Monster" + kv.Value.monster))
            {
                evades.Add(kv.Value);
            }
        }

        QuestMonster qm = m.monsterData as QuestMonster;

        if (evades.Count == 0 && qm != null && qm.derivedType.Length > 0)
        {
            foreach (KeyValuePair <string, EvadeData> kv in game.cd.investigatorEvades)
            {
                if (qm.derivedType.Equals("Monster" + kv.Value.monster))
                {
                    evades.Add(kv.Value);
                }
            }
        }

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


        string    text = evades[Random.Range(0, evades.Count)].text.Translate().Replace("{0}", m.monsterData.name.Translate());
        DialogBox db   = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 8), text);

        db.AddBorder();

        new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), "Finished", delegate { Destroyer.Dialog(); });
    }
Example #13
0
    // Activate a monster
    virtual public bool ActivateMonster(Quest.Monster m)
    {
        List <ActivationData> adList = new List <ActivationData>();
        Game game = Game.Get();

        bool        customActivations = false;
        MonsterData md = m.monsterData;

        // Find out of this monster is quest specific
        QuestMonster qm = md as QuestMonster;

        if (qm != null)
        {
            // Get the base monster type
            if (game.cd.ContainsKey <MonsterData>(qm.derivedType))
            {
                md = game.cd.Get <MonsterData>(qm.derivedType);
            }
            // Determine if the monster has quest specific activations
            customActivations = !qm.useMonsterTypeActivations;
        }

        // A monster with quest specific activations
        if (customActivations)
        {
            if (!qm.useMonsterTypeActivations)
            {
                adList = new List <ActivationData>();
                // Get all custom activations
                foreach (string s in qm.activations)
                {
                    // Find the activation in quest data
                    if (game.quest.qd.components.ContainsKey("Activation" + s) &&
                        game.quest.vars.Test((game.quest.qd.components["Activation" + s] as QuestData.Activation).tests)
                        )
                    {
                        adList.Add(new QuestActivation(game.quest.qd.components["Activation" + s] as QuestData.Activation));
                    }
                    // Otherwise look for the activation in content data
                    else if (game.cd.TryGet("MonsterActivation" + s, out ActivationData activationData))
                    {
                        adList.Add(activationData);
                    }
                    else // Invalid activation
                    {
                        game.quest.log.Add(new Quest.LogEntry("Warning: Unable to find activation: " + s + " for monster type: " + m.monsterData.sectionName, true));
                    }
                }
            }
        }
        else // Content Data activations only
        {
            // Find all possible activations
            foreach (KeyValuePair <string, ActivationData> kv in game.cd.GetAll <ActivationData>())
            {
                // Is this activation for this monster type? (replace "Monster" with "MonsterActivation", ignore specific variety)
                if (kv.Key.IndexOf("MonsterActivation" + md.sectionName.Substring("Monster".Length)) == 0)
                {
                    adList.Add(kv.Value);
                }
            }
            // Search for additional common activations
            foreach (string s in md.activations)
            {
                if (game.cd.TryGet("MonsterActivation" + s, out ActivationData activationData))
                {
                    adList.Add(activationData);
                }
                else
                {
                    ValkyrieDebug.Log("Warning: Unable to find activation: " + s + " for monster type: " + md.sectionName);
                }
            }
        }

        // Check for no activations
        if (adList.Count == 0)
        {
            ValkyrieDebug.Log("Error: Unable to find any activation data for monster type: " + md.name);
            Application.Quit();
        }

        // No current activation
        if (m.currentActivation == null)
        {
            // Pick a random activation
            ActivationData activation = adList[Random.Range(0, adList.Count)];
            m.NewActivation(activation);
        }

        // MoM has a special activation
        if (game.gameType is MoMGameType)
        {
            m.masterStarted = true;
            new ActivateDialogMoM(m);
            return(false);
        }

        // If no minion activation just do master
        if (m.currentActivation.ad.minionActions.fullKey.Length == 0)
        {
            m.minionStarted = true;
            m.masterStarted = true;
            new ActivateDialog(m, true, true);
            return(false);
        }

        // If no master activation just do minion
        if (m.currentActivation.ad.masterActions.fullKey.Length == 0)
        {
            m.minionStarted = true;
            m.masterStarted = true;
            new ActivateDialog(m, false, true);
            return(false);
        }

        // Random pick Minion or master (both available)
        m.minionStarted = Random.Range(0, 2) == 0;

        // If order specificed then use that instead
        if (m.currentActivation.ad.masterFirst)
        {
            m.minionStarted = false;
        }
        if (m.currentActivation.ad.minionFirst)
        {
            m.minionStarted = true;
        }

        // Master is opposite of minion as this is the first activation
        m.masterStarted = !m.minionStarted;

        // Create activation window
        new ActivateDialog(m, m.masterStarted);

        // More groups unactivated
        return(false);
    }
Example #14
0
    public static bool ActivateMonster(Quest.Monster m)
    {
        List <ActivationData> adList = new List <ActivationData>();
        Game game = Game.Get();

        bool        customActivations = false;
        MonsterData md = m.monsterData;

        QuestMonster qm = md as QuestMonster;

        if (qm != null)
        {
            if (game.cd.monsters.ContainsKey(qm.derivedType))
            {
                md = game.cd.monsters[qm.derivedType];
            }
            customActivations = !qm.useMonsterTypeActivations;
        }

        if (customActivations)
        {
            if (!qm.useMonsterTypeActivations)
            {
                adList = new List <ActivationData>();
                foreach (string s in qm.activations)
                {
                    // This should check for quest activations!
                    if (game.quest.qd.components.ContainsKey("Activation" + s))
                    {
                        adList.Add(new QuestActivation(game.quest.qd.components["Activation" + s] as QuestData.Activation));
                    }
                    else if (game.cd.activations.ContainsKey("MonsterActivation" + s))
                    {
                        adList.Add(game.cd.activations["MonsterActivation" + s]);
                    }
                    else
                    {
                        Debug.Log("Warning: Unable to find activation: " + s + " for monster type: " + m.monsterData.sectionName);
                    }
                }
            }
        }
        else
        {
            // Find all possible activations
            foreach (KeyValuePair <string, ActivationData> kv in game.cd.activations)
            {
                // Is this activation for this monster type? (replace "Monster" with "MonsterActivation", ignore specific variety)
                if (kv.Key.IndexOf("MonsterActivation" + md.sectionName.Substring("Monster".Length)) == 0)
                {
                    adList.Add(kv.Value);
                }
            }
            // Search for additional common activations
            foreach (string s in md.activations)
            {
                if (game.cd.activations.ContainsKey("MonsterActivation" + s))
                {
                    adList.Add(game.cd.activations["MonsterActivation" + s]);
                }
                else
                {
                    Debug.Log("Warning: Unable to find activation: " + s + " for monster type: " + md.sectionName);
                }
            }
        }

        // Check for no activations
        if (adList.Count == 0)
        {
            Debug.Log("Error: Unable to find any activation data for monster type: " + md.name);
            Application.Quit();
        }

        if (m.currentActivation == null)
        {
            // Pick a random activation
            ActivationData activation = adList[Random.Range(0, adList.Count)];
            m.NewActivation(activation);
        }

        // If no minion activation just do master
        if (m.currentActivation.ad.minionActions.Length == 0)
        {
            m.minionStarted = true;
            m.masterStarted = true;
            new ActivateDialog(m, true);
            return(false);
        }

        // If no master activation just do minion
        if (m.currentActivation.ad.masterActions.Length == 0)
        {
            m.minionStarted = true;
            m.masterStarted = true;
            new ActivateDialog(m, false);
            return(false);
        }

        // Pick Minion or master
        m.minionStarted = Random.Range(0, 2) == 0;
        if (m.currentActivation.ad.masterFirst)
        {
            m.minionStarted = false;
        }
        if (m.currentActivation.ad.minionFirst)
        {
            m.minionStarted = true;
        }

        m.masterStarted = !m.minionStarted;

        // Create activation window
        new ActivateDialog(m, m.masterStarted);

        // More groups unactivated
        return(false);
    }