Exemplo n.º 1
0
    public void Start()
    {
//		Cursor.visible = false;
        firstFrame = true;

        //Get Erase effect boundary area
        ScreenRect.x      = Dust.GetComponent <Renderer>().bounds.min.x;
        ScreenRect.y      = Dust.GetComponent <Renderer>().bounds.min.y;
        ScreenRect.width  = Dust.GetComponent <Renderer>().bounds.size.x;
        ScreenRect.height = Dust.GetComponent <Renderer>().bounds.size.y;

        dustDepth = Dust.transform.position.z - transform.position.z;

        brushRect.width  = EraserMaterial.mainTexture.width / 100.0f * brushSize;
        brushRect.height = EraserMaterial.mainTexture.height / 100.0f * brushSize;

        rt = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default);

        GetComponent <Camera>().targetTexture = rt;

        Dust.GetComponent <Renderer>().material.SetTexture("_MaskTex", rt);

        GenerateRects();

        audioSource = GetComponent <AudioSource>();

        dirCursor = CursorDirection.None;

        shakeDistance = Mathf.Sqrt((Screen.width * Screen.width) + (Screen.height * Screen.height)) * 5f / 100;

        cursorTexture.localScale = Vector3.one * cursorTextureSize * brushSize;
    }
Exemplo n.º 2
0
        public void Move(CursorDirection direction, int steps)
        {
            if (steps == 0)
            {
                return;
            }

            switch (direction)
            {
            case CursorDirection.Up:
                _backend.Write(new ControlCode(CUU(steps)));
                break;

            case CursorDirection.Down:
                _backend.Write(new ControlCode(CUD(steps)));
                break;

            case CursorDirection.Right:
                _backend.Write(new ControlCode(CUF(steps)));
                break;

            case CursorDirection.Left:
                _backend.Write(new ControlCode(CUB(steps)));
                break;
            }
        }
Exemplo n.º 3
0
        private int GetNewLocation(int location, CursorDirection direction)
        {
            if (direction == CursorDirection.Down)
            {
                location++;
                if (location == 3)
                {
                    location = m_moveWrapping ? 0 : 2;
                }
            }

            if (direction == CursorDirection.Up)
            {
                if (location == 0)
                {
                    location = m_moveWrapping ? 2 : 0;
                }
                else
                {
                    location--;
                }
            }

            return(location);
        }
Exemplo n.º 4
0
        public void Move(CursorDirection direction, int steps)
        {
            if (steps == 0)
            {
                return;
            }

            switch (direction)
            {
            case CursorDirection.Up:
                System.Console.CursorTop -= steps;
                break;

            case CursorDirection.Down:
                System.Console.CursorTop += steps;
                break;

            case CursorDirection.Left:
                System.Console.CursorLeft -= steps;
                break;

            case CursorDirection.Right:
                System.Console.CursorLeft += steps;
                break;
            }
        }
Exemplo n.º 5
0
        public void Move(CursorDirection direction, int steps)
        {
            if (steps == 0)
            {
                return;
            }

            switch (direction)
            {
            case CursorDirection.Up:
                _renderer.Write(Segment.Control($"\u001b[{steps}A"));
                break;

            case CursorDirection.Down:
                _renderer.Write(Segment.Control($"\u001b[{steps}B"));
                break;

            case CursorDirection.Right:
                _renderer.Write(Segment.Control($"\u001b[{steps}C"));
                break;

            case CursorDirection.Left:
                _renderer.Write(Segment.Control($"\u001b[{steps}D"));
                break;
            }
        }
Exemplo n.º 6
0
        public void MoveCursorInDirection(CursorDirection direction)
        {
            switch (direction)
            {
            case CursorDirection.Down:
                MapCoordinates.Y++;
                break;

            case CursorDirection.Right:
                MapCoordinates.X++;
                break;

            case CursorDirection.Up:
                MapCoordinates.Y--;
                break;

            case CursorDirection.Left:
                MapCoordinates.X--;
                break;

            default:
                throw new ArgumentOutOfRangeException("direction", direction, null);
            }

            PreventCursorLeavingMapBounds();
        }
