public void GenerateAllKingdomEntities()
 {
     foreach (KeyValuePair <int, Kingdom> kpv in World.WorldKingdoms)
     {
         KingdomNPCGenerator kingEntGen = new KingdomNPCGenerator(GameGen, kpv.Value, EntityManager);
         kingEntGen.GenerateKingdomNPC();
     }
 }
Exemple #2
0
    private void CreateWorld2()
    {
        World             world = new World();
        SettlementBase    b     = new SettlementBase(new Vec2i(8, 8), 8, SettlementType.CAPITAL);
        SettlementBuilder build = new SettlementBuilder(null, b);

        build.GenerateSettlement();

        /*foreach(SettlementPathNode p in build.nodes)
         * {
         *  TestNodes.Add(p);
         * }*/
        Tile[,] tiles           = build.Tiles;
        WorldObjectData[,] objs = build.SettlementObjects;
        int tileSize = build.TileSize;
        int cSize    = tileSize / World.ChunkSize;

        ChunkData[,] cData = new ChunkData[cSize, cSize];
        ChunkBase[,] cBase = new ChunkBase[cSize, cSize];
        for (int x = 0; x < cSize; x++)
        {
            for (int z = 0; z < cSize; z++)
            {
                cBase[x, z]             = new ChunkBase(new Vec2i(x, z), true);
                int[,] cTiles           = new int[World.ChunkSize, World.ChunkSize];
                WorldObjectData[,] cObj = new WorldObjectData[World.ChunkSize, World.ChunkSize];
                Dictionary <int, WorldObjectData> wObjData = new Dictionary <int, WorldObjectData>();
                for (int x_ = 0; x_ < World.ChunkSize; x_++)
                {
                    for (int z_ = 0; z_ < World.ChunkSize; z_++)
                    {
                        if (tiles[x * World.ChunkSize + x_, z *World.ChunkSize + z_] != null)
                        {
                            cTiles[x_, z_] = tiles[x * World.ChunkSize + x_, z *World.ChunkSize + z_].ID;
                        }
                        else
                        {
                            cTiles[x_, z_] = Tile.GRASS.ID;
                        }

                        if (objs[x * World.ChunkSize + x_, z *World.ChunkSize + z_] != null)
                        {
                            wObjData.Add(WorldObject.ObjectPositionHash(x_, z_), objs[x * World.ChunkSize + x_, z * World.ChunkSize + z_]);
                        }
                        // cObj[x_, z_] = objs[x * World.ChunkSize + x_, z * World.ChunkSize + z_];
                    }
                }
                cData[x, z] = new ChunkData(x, z, cTiles, true, wObjData);
            }
        }


        ChunkRegion r = new ChunkRegion(0, 0, cData);

        WorldManager.LoadedRegions[0, 0] = r;



        Kingdom k = new Kingdom("test", new Vec2i(0, 0));

        k.SetKingdomID(world.AddKingdom(k));
        Settlement set = new Settlement(k, "test_set", build);

        set.SetSettlementID(world.AddSettlement(set));

        WorldManager.SetWorld(world);

        KingdomNPCGenerator npcGen = new KingdomNPCGenerator(new GameGenerator(0), k, EntityManager);

        Debug.Log("BASE:" + set.BaseCoord);
        Debug.Log(cSize);
        npcGen.GenerateSettlementNPC(set);

        world.SetChunkBases(cBase);



        for (int x = 0; x < cSize - 1; x++)
        {
            for (int z = 0; z < cSize - 1; z++)
            {
                //LoadChunk(cData[x, z]);
                WorldManager.CRManager.LoadChunk(new Vec2i(x, z));
                EntityManager.LoadChunk(null, new Vec2i(x, z));
            }
        }

        /*
         * DungeonGenerator dugeonGenerator = new DungeonGenerator();
         * dungeon = dugeonGenerator.GenerateDungeon();
         * ChunkRegion r = new ChunkRegion(0, 0, dungeon.SubworldChunks);
         * world.LoadedRegions.Add(new Vec2i(0, 0), r);
         * WorldManager.SetWorld(world);*/
        //world.Set
    }