Esempio n. 1
1
        public Scrollbar ( string name, Vector2 position, Axis axis, Nullable<int> width, Nullable<int> height, int max, int value )//, Style style)
        {
            this.Type = ControlType.Scrollbar;
            this.name = name;
            this.position = position;
            this.axis = axis;
            //this.style = style;

            this.min = 0;
            this.max = max;
            this.value = value;

            switch (axis)
            {
                case Axis.Horizontal:
                    if (width.HasValue)
                        size.X = width.Value;
                    break;
                case Axis.Vertical:
                    if (height.HasValue)
                        size.Y = height.Value;
                    break;
            }

            Init();

            scrollUp.OnMousePress += new EventHandler( On_ScrollUp );
            scrollDown.OnMousePress += new EventHandler( On_ScrollDown );
            OnValueChange += new EventHandler( onValueChange );
        }
Esempio n. 2
0
        /// <summary>
        /// Starts a configuration for an axis change.
        /// </summary>
        /// <param name="axis">The axis for which a configuration should be added.</param>
        /// <returns>An axis action.</returns>
        public IAxisAction On(Axis axis)
        {
            var action = new AxisAction(axis);
            mAxesActions.Add(axis, action);

            return action;
        }
Esempio n. 3
0
 static CameraMethods()
 {
     UpAxis = Axis.Y;
 }