Exemplo n.º 7
0
        public Boolean MoveCharacterCursor(CursorDirection direction, Point gridsize, Boolean wrapping)
        {
            Point newlocation = GetNewLocation(CurrentCell, direction, gridsize, wrapping);

            Boolean hasmoved = CurrentCell != newlocation;

            CurrentCell = newlocation;

            return(hasmoved);
        }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (ShouldCalculateAngle)
        {
            Angle          = GetAngle();
            SwipeDirection = GetDirection();

            ShouldCalculateAngle = false;
        }
    }
Exemplo n.º 9
0
        public bool MoveTeamModeCursor(CursorDirection direction)
        {
            var newlocation = GetNewLocation(CurrentLocation, direction);

            var hasmoved = CurrentLocation != newlocation;

            CurrentLocation = newlocation;

            return(hasmoved);
        }
Exemplo n.º 10
0
        public bool MoveCharacterCursor(CursorDirection direction, Point gridsize, bool wrapping)
        {
            var newlocation = GetNewLocation(CurrentCell, direction, gridsize, wrapping);

            var hasmoved = CurrentCell != newlocation;

            CurrentCell = newlocation;

            return(hasmoved);
        }
Exemplo n.º 11
0
 public bool MoveCharacterCursor(CursorDirection direction, Point gridsize, bool wrapping)
 {
     if (State == TeamSelectState.SelectSelf)
     {
         return(P1SelectData.MoveCharacterCursor(direction, gridsize, wrapping));
     }
     if (State == TeamSelectState.SelectMate)
     {
         return(P2SelectData.MoveCharacterCursor(direction, gridsize, wrapping));
     }
     return(false);
 }
Exemplo n.º 12
0
        void MoveCharacterSelection(SelectData data, CursorDirection direction)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            if (data.MoveCharacterCursor(direction, m_gridsize, m_wrapping) == true)
            {
                data.PlayCursorMoveSound();
            }
        }
Exemplo n.º 13
0
        private void MoveCharacterSelection(SelectData data, CursorDirection direction)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (data.MoveCharacterCursor(direction, Grid.Size, Grid.Wrapping))
            {
                data.PlayCursorMoveSound();
            }
        }
Exemplo n.º 14
0
        private void MoveTeamModeSelection(TeamSelectData data, CursorDirection direction)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (data.MoveTeamModeCursor(direction))
            {
                data.PlayCursorMoveSound();
            }
        }
