Example #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            nbEnemy = 0;

            gameover = false;

            world = new World(new Vector2(0, 0));

            debugView = new DebugView();
            debugView.LoadContent(GraphicsDevice, Content);

            inputHelper            = new InputHelper(resolutionIndependence);
            inputHelper.ShowCursor = true;

            shadowsRendering = new ShadowsRenderer();

            listGraphicObj = new List <GraphicObj>();

            inputHelper.LoadContent();

            font = Content.Load <SpriteFont>("pixelSpriteFont");

            Texture2D textureCarre  = Content.Load <Texture2D>("carre");
            Texture2D textureCarre2 = Content.Load <Texture2D>("carre2");
            Texture2D textureTotem  = Content.Load <Texture2D>("Totem");

            bouleRouge    = Content.Load <Texture2D>("blood");
            blood1        = Content.Load <Texture2D>("blood1");
            blood2        = Content.Load <Texture2D>("blood2");
            blood3        = Content.Load <Texture2D>("blood3");
            debugNodeBusy = Content.Load <Texture2D>("debugPathFinderNode");
            debugNodeFree = Content.Load <Texture2D>("debugPathFinderNode2");

            particuleSystem = new ParticuleSystem();

            //pathFinder = new PathFinder(2);
            pFinder = new PathFinder();
            pFinder.BuildtNavMeshes(6, 10);

            mapFactory = new MapFactory();
            mapFactory.newMap(listGraphicObj, seedIndexToLoad);
            seedIndexToLoad = -1;
            savedSeeds      = mapFactory.mGen.savedSeeds;
            var treeplanter = new TreePlanter(
                mapFactory.minX * pixelToMeter,
                mapFactory.maxX * pixelToMeter,
                mapFactory.minY * pixelToMeter,
                mapFactory.maxY * pixelToMeter,
                mapFactory.mGen.rand
                );

            frameRateCounter = new FrameRateCounter(font);

            particuleSystem.addParticuleSpawner(new SnowSpawner(new Vector2(100, 100), 0, player, new Vector2(475, -475)));

            snowMarkSpawner = new SnowMarkSpawner(new Vector2(0, 0), 0, player, new Vector2(0, 0));

            var noiseSource = new Perlin
            {
                Seed = mapFactory.mGen.rand.Next()
            };
            var noiseMap        = new NoiseMap();
            var noiseMapBuilder = new PlaneNoiseMapBuilder
            {
                DestNoiseMap   = noiseMap,
                SourceModule   = noiseSource,
                EnableSeamless = true
            };

            //noiseMapBuilder.SetDestSize(300, 300);
            //noiseMapBuilder.SetBounds(-4.5, 4.5, -4.5, 4.5);
            noiseMapBuilder.SetDestSize(256, 256);
            noiseMapBuilder.SetBounds(2, 6, 1, 5);

            noiseMapBuilder.Build();

            textureImageNoise = new SharpNoise.Utilities.Imaging.Image();

            imageRendererNoise = new ImageRenderer
            {
                SourceNoiseMap   = noiseMap,
                DestinationImage = textureImageNoise,
                EnableLight      = true,
                LightContrast    = 1.0,
                LightBrightness  = 2.3,
                EnableWrap       = true
            };

            imageRendererNoise.ClearGradient();

            imageRendererNoise.AddGradientPoint(0.0000, new SharpNoise.Utilities.Imaging.Color(170, 180, 240, 255));
            imageRendererNoise.AddGradientPoint(1.000, new SharpNoise.Utilities.Imaging.Color(170, 180, 240, 255));

            imageRendererNoise.Render();

            renderedmap = createTexture(imageRendererNoise);

            minNoiseX = (int)mapFactory.minX - textureImageNoise.Width * 2;
            maxNoiseX = (int)mapFactory.maxX + textureImageNoise.Width * 2;
            minNoiseY = (int)mapFactory.minY - textureImageNoise.Height * 2;
            maxNoiseY = (int)mapFactory.maxY + textureImageNoise.Height * 2;

            menu = new Menu(font);
        }