Esempio n. 4
0
 /// <summary>
 /// Flips the sprite texture based off a bool and axis.
 /// To flip back turn isFlip to false or use the second version.
 /// </summary>
 /// <param name="axis">The axis to flip on</param>
 protected void FlipSprite(Axis axis)
 {
     if (axis == Axis.Y)
     {
         FlipEffect = SpriteEffects.FlipHorizontally;
     }
     if (axis == Axis.X)
     {
         FlipEffect = SpriteEffects.FlipVertically;
     }
     if (axis == Axis.NONE)
     {
         FlipEffect = SpriteEffects.None;
     }
 }
        private void updaterotatesame(Ray mouseary)
        {
            MouseState mouseState = Mouse.GetState();
            if (!lockedaxis)
            {
                if (mouseState.RightButton == ButtonState.Pressed)
                    rc.UpdateData();
                else
                {
                    if (activeObject.Length != 0)
                    {
                        axis = rc.UpdateData(mouseary);
                        if (axis != Axis.none && mouseState.LeftButton == ButtonState.Pressed)
                        {
                            lockedaxis = true;
                            mymouse = true;
                        }
                        else
                        {
                            mymouse = false;
                            if (activeObject.Length == 1)
                            {
                                Quaternion q;
                                Vector3 v, vs;

                                activeObject[0].transform.Decompose(out vs, out q, out v);
                                GameEngine.renderController.setRotationSame(new string[] { q.X.ToString(), q.Y.ToString(), q.Z.ToString(), q.W.ToString() });
                            }
                            else
                                GameEngine.renderController.setRotationSame(new string[] { "0", "0", "0", "1" });
                        }
                    }
                    else GameEngine.renderController.setRelative(null);
                }
            }

            if (currentaction == null)
            {
                if (mouseState.LeftButton == ButtonState.Pressed && axis != Axis.none)
                {
                    //begin
                    lockedaxis = true;
                    currentaction = new Actions.RotateSamePivotAction(activeObject, axis, new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), rc.transform.Translation));
                    Quaternion res = (Quaternion)currentaction.ActionResult;

                    GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                }

            }
            else
            {
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released)
                {
                    //continue
                    lockedaxis = true;
                    currentaction.UpdateAction(new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), rc.transform.Translation));
                    // ma.SetTransformMatrix(activeObject.transform.TranslationMatrix());
                    rc.SetTransformMatrix(activeObject.middleMarix);
                    Quaternion res = (Quaternion)currentaction.ActionResult;
                    GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    return;
                }
                if (mouseState.LeftButton == ButtonState.Released && mouseState.RightButton == ButtonState.Released)
                {
                    //stop
                    lockedaxis = false;
                    if (currentaction.Valid())
                        editor.actions.AddNewAction(currentaction);
                    if (activeObject.Length == 1)
                    {
                        Quaternion res = (Quaternion)currentaction.ActionResult;
                        GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    }

                    currentaction = null;
                    axis = Axis.none;
                    return;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Pressed)
                {
                    //abort
                    currentaction.CancelAction(this.editor);

                    rc.SetTransformMatrix(activeObject.middleMarix);
                    lockedaxis = false;
                    if (activeObject.Length == 1)
                    {
                        Quaternion res = (Quaternion)currentaction.ActionResult;
                        GameEngine.renderController.setRotationSame(new string[] { res.X.ToString(), res.Y.ToString(), res.Z.ToString(), res.W.ToString() });
                    }
                    currentaction = null;
                    axis = Axis.none;
                    return;
                }
            }
        }
        private void updatemove(Ray mouseary)
        {
            MouseState mouseState = Mouse.GetState();
            if (!lockedaxis)
            {
                if (mouseState.RightButton == ButtonState.Pressed)
                    ma.UpdateData();
                else
                {
                    if (activeObject.Length != 0)
                    {
                        axis = ma.UpdateData(mouseary);
                        if (axis != Axis.none && mouseState.LeftButton == ButtonState.Pressed)
                        {
                            lockedaxis = true;
                            mymouse = true;
                        }
                        else
                            mymouse = false;
                    }
                }
            }

            if (currentaction == null)
            {
                Vector3 transl = ma.transform.Translation;
                if (activeObject.Length != 0 && mouseState.LeftButton == ButtonState.Pressed && axis != Axis.none)
                {
                    //begin
                    lockedaxis = true;
                    //Vector3 transl = ma.transform.Translation;
                    currentaction = new Actions.DragPivotObject(activeObject, axis, new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), transl));
                    if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else
                        GameEngine.renderController.setRelative(threezeros);
                }
                else
                    if (activeObject.Length == 0)
                        GameEngine.renderController.setRelative(null);
                    else if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else GameEngine.renderController.setRelative(threezeros);
            }
            else
            {
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released)
                {
                    //continue
                    lockedaxis = true;
                    Vector3 transl = ma.transform.Translation;
                    currentaction.UpdateAction(new Actions.PivotActionUpdateParameters(mouseary, new Vector2(mouseState.X, mouseState.Y), transl));
                    ma.SetTransformMatrix(activeObject.middleMarix);

                    Vector3 difference = (Vector3)currentaction.ActionResult;
                    GameEngine.renderController.setRelative(new string[] { difference.X.ToString(), difference.Y.ToString(), difference.Z.ToString() });

                    return;
                }
                if (mouseState.LeftButton == ButtonState.Released && mouseState.RightButton == ButtonState.Released)
                {
                    //stop
                    lockedaxis = false;
                    if(currentaction.Valid())
                        editor.actions.AddNewAction(currentaction);
                    currentaction = null;
                    axis = Axis.none;

                    if (activeObject.Length == 1)
                    {
                        Vector3 transl = ma.transform.Translation;
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    }
                    else
                        GameEngine.renderController.setRelative(threezeros);

                    return;
                }
                if (mouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Pressed)
                {
                    //abort
                    currentaction.CancelAction(this.editor);

                    ma.SetTransformMatrix(activeObject.middleMarix);
                    Vector3 transl = ma.transform.Translation;
                    if (activeObject.Length == 1)
                        GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                    else
                        GameEngine.renderController.setRelative(threezeros);

                    lockedaxis = false;
                    currentaction = null;
                    axis = Axis.none;
                    return;
                }

            }
        }
        public void SwitchState(TransformManagerState newstate)
        {
            if (newstate != currentState)
            {
                mymouse = false;
                lockedaxis = false;
                axis = Axis.none;
                if (currentaction != null)
                {
                    currentaction.CancelAction(this.editor);
                    ma.SetTransformMatrix(activeObject.middleMarix);
                    lockedaxis = false;
                    currentaction = null;
                    axis = Axis.none;
                }
                switch (newstate)
                {
                    case TransformManagerState.move:
                        {
                            if (activeObject.Length != 0)
                                ma.SetTransformMatrix(activeObject.middleMarix);

                            Vector3 transl = ma.transform.Translation;
                            if (activeObject.Length == 1)
                                GameEngine.renderController.setMove(new string[] { transl.X.ToString(), transl.Y.ToString(), transl.Z.ToString() });
                            else
                                GameEngine.renderController.setRelative(threezeros);
                        }break;
                    case TransformManagerState.rotatelocal:
                    case TransformManagerState.rotatesame:
                        {
                            if (activeObject.Length != 0)
                                rc.SetTransformMatrix(activeObject.middleMarix);
                        }break;
                }
                currentState = newstate;
            }
        }
