コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        TestMain.SetupTest();
        Player = TestMain.CreatePlayer(new Vector3(0, 0, 0));

        Kingdom king = new Kingdom("kingdom", new Vec2i(0, 0));

        World.Instance.AddKingdom(king);


        SettlementShell shell = new SettlementShell(new GridPoint(new Vec2i(0, 0), new Vec2i(0, 0)), 0, SettlementType.CAPITAL);

        bool[] entraceDir = new bool[8];
        entraceDir[0] = true;
        entraceDir[3] = true;
        // entraceDir[4] = true;
        // entraceDir[6] = true;
        SettlementGenerator2.LocationData ld = new SettlementGenerator2.LocationData()
        {
            OnRiver = false, OnBorder = false, OnLake = false, EntranceDirections = entraceDir
        };
        shell.SetLocationData(ld);

        int size = shell.Type.GetSize();

        ChunkBase2[,] bases = new ChunkBase2[size, size];
        for (int x = 0; x < size; x++)
        {
            for (int z = 0; z < size; z++)
            {
                bases[x, z] = new ChunkBase2(new Vec2i(x, z), WorldHeightChunk(x, z), ChunkBiome.grassland);
                if (z == 8)
                {
                    bases[x, z].SetChunkFeature(new ChunkRiverNode(new Vec2i(x, z)));
                }
            }
        }
        List <BuildingPlan> reqBuild = new List <BuildingPlan>()
        {
            Building.VEGFARM, Building.WHEATFARM, Building.VEGFARM, Building.WHEATFARM
        };

        shell.RequiredBuildings = reqBuild;
        shell.SetChunkBases(bases);
        Debug.BeginDeepProfile("Setgen");
        SettlementBuilder2 setB = new SettlementBuilder2(WorldHeight, shell);

        setB.Generate(new GenerationRandom(0));

        foreach (Building b in setB.Buildings)
        {
            if (b.BuildingSubworld != null)
            {
                World.Instance.AddSubworld(b.BuildingSubworld);
            }
        }

        Settlement set = new Settlement(king, "set", setB);

        World.Instance.AddLocation(set);
        EntityGenerator eg = new EntityGenerator(null, EntityManager.Instance);

        eg.GenerateAllKingdomEntities();
        SettlementWall = setB.GenerateWall();
        //wall = SettlementWall.WallPath.CalculateEvenlySpacedPoints(5, 1);
        Debug.EndDeepProfile("Setgen");

        /*
         * int seed = 0;
         * SettlementBuilder setB = new SettlementBuilder(WorldHeight, new SettlementBase(new Vec2i(9, 9), 8, SettlementType.CAPITAL));
         * setB.Generate(GameManager.RNG);
         *
         * Kingdom k = new Kingdom("king", new Vec2i(9, 9));
         * Settlement set = new Settlement(k, "set", setB);
         * k.AddSettlement(set);
         * KingdomNPCGenerator npcGen = new KingdomNPCGenerator(null, k, EntityManager.Instance);
         * npcGen.GenerateSettlementNPC(set);
         */


        List <ChunkData> chunks = setB.ToChunkData();

        Chunks = new ChunkData[20, 20];


        foreach (ChunkData cd in chunks)
        {
            if (cd == null)
            {
                continue;
            }

            Chunks[cd.X, cd.Z] = cd;

            EntityManager.Instance.LoadChunk(new Vec2i(cd.X, cd.Z));
        }

        SetChunks(Chunks);

        return;
    }
コード例 #2
0
 public void SetLocationData(SettlementGenerator2.LocationData ld)
 {
     LocationData = ld;
 }