Exemplo n.º 15
0
        private void pnImage_MouseDown(object sender, MouseEventArgs e)
        {
            int cX = this.cutRectangle.X;
            int cY = this.cutRectangle.Y;
            int cW = this.cutRectangle.Width;
            int cH = this.cutRectangle.Height;

            if (e.Button == MouseButtons.Left)
            {
                if (this.InCutRectangle(cX, cY, cW, cH, e))
                {
                    if (this.InCutRectangleTop(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eTop;
                    }
                    else if (this.InCutRectangleBottom(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eBottom;
                    }
                    else if (this.InCutRectangleLeft(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eLeft;
                    }
                    else if (this.InCutRectangleRight(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eRight;
                    }
                    else if (this.InCutRectangleLeftOrTop(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eLeftTop;
                    }
                    else if (this.InCutRectangleRightOrTop(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eRightTop;
                    }
                    else if (this.InCutRectangleLeftOrBottom(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eLeftBottom;
                    }
                    else if (this.InCutRectangleRightOrBottom(cX, cY, cW, cH, e))
                    {
                        this.currentCursor = CursorDirection.eRightBottom;
                    }
                    else
                    {
                        this.currentCursor = CursorDirection.eMove;
                    }
                    this.currentPos = e.Location;
                    this.startMove  = true;
                }
            }
        }
Exemplo n.º 16
0
                public void Should_Return_Correct_Ansi_Code(CursorDirection direction, string expected)
                {
                    // Given
                    var console = new FakeAnsiConsole(ColorSystem.Standard, AnsiSupport.Yes);

                    // When
                    console.Write("Hello");
                    console.Cursor.Move(direction, 2);
                    console.Write("World");

                    // Then
                    console.Output.ShouldBe(expected);
                }
Exemplo n.º 17
0
                public void Should_Return_Correct_Ansi_Code(CursorDirection direction, string expected)
                {
                    // Given
                    var console = new TestConsole().EmitAnsiSequences();

                    // When
                    console.Write("Hello");
                    console.Cursor.Move(direction, 2);
                    console.Write("World");

                    // Then
                    console.Output.ShouldBe(expected);
                }
Exemplo n.º 18
0
    private bool CheckShake()
    {
        if (Input.mousePosition.x >= 0 && Input.mousePosition.x <= Screen.width &&
            Input.mousePosition.y >= 0 && Input.mousePosition.y <= Screen.height)
        {
            if (minCursor == null)
            {
                minCursor = Input.mousePosition;

                list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(minCursor.Value.x, minCursor.Value.y, dustDepth)));
                return(false);
            }

            maxCursor = Input.mousePosition;
            Vector2 mouseDir = maxCursor - minCursor.Value;

            if (Vector2.Distance(minCursor.Value, maxCursor) > shakeDistance)
            {
                CursorDirection tempDirCursor;
                if (mouseDir.x >= 0)
                {
                    tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightUp : CursorDirection.LeftUp;
                }
                else
                {
                    tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightDown : CursorDirection.LeftDown;
                }

                if (dirCursor != tempDirCursor)
                {
                    if (dirCursor != CursorDirection.None)
                    {
                        shakeIterations++;
                        //					print ("Shake Iteration From " + dirCursor + " To " + tempDirCursor + " / " + shakeIterations);

                        list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(minCursor.Value.x, minCursor.Value.y, dustDepth)));
                        list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(maxCursor.x, maxCursor.y, dustDepth)));
                    }
                    minCursor = Input.mousePosition;
                    dirCursor = tempDirCursor;
                }

                if (shakeIterations == 2)
                {
                    shakeIterations = 0;
                    return(true);
                }
            }
        }
        return(false);
    }
Exemplo n.º 19
0
        private bool CheckShake()
        {
            if (Input.mousePosition.x >= 0 && Input.mousePosition.x <= Screen.width &&
                Input.mousePosition.y >= 0 && Input.mousePosition.y <= Screen.height)
            {
                if (minCursor == null)
                {
                    minCursor = Input.mousePosition;
                    return(false);
                }

                maxCursor = Input.mousePosition;
                Vector2 mouseDir = maxCursor - minCursor.Value;

                if (Vector2.Distance(minCursor.Value, maxCursor) > shakeDistance)
                {
                    CursorDirection tempDirCursor;
                    if (mouseDir.x >= 0)
                    {
                        tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightUp : CursorDirection.LeftUp;
                    }
                    else
                    {
                        tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightDown : CursorDirection.LeftDown;
                    }

                    if (dirCursor != tempDirCursor)
                    {
                        if (dirCursor != CursorDirection.None)
                        {
                            shakeIterations++;
                        }

                        minCursor = Input.mousePosition;
                        dirCursor = tempDirCursor;
                    }

                    if (shakeIterations == 2)
                    {
                        shakeIterations = 0;
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Sets cursor move direction and specifies display shift. These operations are
        /// performed during data write and read.
        /// </summary>
        /// <param name="displayShift">Enable or disable display shifting</param>
        /// <param name="cursorDirection">Cursor move direction</param>
        public void EntryModeSet(DisplayShift displayShift, CursorDirection cursorDirection)
        {
            //  DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
            //  0   0   0   0   0   1   I/D S

            byte entryModeCmd = ENTRY_MODE_SET;

            // if requested display shifting
            if (displayShift == DisplayShift.Yes)
            {
                entryModeCmd |= DISPLAY_SHIFT_ENABLE;
            }

            // cursor direction if display shifting enabled
            if (cursorDirection == CursorDirection.Increment)
            {
                entryModeCmd |= CURSOR_DIRECTION_INCREMENT;
            }

            this.SendCommand(entryModeCmd); // 37 us (datasheet)
        }
Exemplo n.º 21
0
 public Request OpenKeyCursor(object range, CursorDirection direction)
 {
     return default(Request);
 }
Exemplo n.º 22
0
        //カーソルの見た目変更
        private void FlatThumb_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = e.GetPosition(this);
            bool  isNoth = false, isSouth = false, isEast = false, isWest = false;

            if (p.X < cMargin)
            {
                isWest = true;
            }
            if (p.X > Width - cMargin)
            {
                isEast = true;
            }
            if (p.Y < cMargin)
            {
                isNoth = true;
            }
            if (p.Y > Height - cMargin)
            {
                isSouth = true;
            }

            if (isNoth)//北
            {
                Cursor            = Cursors.SizeNS;
                MyCursorDirection = CursorDirection.Noth;
                if (isWest)//北西
                {
                    Cursor            = Cursors.SizeNWSE;
                    MyCursorDirection = CursorDirection.NothWest;
                }
                else if (isEast)//北東
                {
                    Cursor            = Cursors.SizeNESW;
                    MyCursorDirection = CursorDirection.NothEast;
                }
            }
            else if (isSouth)//南
            {
                Cursor            = Cursors.SizeNS;
                MyCursorDirection = CursorDirection.South;
                if (isWest)//南西
                {
                    Cursor            = Cursors.SizeNESW;
                    MyCursorDirection = CursorDirection.SouthWest;
                }
                else if (isEast)//南東
                {
                    Cursor            = Cursors.SizeNWSE;
                    MyCursorDirection = CursorDirection.SouthEast;
                }
            }
            else if (isWest)//西
            {
                Cursor            = Cursors.SizeWE;
                MyCursorDirection = CursorDirection.West;
            }
            else if (isEast)//東
            {
                Cursor            = Cursors.SizeWE;
                MyCursorDirection = CursorDirection.East;
            }
            else//その他
            {
                Cursor            = Cursors.Arrow;
                MyCursorDirection = CursorDirection.None;
            }
        }
    private bool CheckShake()
    {
        if(Input.mousePosition.x >= 0 && Input.mousePosition.x <= Screen.width
           && Input.mousePosition.y >= 0 && Input.mousePosition.y <= Screen.height)
        {
            if(minCursor == null)
            {
                minCursor =  Input.mousePosition;

                list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(minCursor.Value.x, minCursor.Value.y, dustDepth)));
                return false;
            }

            maxCursor = Input.mousePosition;
            Vector2 mouseDir = maxCursor - minCursor.Value;

            if(Vector2.Distance(minCursor.Value,maxCursor) > shakeDistance)
            {
                CursorDirection tempDirCursor;
                if(mouseDir.x >= 0)
                    tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightUp : CursorDirection.LeftUp;
                else
                    tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightDown : CursorDirection.LeftDown;

                if(dirCursor != tempDirCursor)
                {
                    if(dirCursor != CursorDirection.None)
                    {
                        shakeIterations ++;
        //					print ("Shake Iteration From " + dirCursor + " To " + tempDirCursor + " / " + shakeIterations);

                        list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(minCursor.Value.x, minCursor.Value.y, dustDepth)));
                        list_ShakePoints.Add(Camera.main.ScreenToWorldPoint(new Vector3(maxCursor.x, maxCursor.y, dustDepth)));
                    }
                    minCursor =  Input.mousePosition;
                    dirCursor = tempDirCursor;
                }

                if(shakeIterations == 2)
                {
                    shakeIterations = 0;
                    return true;
                }
            }
        }
        return false;
    }
    public void Start()
    {
        //		Cursor.visible = false;
        firstFrame = true;

        //Get Erase effect boundary area
        ScreenRect.x = Dust.GetComponent<Renderer>().bounds.min.x;
        ScreenRect.y = Dust.GetComponent<Renderer>().bounds.min.y;
        ScreenRect.width = Dust.GetComponent<Renderer>().bounds.size.x;
        ScreenRect.height = Dust.GetComponent<Renderer>().bounds.size.y;

        dustDepth = Dust.transform.position.z - transform.position.z;

        brushRect.width = EraserMaterial.mainTexture.width / 100.0f * brushSize;
        brushRect.height = EraserMaterial.mainTexture.height / 100.0f * brushSize;

        rt = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default);

        GetComponent<Camera>().targetTexture = rt;

        Dust.GetComponent<Renderer>().material.SetTexture("_MaskTex", rt);

        GenerateRects ();

        audioSource = GetComponent<AudioSource>();

        dirCursor = CursorDirection.None;

        shakeDistance = Mathf.Sqrt((Screen.width * Screen.width) + (Screen.height * Screen.height)) * 5f / 100;

        cursorTexture.localScale = Vector3.one * cursorTextureSize * brushSize;
    }
Exemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     ShouldCalculateAngle = false;
     SwipeDirection       = CursorDirection.None;
 }
Exemplo n.º 26
0
        public Boolean MoveCharacterCursor(CursorDirection direction, Point gridsize, Boolean wrapping)
        {
            Point newlocation = GetNewLocation(CurrentCell, direction, gridsize, wrapping);

            Boolean hasmoved = CurrentCell != newlocation;

            CurrentCell = newlocation;

            return hasmoved;
        }
Exemplo n.º 27
0
 public Request OpenKeyCursor(object range, CursorDirection direction)
 {
     return(default(Request));
 }
Exemplo n.º 28
0
        /// <summary>
        /// Sets cursor move direction and specifies display shift. These operations are
        /// performed during data write and read.
        /// </summary>
        /// <param name="displayShift">Enable or disable display shifting</param>
        /// <param name="cursorDirection">Cursor move direction</param>
        public void EntryModeSet(DisplayShift displayShift, CursorDirection cursorDirection)
        {
            //  DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
            //  0   0   0   0   0   1   I/D S

            byte entryModeCmd = ENTRY_MODE_SET;

            // if requested display shifting
            if (displayShift == DisplayShift.Yes)
                entryModeCmd |= DISPLAY_SHIFT_ENABLE;

            // cursor direction if display shifting enabled
            if (cursorDirection == CursorDirection.Increment)
                entryModeCmd |= CURSOR_DIRECTION_INCREMENT;

            this.SendCommand(entryModeCmd); // 37 us (datasheet)
        }
