Пример #1
0
        public void Initialize()
        {
            LightRenderer = new LightRenderer(Game1.graphics);
            EnemyManager.Reset();
            Camera.ClearFocusList();

            if (mapManager == null)
                mapManager = new MapManager();

            mapManager.Initialize(LightRenderer);
            finalRenderTarget = new RenderTarget2D(ScreenManager.Game.GraphicsDevice, MapManager.MapWidth, MapManager.MapHeight);

            if (Player == null)
                Player = new Player();

            Player.SetStartPos(mapManager.PlayerStartPos);
            lightPos = mapManager.PlayerStartPos;

            Camera.ResetValues(mapManager.PlayerStartPos);
            Camera.DefaultFocus = Player;
            Camera.Position = mapManager.PlayerStartPos;
            Camera.Limits = new Rectangle(0, 0, MapManager.MapWidth, MapManager.MapHeight);

            pointLightHandles = new List<PointLight>();
            spotLightHandles = new List<SpotLight>();

            LightRenderer.Initialize(0, 0, MapManager.MapWidth, MapManager.MapHeight);

            LightRenderer.minLight = 0.15f;
            LightRenderer.lightBias = 10f;
            spotLightDir = Vector2.UnitX * -1.00001f;

            //pointLightHandles.Add(new PointLight(new Vector2(200, 200), 1f, 300f, Color.White));

            pointLightHandles.Add(new PointLight(new Vector2(200, 200), 1f, 200f, Color.Red));
            pointLightHandles.Add(new PointLight(new Vector2(200, 200), 1f, 250f, Color.LightGreen));
            pointLightHandles.Add(new PointLight(new Vector2(200, 200), 1f, 250f, Color.LightGreen));

            spotLightHandles.Add(new SpotLight(new Vector2(200, 200), spotLightDir, 1f, 2f, 0.5f, 500f, Color.LightBlue));
            spotLightHandles.Add(new SpotLight(new Vector2(200, 200), spotLightDir, 1f, 2f, 0.5f, 500f, Color.Red));

            //LightRenderer.pointLights.Add(pointLightHandles[0]);
            //LightRenderer.pointLights.Add(pointLightHandles[1]);
            //LightRenderer.pointLights.Add(pointLightHandles[2]);
            //LightRenderer.spotLights.Add(spotLightHandles[0]);
            //LightRenderer.spotLights.Add(spotLightHandles[1]);

            LightRenderer.LoadContent(ScreenManager.Game.Content);
            Console.WriteLine("PointLights.Count: " + LightRenderer.pointLights.Count);
            myAffectLightDir = false;
            myCurrLight = 0;
        }
Пример #2
0
        public void Initialize()
        {
            EnemyManager.Reset();
            Camera.ClearFocusList();

            if (mapManager == null)
                mapManager = new MapManager();

            mapManager.Initialize();

            if (Player == null)
                Player = new Player();

            Player.SetStartPos(mapManager.PlayerStartPos);
            Camera.ResetValues(mapManager.PlayerStartPos);
            Camera.DefaultFocus = Player;
            Camera.Position = mapManager.PlayerStartPos;
            Camera.Limits = new Rectangle(0, 0, MapManager.MapWidth, MapManager.MapHeight);

            ambientLightHandles = new List<AmbientLight>();
            spotLightHandles = new List<PointLight>();

            ambientLightHandles.Add(new AmbientLight(Color.White * 0.40f));
            ambientLightHandles.Add(new AmbientLight(Color.White));
            spotLightHandles.Add(new PointLight(Player.Position, 200, 0.8f, Color.White));

            LightingManager.AmbientLights.Add(ambientLightHandles[0]);
            LightingManager.PointLights.Add(spotLightHandles[0]);
        }