Beispiel #1
0
        /// <summary>
        /// Constructor for the GameWorld class
        /// </summary>
        /// <param name="width">The width of the world</param>
        /// <param name="height">The height of the world</param>
        public GameWorld(int width, int height)
        {
            instance = this;

            gameWidth  = width;
            gameHeight = height;

            // Init the time, graph, grid- and tilessystem
            time = new Time();
            materialCollection = new MaterialCollector(true);
            graph = new Graph();
            grid  = new GridSystem();
            tiles = new TileSystem();

            // Initializations for the tiles-, gridsystem and graph
            tiles.initTiles();
            grid.initGrid();

            // A temp NPC to test stuff with
            Gatherer npc = new Gatherer(new Vector2D(20, 100), // Position
                                        20,                    // Bounding Radius
                                        new Vector2D(0, 0),    // Velocity
                                        80,                    // Max Speed
                                        Vector2D.Up,           // Heading
                                        1,                     // Mass
                                        new Vector2D(15, 15),  // Scale
                                        0.05f,                 // Turnrate
                                        10,                    // Max Force
                                        15,                    // Carry Capacity
                                        Material.WOOD.id);     // MatID

            //Gatherer npc2 = new Gatherer(new Vector2D(60, 100), // Position
            //                                    20, // Bounding Radius
            //                                    new Vector2D(0, 0), // Velocity
            //                                    80, // Max Speed
            //                                    Vector2D.Left, // Heading
            //                                    1, // Mass
            //                                    new Vector2D(15, 15), // Scale
            //                                    0.05f, // Turnrate
            //                                    10, // Max Force
            //                                    15, // Carry Capacity
            //                                    2); // MatID

            StorageBuilding storage = new StorageBuilding(new Vector2D(400, 200), new Vector2D(40, 40));

            graph.initGraph();
            tiles.AddResources();

            // Setting the path for the npc to follow
            //npc.path.Set(Path.GetPathTo(tiles.tiles[TileSystem.GetIndexOfTile(npc.position)], Material.WOOD));
            //npc2.path.Set(Path.GetPathTo(tiles.tiles[TileSystem.GetIndexOfTile(npc2.position)], Material.STONE));

            // Adding the npc to the world
            entities.Add(npc);
            //entities.Add(npc2);

            storage.SetEntranceEdge();

            buildings.Add(storage);
        }