Exemplo n.º 29
0
        Point GetNewLocation(Point location, CursorDirection direction, Point gridsize, Boolean wrapping)
        {
            if (direction == CursorDirection.Down)
            {
                Point newlocation = location + new Point(0, 1);
                if (newlocation.Y > gridsize.Y - 1)
                {
                    if (wrapping == false)
                    {
                        return(location);
                    }
                    newlocation.Y = 0;
                }

                for (Int32 i = newlocation.Y; i < gridsize.Y; ++i)
                {
                    newlocation.Y = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true)
                    {
                        return(newlocation);
                    }
                }
            }

            if (direction == CursorDirection.Up)
            {
                Point newlocation = location + new Point(0, -1);
                if (newlocation.Y < 0)
                {
                    if (wrapping == false)
                    {
                        return(location);
                    }
                    newlocation.Y = gridsize.Y - 1;
                }

                for (Int32 i = newlocation.Y; i >= 0; --i)
                {
                    newlocation.Y = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true)
                    {
                        return(newlocation);
                    }
                }
            }

            if (direction == CursorDirection.Left)
            {
                Point newlocation = location + new Point(-1, 0);
                if (newlocation.X < 0)
                {
                    if (wrapping == false)
                    {
                        return(location);
                    }
                    newlocation.X = gridsize.X - 1;
                }

                for (Int32 i = newlocation.X; i >= 0; --i)
                {
                    newlocation.X = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true)
                    {
                        return(newlocation);
                    }
                }
            }

            if (direction == CursorDirection.Right)
            {
                Point newlocation = location + new Point(1, 0);
                if (newlocation.X > gridsize.X - 1)
                {
                    if (wrapping == false)
                    {
                        return(location);
                    }
                    newlocation.X = 0;
                }

                for (Int32 i = newlocation.X; i < gridsize.X; ++i)
                {
                    newlocation.X = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true)
                    {
                        return(newlocation);
                    }
                }
            }

            return(location);
        }
