Example #1
0
        //Returns the two angles of aim calculating weapon accuracy (0 is left, 1 is right)
        public AccuracyAngle getAimAccuracyAngle(bool relative = false)
        {
            AccuracyAngle aimAccuracyAngle = new AccuracyAngle();
            float         fov = (float)Math.PI / 4f; //half view

            RangedWeapon weapon;

            if ((weapon = hands as RangedWeapon) != null)
            {
                fov -= (weapon.accuracy / 100) * Orientation.MaxAngle;
            }
            if (_sprinting)
            {
                fov += 0.15f;
            }
            else if (_aimlock)
            {
                fov -= 0.05f;
            }

            aimAccuracyAngle.left  = fov;
            aimAccuracyAngle.right = -fov;
            if (relative)
            {
                aimAccuracyAngle.left  += (_orientation);
                aimAccuracyAngle.right += (_orientation);
            }
            aimAccuracyAngle.EnforceConsistency();
            return(aimAccuracyAngle);
        }
Example #2
0
        public void drawAimLines(SpriteBatch spriteBatch, MainPlayer mainPlayer, Camera cam)
        {
            AccuracyAngle aimAccuracyAngle = mainPlayer.getAimAccuracyAngle();

            Vector2[] leftLine  = new Vector2[2];
            Vector2[] rightLine = new Vector2[2];

            leftLine[0]  = cam.getViewportCenter() + Player.getDirectionVector(Direction.Forward, aimAccuracyAngle.left, 100);
            leftLine[1]  = cam.getViewportCenter() + Player.getDirectionVector(Direction.Forward, aimAccuracyAngle.left, 120);
            rightLine[0] = cam.getViewportCenter() + Player.getDirectionVector(Direction.Forward, aimAccuracyAngle.right, 100);
            rightLine[1] = cam.getViewportCenter() + Player.getDirectionVector(Direction.Forward, aimAccuracyAngle.right, 120);
            DrawLine(spriteBatch, Resources.Pixel, leftLine[0], leftLine[1], Color.Yellow, 1);
            DrawLine(spriteBatch, Resources.Pixel, rightLine[0], rightLine[1], Color.Yellow, 1);
        }