Пример #1
0
        /// <summary>
        /// Array translator.
        ///
        /// Uses the two dimensional int array from Map_Generator and goes through the whole array and
        /// intepretes the number and add the appropriate thing.
        ///
        /// example if the current value is 0 it will add floor to the list.
        /// </summary>
        private void Map_loader()
        {
            walls = new Rectangle[Map_Generator.wall_count];
            int walls_amount = Map_Generator.wall_count - 1;

            for (int x = 0; x < Map_Generator.map_grid.GetLength(0); x++)
            {
                for (int y = 0; y < Map_Generator.map_grid.GetLength(1); y++)
                {
                    // ########
                    // Golv
                    // ########
                    if (Map_Generator.map_grid[x, y] == 0)
                    {
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }

                    // ########
                    // Vägg
                    // ########
                    if (Map_Generator.map_grid[x, y] == 1)
                    {
                        walls[walls_amount] = new Rectangle(x * wall_size, y * wall_size, wall_size, wall_size);
                        walls_amount--;
                    }

                    // ########
                    // Doors
                    // ########
                    else if (Map_Generator.map_grid[x, y] == 2)
                    {
                        Add_door(new Vector2(x, y));
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }

                    // ########
                    // Zombies
                    // ########
                    else if (Map_Generator.map_grid[x, y] == 3)
                    {
                        Zombie_manager.Add_spawner(new Vector2((x * wall_size) + 5, (y * wall_size) + 5));
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }

                    // ########
                    // Playera
                    // ########
                    else if (Map_Generator.map_grid[x, y] == 4)
                    {
                        // Camera pos
                        Objects.camera.MoveCamera(new Vector2((x * wall_size) + 40, (y * wall_size) + 40));

                        Objects.player.Start_pos(new Vector2(x * wall_size, y * wall_size));
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }

                    // ########
                    // Shotgun shop
                    // ########
                    else if (Map_Generator.map_grid[x, y] == 5)
                    {
                        Shops.Add_Shotgun(new Vector2(x * wall_size, y * wall_size));
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }

                    // ########
                    // Rifle shop
                    // ########
                    else if (Map_Generator.map_grid[x, y] == 6) // Add Rifle shop
                    {
                        Shops.Add_Ak(new Vector2(x * wall_size, y * wall_size));
                        Add_Floor(new Vector2(x * wall_size, y * wall_size));
                    }
                }
            }
        }