Exemplo n.º 30
0
        public void Update(SceneContext c, GameTime gt)
        {
            if (c.IsFlagSetOR(GameFlagMask.CROSSHAIR_HIDE_MASK))
            {
                pj.WorldAnchorB = this.FocusedEntity.Mesh.Body.Position;
                return;
            }



            float dx = 0;
            float dy = 0;

            //InputConfig ic = InputConfig.Instance;
            //if (ic.RIGHT_AXIS.WasMoved)
            //{
            //    dx = ic.RIGHT_AXIS.DX;
            //    dy = ic.RIGHT_AXIS.DY;
            //}
            //else
            //{
            //    dx = ic.MOUSE.DX;
            //    dy = ic.MOUSE.DY;
            //}


            foreach (Axis a in this.ListeningAxis)
            {
                if (a.WasMoved)
                {
                    dx = a.DX;
                    dy = a.DY;
                    break;
                }
            }

            //   // Ray berechnen -> das ist die richtung/bahn auf der projektiele fliegen werden -> wird vom offsetpunkt an berechnet
            CursorDirection = this.FocusedEntity.Mesh.Body.Position - this.Sensor.Position; //Vector2.Subtract(actorData.RightHandOffset, new Vector2(this.X, this.Y));
            CursorDirection.Normalize();
            CursorDirection = Vector2.Negate(CursorDirection);


            // player rotation setzen
            float bodyAngle = this.FocusedEntity.Mesh.Body.Rotation;

            float desiredAngle = -VectorMath.GetAngle(CursorDirection);



            float speed = this.FocusedEntity.GetAttribute <ActorDataAttribute>().RotationSpeed;

            /// source: http://www.iforce2d.net/b2dtut/rotate-to-angle
            float nextAngle     = bodyAngle + this.FocusedEntity.Mesh.Body.AngularVelocity / speed;
            float totalRotation = desiredAngle - nextAngle;

            while (totalRotation < -180 * DEGTORAD)
            {
                totalRotation += 360 * DEGTORAD;
            }
            while (totalRotation > 180 * DEGTORAD)
            {
                totalRotation -= 360 * DEGTORAD;
            }
            float desiredAngularVelocity = totalRotation * speed;

            float torque = this.FocusedEntity.Mesh.Body.Inertia * desiredAngularVelocity / (1 / speed);

            this.FocusedEntity.Mesh.Body.ApplyTorque(torque);


            // position:
            this.relativePos -= ConvertUnits.ToSimUnits(new Vector2(dx, dy) * CursorSensitivity);

            if (VectorMath.Distance(new Vector2(), this.relativePos) >= ConvertUnits.ToSimUnits(this.CursorRange))
            {
                //nicht die ray nemen, sondern vom mittelpunkt des spielers ausgehen
                Vector2 rangeDir = this.relativePos;
                rangeDir.Normalize();

                this.relativePos = rangeDir * ConvertUnits.ToSimUnits(this.CursorRange);
            }

            pj.WorldAnchorB = this.FocusedEntity.Mesh.Body.Position + this.relativePos;


            foreach (ICrosshairDrawableProcessor dp in this.drawableProcessor)
            {
                dp.Update(c, gt);
            }

            // Update Tool
            if (this.SelectedTool != null)
            {
                if (this.PrimaryAction.WasPressed)
                {
                    this.SelectedTool.OnPrimaryDown(c);
                }

                if (this.PrimaryAction.WasReleased)
                {
                    this.SelectedTool.OnPrimaryUp(c);
                }

                if (this.SecondaryAction.WasPressed)
                {
                    this.SelectedTool.OnSecondaryDown(c);
                }

                if (this.SecondaryAction.WasReleased)
                {
                    this.SelectedTool.OnSecondaryUp(c);
                }

                this.SelectedTool.Update(c, gt);
            }
        }
