Beispiel #1
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;
        }
    }
    public List <ChunkData> Generate(GenerationRandom genRan)
    {
        Vec2i tilebase = Shell.Position * World.ChunkSize;

        if (Shell.BanditCampLevel > 1 && Shell.Size.x > 3 && Shell.Size.z > 3)
        {
            //If this camp is large enough, generate a dungeon entrance.

            Vec2i localPos = new Vec2i(2, TileSize.z / 2 - 2);

            CaveDungeonEntrance entr = new CaveDungeonEntrance(tilebase + localPos, null, new WorldObjectMetaData(direction: new Vec2i(1, 0)));
            IMultiTileObjectChild[,] children = entr.GetChildren();
            Objects[localPos.x, localPos.z]   = entr;
            for (int x = 0; x < entr.Size.x; x++)
            {
                for (int z = 0; z < entr.Size.z; z++)
                {
                    if (x == 0 && z == 0)
                    {
                        continue;
                    }
                    Objects[localPos.x + x, localPos.z + z] = children[x, z] as WorldObjectData;
                }
            }
            Debug.Log("Generated Bandit Camp with Dungeon at " + this.Shell.Position, Debug.CHUNK_STRUCTURE_GENERATION);

            Shell.SetDungeonEntrance(entr);
            entr.SetChunkStructure(Shell);
        }
        else
        {
            Debug.Log("Generated Bandit Camp no Dungeon at " + this.Shell.Position, Debug.CHUNK_STRUCTURE_GENERATION);
        }

        Objects[11, 11] = new LootSack(tilebase + new Vec2i(11, 11));
        FinalLootChest  = Objects[11, 11] as IInventoryObject;

        for (int x = 0; x < TileSize.x; x++)
        {
            for (int z = 0; z < TileSize.z; z++)
            {
                if (x == 0)
                {
                    Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z));
                }
                if (z == 0)
                {
                    Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z));
                }
                if (x == TileSize.x - 1 && z < TileSize.z / 2 - 2 && z > TileSize.z / 2 + 2)
                {
                    Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z));
                }
                if (z == TileSize.z - 1)
                {
                    Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z));
                }
                Tiles[x, z] = Tile.DIRT.ID;
            }
        }

        EntityFaction banditFaction = new EntityFaction("Bandit_Camp");

        for (int x = 0; x < Shell.Size.x; x++)
        {
            for (int z = 0; z < Shell.Size.z; z++)
            {
                //Entity e = new Bandit();
                //e.SetPosition(tilebase + new Vec2i(x * World.ChunkSize + 5, z * World.ChunkSize + z + 3));
                //Shell.AddEntity(x, z, e);
                //e.SetEntityFaction(banditFaction);
            }
        }
        Entity e = new Bandit();

        e.SetPosition(tilebase + new Vec2i(2 * World.ChunkSize + 5, 2 * World.ChunkSize + 2 + 3));
        Shell.AddEntity(0, 0, e);
        e.SetEntityFaction(banditFaction);



        return(ToChunkData());
    }