示例#1
0
    void Start()
    {
        ResourceManager.LoadAllResources();
        Instance = this;
        GameGen  = new GameGenerator2(0);
        GameGen.GenerateWorld();



        Caravans = new Dictionary <EntityGroup, GameObject>();

        Image.texture = GameGen.TerGen.ToTexture();
        GenMeshes();
        KingdomMap.texture = GameGen.KingdomGen.ToTexture();
        ContourMap.texture = GameGen.TerGen.DrawContours();
        foreach (GridPoint gp in GameGen.GridPlacement.GridPoints)
        {
            if (gp == null)
            {
                continue;
            }
            Vec2i      pos = gp.ChunkPos;
            GameObject t   = Instantiate(GridPoint);
            t.transform.SetParent(Image.transform, false);
            t.transform.localPosition = new Vector3(pos.x - World.WorldSize / 2, pos.z - World.WorldSize / 2, 0);
            (t.GetComponent <GridPointTest>()).SetPoint(gp);
            //Gizmos.DrawCube(new Vector3(pos.x, pos.z, -1), Vector3.one);
        }
        return;

        foreach (EntityGroup c in WorldEventManager.Instance.EntityGroups)
        {
            GameObject obj = Instantiate(Caravan);
            obj.transform.SetParent(Image.transform, false);
            Vec2i pos = c.CurrentChunk;
            obj.transform.localPosition = new Vector3(pos.x - World.WorldSize / 2, pos.z - World.WorldSize / 2, 0);
            Caravans.Add(c, obj);

            obj.GetComponent <EntityGroupDisplay>().SetEntityGroup(c);
        }
    }
示例#2
0
    /// <summary>
    /// The main generation function for the whole game
    /// Creates a <see cref="GameGenerator"/> and then creates a world using <see cref="GameGenerator.GenerateWorld"/>
    /// Then generates all quests using <see cref="GameGenerator.GenerateQuests(World)"/>
    /// </summary>
    /// <param name="seed">Seed fed to the <see cref="GameGenerator"/> that defines the generation</param>
    private void GenerateGame(int seed)
    {
        //Initiate GameGenerator, then generate and set world
        //Debug.BeginDeepProfile("generate_world");

        GameGenerator = new GameGenerator2(seed);
        GameGenerator.GenerateWorld();
        //GameGenerator.GenerateWorld(WorldManager);

        /*
         * GameGenerator.GenerateEntities(WorldManager.World);
         * GameGenerator.GenerateDungeons();*/
        //GameGenerator.GenerateWorldMap();
        //QuestManager.SetQuests(GameGenerator.GenerateQuests(WorldManager.World));


        //Vec2i wpos = Vec2i.FromVector2(QuestManager.Unstarted[0].Initiator.GetNPC().Position2);
        //Vec2i wpos = WorldManager.World.GetChunkStructure(0).Position * World.ChunkSize + new Vec2i(2, 2);
        Vec2i wpos = null;

        foreach (KeyValuePair <int, WorldLocation> tl in WorldManager.World.WorldLocations)
        {
            wpos = tl.Value.ChunkPos * World.ChunkSize;
            break;
        }


        //Vec2i wpos = new Vec2i(1, 1) * World.ChunkSize * World.WorldSize / 2;
        // Vec2i wEntr = WorldManager.World.GetSubworld(1).WorldEntrance;
        //TestSettle = QuestManager.Unstarted[0].Initiator.GetNPC().NPCKingdomData.GetSettlement();
        Debug.Log(TestSettle);


        Vec2i playerStartreg = World.GetRegionCoordFromChunkCoord(World.GetChunkPosition(wpos));

        Debug.Log("Player start region: " + playerStartreg);
        ChunkRegionGenerator = GameGenerator.GenerateChunks(playerStartreg);
        GeneratePlayer(wpos);
    }