Exemplo n.º 31
0
        Point GetNewLocation(Point location, CursorDirection direction, Point gridsize, Boolean wrapping)
        {
            if (direction == CursorDirection.Down)
            {
                Point newlocation = location + new Point(0, 1);
                if (newlocation.Y > gridsize.Y - 1)
                {
                    if (wrapping == false) return location;
                    newlocation.Y = 0;
                }

                for (Int32 i = newlocation.Y; i < gridsize.Y; ++i)
                {
                    newlocation.Y = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true) return newlocation;
                }
            }

            if (direction == CursorDirection.Up)
            {
                Point newlocation = location + new Point(0, -1);
                if (newlocation.Y < 0)
                {
                    if (wrapping == false) return location;
                    newlocation.Y = gridsize.Y - 1;
                }

                for (Int32 i = newlocation.Y; i >= 0; --i)
                {
                    newlocation.Y = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true) return newlocation;
                }
            }

            if (direction == CursorDirection.Left)
            {
                Point newlocation = location + new Point(-1, 0);
                if (newlocation.X < 0)
                {
                    if (wrapping == false) return location;
                    newlocation.X = gridsize.X - 1;
                }

                for (Int32 i = newlocation.X; i >= 0; --i)
                {
                    newlocation.X = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true) return newlocation;
                }
            }

            if (direction == CursorDirection.Right)
            {
                Point newlocation = location + new Point(1, 0);
                if (newlocation.X > gridsize.X - 1)
                {
                    if (wrapping == false) return location;
                    newlocation.X = 0;
                }

                for (Int32 i = newlocation.X; i < gridsize.X; ++i)
                {
                    newlocation.X = i;
                    PlayerSelect selection = SelectScreen.GetSelection(newlocation, true);
                    if (selection != null || m_moveoverempty == true) return newlocation;
                }
            }

            return location;
        }
Exemplo n.º 32
0
 public void Move(CursorDirection direction, int steps)
 {
 }
