Beispiel #1
0
 private Map(Simulation game, Field[,] fields, Camera camera, StatisticsGUI statisticsGui)
 {
     dirtTexture  = game.Content.Load <Texture2D>("dirt");
     waterTexture = game.Content.Load <Texture2D>("water");
     //waterTexture = new Texture2D(game.GraphicsDevice, 1, 1);
     //waterTexture.SetData(new Color[] { Color.Blue });
     this.fields        = fields;
     this.camera        = camera;
     graphicsDevice     = game.GraphicsDevice;
     this.statisticsGui = statisticsGui;
 }
Beispiel #2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Animal.LoadTexture(Content);

            statisticsGUI = new StatisticsGUI(this);
            camera        = new Camera();

            try{
                map = Map.Deserialize(savePath, this, camera, statisticsGUI);
            }catch (Exception e) {
                map = new Map(this, camera, statisticsGUI);
            }
            try{
                animalManager = AnimalManager.Read(savePath, map, delegate(Animal animal) { });
            } catch (Exception e) {
                animalManager = new AnimalManager(map, delegate(Animal animal) { });
            }

            // TODO: use this.Content to load your game content here
        }
Beispiel #3
0
        public Map(Simulation game, Camera camera, StatisticsGUI statisticsGui)
        {
            NoiseGenerator noiseGenerator = new NoiseGenerator();

            dirtTexture  = game.Content.Load <Texture2D>("dirt");
            waterTexture = game.Content.Load <Texture2D>("water");
            //waterTexture = new Texture2D(game.GraphicsDevice, 1, 1);
            //waterTexture.SetData(new Color[] { Color.Blue });
            double [,] heightMap = noiseGenerator.Generate(MAPSIZE, 0, 1, 10, 2, 0.9);
            fields = new Field[MAPSIZE, MAPSIZE];
            for (int i = 0; i < MAPSIZE; i++)
            {
                for (int j = 0; j < MAPSIZE; j++)
                {
                    fields[i, j] = new Field(0, heightMap[i, j]);
                }
            }
            InitializeFood();
            this.camera        = camera;
            graphicsDevice     = game.GraphicsDevice;
            this.statisticsGui = statisticsGui;
        }
Beispiel #4
0
        public static Map Deserialize(String path, Simulation simulation, Camera camera, StatisticsGUI statisticsGui)
        {
            FileStream   file   = File.Open(path + "/map.aemap", FileMode.Open);
            BinaryReader reader = new BinaryReader(file);

            Field[,] fields = reader.ReadArray2 <Field>(delegate() { return(Field.Deserialize(reader)); });

            file.Close();
            return(new Map(simulation, fields, camera, statisticsGui));
        }