private void CollectQuestReward(Quest quest)
 {
     foreach (QuestReward reward in quest.Rewards)
     {
         if (!reward.IsCollected)
         {
             QuestActions.CallFunction(reward.OnRewardLuaFunction, reward);
         }
     }
 }
    private bool IsQuestCompleted(Quest quest)
    {
        quest.IsCompleted = true;
        foreach (QuestGoal goal in quest.Goals)
        {
            QuestActions.CallFunction(goal.IsCompletedLuaFunction, goal);
            quest.IsCompleted &= goal.IsCompleted;
        }

        return(quest.IsCompleted);
    }
        /// <summary>
        /// Check's whether the Player meets requirements and processes from there.
        /// </summary>
        /// <param name="QuestGiverName"></param>
        /// <param name="player"></param>
        /// <param name="type"></param>
        public void CheckQuest(string QuestGiverName, Player player, QuestType type)
        {
            if (QuestGiverName != player.QuestNPCName)
            {
                throw new QuestKicker();
            }

            //[TODO] More checks

            //[TODO] More Quest crap
            switch (type)
            {
            case QuestType.NO_QUEST:
            case QuestType.SLIME_QUEST:
            case QuestType.CRAFTING_QUEST:
            case QuestType.MINING_QUEST:
            case QuestType.TRANSFORMATION:
            case QuestType.ALCHEMIST_1:
            case QuestType.ALCHEMIST_2:
            case QuestType.ALCHEMIST_3:
            case QuestType.TINKERER_1:
            case QuestType.DARK_MAGE_1:
            case QuestType.DARK_MAGE_2:
            case QuestType.PALADIN_1:
            case QuestType.PALADIN_2:
            case QuestType.QUESTS_END:
                break;

            case QuestType.TINKERER_2:
                QuestActions.Tinkerer_2(player);
                break;

            case QuestType.TINKERER_3:
                QuestActions.Tinkerer_3(player);
                break;

            case QuestType.TINKERER_4:
                QuestActions.Tinkerer_4(player);
                break;

            case QuestType.DARK_MAGE_3:
                QuestActions.Dark_Mage_3(player);
                break;

            case QuestType.DARK_MAGE_4:
                QuestActions.Dark_Mage_4(player);
                break;

            case QuestType.PALADIN_3:
                QuestActions.Paladin_3(player);
                break;
            }
        }
Esempio n. 4
0
    public QuestActions(string rawLuaCode)
    {
        // Tell the LUA interpreter system to load all the classes
        // that we have marked as [MoonSharpUserData]
        UserData.RegisterAssembly();

        _Instance = this;

        myLuaScript = new Script();

        // If we want to be able to instantiate a new object of a class
        //   i.e. by doing    SomeClass.__new()
        // We need to make the base type visible.
        myLuaScript.Globals["Inventory"]   = typeof(Inventory);
        myLuaScript.Globals["Quest"]       = typeof(Quest);
        myLuaScript.Globals["QuestGoal"]   = typeof(QuestGoal);
        myLuaScript.Globals["QuestReward"] = typeof(QuestReward);

        // Also to access statics/globals
        myLuaScript.Globals["World"] = typeof(World);

        myLuaScript.DoString(rawLuaCode);
    }