Exemplo n.º 33
0
        private void MoveCursorInDirectionNew(CursorDirection direction)
        {
            if (this.currentlySnappedComponent == null && this.allClickableComponents != null && this.allClickableComponents.Count <ClickableComponent>() > 0)
            {
                this.snapToDefaultClickableComponent();
                if (this.currentlySnappedComponent == null)
                {
                    this.currentlySnappedComponent = this.allClickableComponents.First <ClickableComponent>();
                }
            }
            if (this.currentlySnappedComponent == null)
            {
                return;
            }

            ClickableComponent snappedComponent = this.currentlySnappedComponent;

            switch (direction)
            {
            case CursorDirection.Up:
                if (this.currentlySnappedComponent.upNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.upNeighborID == -7777)
                {
                    this.customSnapBehavior(0, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.upNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.upNeighborID != -7777) && (!this.currentlySnappedComponent.downNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.downNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(0, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.Right:
                if (this.currentlySnappedComponent.rightNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.rightNeighborID == -7777)
                {
                    this.customSnapBehavior(1, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }

                // Code added: Sets the correct snapped component (first lost book) when the [Lost Books] sidetab is selected
                // and the player presses the [Right] button to snap to a book item. Previously, the snapped component was set to
                // the component with ID = 0 in the collections page. The first item with ID = 0 is the first item in the [Shipped] tab
                // and has the wrong item offset. As a result, continous right-snapping or below snapping would fail to snap to the correct
                // [Lost Book].
                else if (this.currentlySnappedComponent.myID >= region_sideTabShipped &&
                         this.currentlySnappedComponent.myID <= region_sideTabLostBooks &&
                         ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue() == lostBooksTabPageIndex)
                {
                    this.currentlySnappedComponent = this.getComponentWithID(LostBooksTab_ItemBaseId);
                }

                // Code added: Sets the correct snapped component (first lost book) when a sidetab other than [Lost Books] is selected
                // and the player presses the [Right] button to snap to an item while the [Lost Books] item is snapped.
                // Without this code the snapped item will be treated as a [Lost Book] (with its non-standard item offset).
                // Since the item offset is the same for every sidetab other than [Lost Books], we simply set the currently snapped item
                // to the first item with ID = 0 which is the first item for every original sidetab.
                else if (this.currentlySnappedComponent.myID == region_sideTabLostBooks &&
                         ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue() != lostBooksTabPageIndex)
                {
                    this.currentlySnappedComponent = this.getComponentWithID(0);
                }

                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.rightNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.rightNeighborID != -7777) && (!this.currentlySnappedComponent.leftNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.leftNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null && snappedComponent.tryDefaultIfNoRightNeighborExists)
                {
                    this.snapToDefaultClickableComponent();
                    break;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(1, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.Down:
                if (this.currentlySnappedComponent.downNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.downNeighborID == -7777)
                {
                    this.customSnapBehavior(2, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.downNeighborID);
                }
                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.downNeighborID != -7777) && (!this.currentlySnappedComponent.upNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.upNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null && snappedComponent.tryDefaultIfNoDownNeighborExists)
                {
                    this.snapToDefaultClickableComponent();
                    break;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(2, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;

            case CursorDirection.Left:
                if (this.currentlySnappedComponent.leftNeighborID == -99999)
                {
                    this.snapToDefaultClickableComponent();
                }
                else if (this.currentlySnappedComponent.leftNeighborID == -7777)
                {
                    this.customSnapBehavior(3, this.currentlySnappedComponent.region, this.currentlySnappedComponent.myID);
                }
                else
                {
                    //this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.leftNeighborID);

                    // Addd code: This addition makes sure that the cursor will snap to the selected sidetab (and not the first tab)
                    // when the player presses [Left] when on the leftmost column of a collections page.
                    var currentTab = ModEntry.CommonServices.ReflectionHelper.GetField <int>(this, "currentTab").GetValue();
                    if (this.currentlySnappedComponent.leftNeighborID >= sideTabs_FirstIndex &&
                        this.currentlySnappedComponent.leftNeighborID <= sideTabs_FirstIndex + secretNotesTab &&
                        this.currentlySnappedComponent.leftNeighborID != sideTabs_FirstIndex + currentTab)
                    {
                        //var currentTab = ModEntry.CommonServices.ReflectionHelper.GetField<int>(this, "currentTab").GetValue();

                        this.currentlySnappedComponent.leftNeighborID = sideTabs_FirstIndex + currentTab;
                        this.currentlySnappedComponent = this.getComponentWithID(sideTabs_FirstIndex + currentTab);
                    }
                    else
                    {
                        this.currentlySnappedComponent = this.getComponentWithID(this.currentlySnappedComponent.leftNeighborID);
                    }
                }

                if (this.currentlySnappedComponent != null && (snappedComponent == null || snappedComponent.leftNeighborID != -7777) && (!this.currentlySnappedComponent.rightNeighborImmutable && !this.currentlySnappedComponent.fullyImmutable))
                {
                    this.currentlySnappedComponent.rightNeighborID = snappedComponent.myID;
                }
                if (this.currentlySnappedComponent == null)
                {
                    this.noSnappedComponentFound(3, snappedComponent.region, snappedComponent.myID);
                    break;
                }
                break;
            }

            if (this.currentlySnappedComponent != null && snappedComponent != null && this.currentlySnappedComponent.region != snappedComponent.region)
            {
                this.actionOnRegionChange(snappedComponent.region, this.currentlySnappedComponent.region);
            }

            if (this.currentlySnappedComponent == null)
            {
                this.currentlySnappedComponent = snappedComponent;
            }

            this.snapCursorToCurrentSnappedComponent();
            Game1.playSound("shiny4");
        }
Exemplo n.º 34
0
        private bool CheckShake()
        {
            if(Input.mousePosition.x >= 0 && Input.mousePosition.x <= Screen.width
               && Input.mousePosition.y >= 0 && Input.mousePosition.y <= Screen.height)
            {
                if(minCursor == null)
                {
                    minCursor =  Input.mousePosition;
                    return false;
                }

                maxCursor = Input.mousePosition;
                Vector2 mouseDir = maxCursor - minCursor.Value;

                if(Vector2.Distance(minCursor.Value,maxCursor) > shakeDistance)
                {
                    CursorDirection tempDirCursor;
                    if(mouseDir.x >= 0)
                        tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightUp : CursorDirection.LeftUp;
                    else
                        tempDirCursor = mouseDir.y >= 0 ? CursorDirection.RightDown : CursorDirection.LeftDown;

                    if(dirCursor != tempDirCursor)
                    {
                        if(dirCursor != CursorDirection.None)
                            shakeIterations ++;

                        minCursor =  Input.mousePosition;
                        dirCursor = tempDirCursor;
                    }

                    if(shakeIterations == 2)
                    {
                        shakeIterations = 0;
                        return true;
                    }
                }
            }
            return false;
        }