Esempio n. 8
0
        public static Vector2 MoveSpriteOnMap(Axis axis, Vector2 previousPosition, Vector2 position, Point spriteSize, Hitbox spriteHitbox)
        {
            Vector2 point = new Vector2();
            float speed;
            float X = position.X;
            float Y = position.Y;
            int point1Index, point2Index;

            switch (axis)
            {
                case Axis.YAxis: //Up-Down
                    {
                        point.X = position.X;
                        speed = position.Y - previousPosition.Y;

                        if (previousPosition.Y > position.Y) //Up
                        {
                            if (speed >= 1 || speed <= 1)
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                {
                                    Y = previousPosition.Y;
                                    for (int i = 0; i < Math.Abs(speed); i++)
                                    {
                                        Y--;
                                        point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                        point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                        if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                        {
                                            Y++;
                                            break;
                                        }
                                    }
                                }
                                else
                                    Y = position.Y;
                                point.Y = Y;
                            }
                            else
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                    point.Y = previousPosition.Y;
                                else
                                    point.Y = Y;
                            }
                        }
                        else //Down
                        {
                            if (speed >= 1 || speed <= 1)
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                {
                                    Y = previousPosition.Y;
                                    for (int i = 0; i < Math.Abs(speed); i++)
                                    {
                                        Y++;
                                        point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                        point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                        if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                        {
                                            Y--;
                                            break;
                                        }
                                    }
                                }
                                else
                                    Y = position.Y;
                                point.Y = Y;
                            }
                            else
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                    point.Y = previousPosition.Y;
                                else
                                    point.Y = Y;
                            }
                        }
                        break;
                    }

                case Axis.XAxis: //Left-Right
                    {
                        point.Y = position.Y;
                        speed = position.X - previousPosition.X;

                        if (previousPosition.X > position.X) //Left
                        {
                            if (speed >= 1 || speed <= 1)
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                {
                                    X = previousPosition.X;
                                    for (int i = 0; i < Math.Abs(speed); i++)
                                    {
                                        X--;
                                        point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                        point2Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                        if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                        {
                                            X++;
                                            break;
                                        }
                                    }
                                }
                                else
                                    X = position.X;
                                point.X = X;
                            }
                            else
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x1, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                    point.X = previousPosition.X;
                                else
                                    point.X = X;
                            }
                        }
                        else //Right
                        {
                            if (speed >= 1 || speed <= 1)
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                {
                                    X = previousPosition.X;
                                    for (int i = 0; i < Math.Abs(speed); i++)
                                    {
                                        X++;
                                        point1Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                        point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                        if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                        {
                                            X--;
                                            break;
                                        }
                                    }
                                }
                                else
                                    X = position.X;
                                point.X = X;
                            }
                            else
                            {
                                point1Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y1);
                                point2Index = Position2MapIndex(X, Y, spriteHitbox.x2, spriteHitbox.y2);
                                if (TestPoints(point1Index, point2Index) || TestScreen(spriteSize, X, Y))
                                    point.X = previousPosition.X;
                                else
                                    point.X = X;
                            }
                        }

                    }
                    break;
            }
            return point;
        }
Esempio n. 9
0
File: Stick.cs Progetto: Zeludon/FEZ
 public Stick()
 {
   this.X = new Axis();
   this.Y = new Axis();
   this.Press = new Input();
 }