Esempio n. 1
0
    /// <summary>
    /// Generates a quest with the goal of clearing a specific chunk structure
    /// </summary>
    /// <param name="dungeonPos"></param>
    /// <param name="chunkStructure"></param>
    /// <returns></returns>
    private Quest GenerateDungeonQuest(Vec2i dungeonPos, ChunkStructure chunkStructure)
    {
        questCount++;
        //Get the dungeon this quest is based on
        Dungeon dun = chunkStructure.DungeonEntrance.GetDungeon();
        //If the dungeon doesn't have a key (generation should be set so it doesn't), we create one
        Key key = dun.GetKey();

        if (key == null)
        {
            key = new SimpleDungeonKey(GenRan.RandomInt(1, int.MaxValue));
            dun.SetKey(key);
        }

        //We build the quest in reverse, we first define the goal
        List <QuestTask> revTasks = new List <QuestTask>();

        //For a dungeon quest, this is always to kill the dungeon boss
        revTasks.Add(new QuestTask("Kill " + dun.Boss.Name, QuestTask.QuestTaskType.KILL_ENTITY, new object[] { dun.Boss }));

        //The second to last task is to get to the dungeon,
        revTasks.Add(new QuestTask("Get to dungeon", QuestTask.QuestTaskType.GO_TO_LOCATION, new object[] { chunkStructure.WorldMapLocation, dun.WorldEntrance }));

        //Before we get to the dungeon, we need to get the key.
        //The key can either be held by an entity, or it can be found in a
        //random chunk structure with no dungeon.


        return(GenerateDungeonKeyQuest_RandomStructure(dungeonPos, dun, revTasks));
    }
Esempio n. 2
0
    public Dungeon(ChunkData[,] subChunks, Vec2i subentra, Vec2i worldEntrance, List <Entity> dungeonEntity, DungeonBoss boss, SimpleDungeonKey key = null) : base(subChunks, subentra, worldEntrance)
    {
        DungeonEntities = dungeonEntity;
        Boss            = boss;
        Vec2i entranceChunk = World.GetChunkPosition(SubworldEntrance);
        int   local         = WorldObject.ObjectPositionHash(SubworldEntrance);

        if (!(subChunks[entranceChunk.x, entranceChunk.z].GetObject(SubworldEntrance.x, SubworldEntrance.z) is DungeonEntrance))
        {
            //If the entrance isn't a dungeon entrance.
            DungeonEntrance de = new CaveDungeonEntrance(subentra, this, new WorldObjectMetaData(direction: new Vec2i(0, -1)));
            SubworldChunks[entranceChunk.x, entranceChunk.z].SetObject(SubworldEntrance.x, SubworldEntrance.z, de);
        }
        Key = key;
        if (Key == null)
        {
            IsLocked = false;
        }
        else
        {
            IsLocked = true;
        }
    }