Пример #1
0
        private static void DrawPointLight(PointLight pLight)
        {
            Vector2 offset, lightPos;
            if (!EditorMode)
            {
                offset = new Vector2(Camera.Position.X - Camera.ViewPort.Width / 2, Camera.Position.Y - Camera.ViewPort.Height / 2);
                lightPos = new Vector2(pLight.Position.X - offset.X, pLight.Position.Y - offset.Y);
                pointLight.Parameters["LightPos"].SetValue(lightPos);
            }
            else
            {
                lightPos = new Vector2(pLight.Position.X, pLight.Position.Y);
                pointLight.Parameters["LightPos"].SetValue(lightPos);
            }

            pointLight.Parameters["Radius"].SetValue(pLight.Radius);
            pointLight.Parameters["LightPow"].SetValue(pLight.Power);
            pointLight.Parameters["LightColor"].SetValue(pLight.Color.ToVector4());

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, null, null, null, pointLight);

            spriteBatch.Draw(lightingTarget, new Rectangle(0, 0, renderTargetWidth, renderTargetHeight), Color.White);
            spriteBatch.End();
        }
Пример #2
0
        public static void Update()
        {
            Point Offset = new Point((int)EditorMapManager.Offset.X, (int)EditorMapManager.Offset.Y);
            mouseX = ConvertPixelsToIndex(KeyMouseReader.GetMousePos()).X;
            mouseY = ConvertPixelsToIndex(KeyMouseReader.GetMousePos()).Y;

            Console.WriteLine(KeyMouseReader.GetMousePos() - Offset);

            if (KeyMouseReader.isKeyDown(Keys.LeftAlt) && KeyMouseReader.LeftClick())
            {
                EditorMapManager.SetCursorTexture(EditorMapManager.SelectedLayer[mouseX, mouseY]);
            }

            #region Selection
            if (KeyMouseReader.isKeyDown(Keys.LeftShift))
            {
                Selector.Update();
            }
            #endregion

            else
            {
                #region TileCreation
                if (EditorScreen.EditMode == 0)
                {
                    CopyPaster.Update(mouseX, mouseY);

                    if (!CopyPaster.Active)
                        TileCreator.Update(mouseX, mouseY);
                }
                #endregion

                #region Collision-Flagging
                else if (EditorScreen.EditMode == 1)
                {
                    ColliderMaker.Update(mouseX, mouseY);
                }
                #endregion

                #region JumpThroughAble-Flagging
                else if (EditorScreen.EditMode == 2)
                {
                    JumpThroughMaker.Update(mouseX, mouseY);
                }
                else if (EditorScreen.EditMode == 4)
                {
                    if (KeyMouseReader.KeyClick(Keys.Q))
                        LightingManager.AmbientLights.Add(new Lights.AmbientLight(0, 0, EditorMapManager.NumXTiles * 20, EditorMapManager.NumYTiles * 20, EditorScreen.ColorPicker.SelectedColor * 0.5f));
                    else if (KeyMouseReader.LeftClick())
                    {
                        Vector2 mousePos = new Vector2(KeyMouseReader.GetMousePos().X, KeyMouseReader.GetMousePos().Y) - EditorMapManager.Offset;
                        PointLight tempLight = new PointLight(mousePos, 150, 0.8f, EditorScreen.ColorPicker.SelectedColor);
                        LightingManager.PointLights.Add(tempLight);

                        Console.WriteLine("MousePos : " + mousePos);
                        Console.WriteLine("LightPos : " + tempLight.Position);
                    }

                }
                #endregion
            }

            if (KeyMouseReader.isKeyDown(Keys.LeftControl) && KeyMouseReader.KeyClick(Keys.D))
                ClearSelection();
        }