protected override void Initialize()
        {
            base.Initialize();
            OnStart();
            optionTool = new OptionTool(this);
            loadTool   = new LoadTool(this);
            saveTool   = new SaveTool(this);
            newTool    = new NewTool(this);
            pencilTool = new PencilTool(this);
            flagTool   = new FlagTool(this);
            fillTool   = new FillTool(this);
            actorTool  = new ActorTool(this);
            eraseTool  = new EraserTool(this);
            stampTool  = new StampTool(this);

            EditorInput input = inputComponent as EditorInput;

            (input[EditorInput.EditBindings.SCROLLLOCK] as SinglePressBinding).downEvent += flipScroll;
            (input[EditorInput.EditBindings.FULLSCREEN] as SinglePressBinding).downEvent += flipFull;
            (input[EditorInput.EditBindings.ZOOMIN] as SinglePressBinding).downEvent     += zoomIn;
            (input[EditorInput.EditBindings.ZOOMOUT] as SinglePressBinding).downEvent    += zoomOut;
            (input[EditorInput.EditBindings.QUIT] as SinglePressBinding).downEvent       += Exit;

            pencilTool.active = true;
            activeTool        = pencilTool;
            graphicsComponent.guiComponent.current.performLayout();
            graphicsComponent.guiComponent.current.performLayout();
        }
        public Editor()
        {
            resourceComponent = new GameResources(this.Content, this);
            inputComponent    = new EditorInput(this);
            physicsComponent  = new EditorPhysics(this);
            graphicsComponent = new EditorGraphics(this);
            audioComponent    = new EditorAudio(this);

            fullscreen = false;
            Tile.noLOS = true;
        }
Exemple #3
0
        public override void Initialize()
        {
            base.Initialize();
            float       width  = graphics.camera.screenWidth / graphics.camera.scale;
            float       height = graphics.camera.screenHeight / graphics.camera.scale;
            EditorInput input  = tileEngine.inputComponent as EditorInput;



            egl.size     = new Vector2(width, .25f * height);
            egl.location = new Vector2(0, .75f * height);
            egl.Initialize();



            egl.pack();
            current = egl;
            focus   = current;
        }
        public Tool(Editor editor)
        {
            this.editor = editor;

            EditorInput input = this.editor.inputComponent as EditorInput;

            gui = new ToolOptionsGUI(editor.graphicsComponent.guiComponent as EditorGUI);

            toolAction = new Stack <ToolAction>();
            undos      = new Stack <ToolAction>();

            /*
             * bindings = new InputBinding[Enum.GetValues(typeof(ToolBindings)).Length];
             * bindings[(int)ToolBindings.LEFT] = new SinglePressBinding(input, null, null, InputComponent.MouseButton.LEFT);
             * bindings[(int)ToolBindings.RIGHT] = new SinglePressBinding(input, null, null, InputComponent.MouseButton.RIGHT);
             *
             * (bindings[(int)ToolBindings.LEFT] as SinglePressBinding).downEvent += doLeftAction;
             * (bindings[(int)ToolBindings.RIGHT] as SinglePressBinding).downEvent += doRightAction;
             */
        }
Exemple #5
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            EditorWorld editorWorld = tileEngine.world as EditorWorld;

            base.Update(gameTime);
            if ((tileEngine as Editor).activeTool.active)
            {
                (tileEngine as Editor).activeTool.doMoveAction();
            }
            // Move camera position to center of player position


            AxisBinding xaim, yaim, xmove, ymove;
            EditorInput input = tileEngine.inputComponent as EditorInput;

            AxisBinding.origin = (new Vector2(.5f * camera.screenWidth, .4f * camera.screenHeight));
            //AxisBinding.origin = new Vector2(0,0);
            xaim  = input[EditorInput.EditBindings.XAIM] as AxisBinding;
            yaim  = input[EditorInput.EditBindings.YAIM] as AxisBinding;
            xmove = input[EditorInput.EditBindings.XMOVE] as AxisBinding;
            ymove = input[EditorInput.EditBindings.YMOVE] as AxisBinding;
            Debug.WriteLine(xaim.position + "  " + yaim.position + "\n");

            camera.velocity = Vector2.Zero;

            camera.velocity  = new Vector2(xaim.position, -yaim.position);
            camera.velocity *= 20f; // scale by speed
            if (camera.velocity.Length() > 2.5 && !editorWorld.scrollLock)
            {
                if (camera.position.X + camera.velocity.X < 0 || camera.position.X + camera.velocity.X >= tileEngine.world.width * Tile.size)
                {
                    camera.velocity = new Vector2(0, camera.velocity.Y);
                }
                if (camera.position.Y + camera.velocity.Y < 0 || camera.position.Y + camera.velocity.Y >= tileEngine.world.height * Tile.size)
                {
                    camera.velocity = new Vector2(camera.velocity.X, 0);
                }
                if (fullscreen)
                {
                    camera.position += camera.velocity * 5 / (camera.scale - camera.scaleChange);
                }
                if (!fullscreen)
                {
                    camera.position += camera.velocity / (camera.scale - camera.scaleChange);
                }
            }
            else
            {
                if (editorWorld.scrollLock && !(guiComponent.focus is TextArea))
                {
                    camera.velocity = new Vector2(xmove.position, -ymove.position);

                    if (camera.position.X + camera.velocity.X < 0 || camera.position.X + camera.velocity.X >= tileEngine.world.width * Tile.size)
                    {
                        camera.velocity = new Vector2(0, camera.velocity.Y);
                    }
                    if (camera.position.Y + camera.velocity.Y < 0 || camera.position.Y + camera.velocity.Y >= tileEngine.world.height * Tile.size)
                    {
                        camera.velocity = new Vector2(camera.velocity.X, 0);
                    }
                    if (fullscreen)
                    {
                        camera.position += camera.velocity * 15 / (camera.scale - camera.scaleChange);
                    }
                    if (!fullscreen)
                    {
                        camera.position += camera.velocity * 15 / (camera.scale - camera.scaleChange);
                    }
                }
            }
        }