Пример #1
0
        public Axis AddNewAxisFor(AxisTypes axisType)
        {
            var axis = new Axis(axisType);

            AddAxis(axis);
            return(axis);
        }
Пример #2
0
        public void MoveTo(AxisTypes axis, double step, double speed, CancellationToken token, Action <MotorInfoMap <double>, MotorInfoMap <double> > infoHandler)
        {
            var line = new LineSegment();

            if (axis == AxisTypes.AxisX)
            {
                line.XDistance = step;
                line.XSpeed    = speed;
            }
            else if (axis == AxisTypes.AxisY)
            {
                line.YDistance = step;
                line.YSpeed    = speed;
            }
            else if (axis == AxisTypes.AxisZ)
            {
                line.ZDistance = step;
                line.ZSpeed    = speed;
            }

            var lines = new List <LineSegment> {
                line
            };

            this.Motor.MoveAsync(lines, token, infoHandler).Wait();
        }
Пример #3
0
 private void addOrdinateToLegendEntry(IEnumerable <Plot> plots, AxisTypes ordinate)
 {
     foreach (var plot in plots)
     {
         plot.LegendEntry = string.Format("({0}) {1}", ordinate, plot.LegendEntry);
     }
 }
Пример #4
0
 public void SetCurrentPos(AxisTypes axis, int pos)
 {
     this.mutex.WaitOne();
     this.motorInfoMap[axis].CurrrentPos = pos;
     this.Save();
     this.mutex.ReleaseMutex();
 }
Пример #5
0
 public void SetMovingStatus(AxisTypes axis, bool flag)
 {
     this.mutex.WaitOne();
     this.motorInfoMap[axis].IsMoving = flag;
     this.Save();
     this.mutex.ReleaseMutex();
 }
Пример #6
0
 private void addOrdinateToLegendEntry(IEnumerable <Plot> plots, AxisTypes ordinate)
 {
     foreach (var plot in plots)
     {
         plot.LegendEntry = $"({ordinate}) {plot.LegendEntry}";
     }
 }
Пример #7
0
 public void SetEncoder(AxisTypes axis, int pos)
 {
     this.mutex.WaitOne();
     this.motorInfoMap[axis].Encoder = pos;
     this.Save();
     this.mutex.ReleaseMutex();
 }
Пример #8
0
        public void SetAxis(int index, AxisTypes axisType, int value)
        {
            var device = GetDevice(index);

            if(value < device.LowerRange || value > device.UpperRange)
            {
                throw new Exception(string.Format("Valid axis value {0} to {1}", device.LowerRange, device.UpperRange));
            }

            int newValue = (VirtualJoystick.MaxAnalogDataSourceVal/2) + 1;

            if(value < 0)
            {
                var ratio = (double)value/device.LowerRange;
                newValue = newValue - (int)(newValue*ratio);
            } 
            else if(value > 0)
            {
                var ratio = (double)value/device.UpperRange;
                newValue = (int)(newValue*ratio) + newValue;
            }

            device.Joystick.SetAnalogDataSourceValue((int)axisType, newValue);

        }
Пример #9
0
    /// <summary>
    /// Builds a string to get the controller by player.
    /// </summary>
    /// <param name="player"></param>
    /// <param name="axis"></param>
    /// <param name="type"></param>
    /// <param name="atype"></param>
    /// <returns></returns>
    public static string GetInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, AnalogTypes atype)
    {
        Vector2      point;
        JoystickType joystickType = GetControllerType(player);

        switch (joystickType)
        {
        case JoystickType.ps3:
            //Note We don't care if the axis is X or Y,  we just want to check for input from normalized.
            #region PS3 Controller
            point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Right)));
            if (point.x != 0f || point.y != 0f)
            {
                return(CheckInput(player, axis, JoystickType.ps3, atype));
            }
            if (atype.Equals(AnalogTypes.DPad))
            {
                return(CheckInput(player, axis, JoystickType.ps3, atype));
            }
            #endregion
            return(string.Empty);

        case JoystickType.xbox:
            #region xbox360
            point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Right)));
            if (point.x != 0f || point.y != 0f)
            {
                return(CheckInput(player, axis, JoystickType.xbox, atype));
            }
            if (atype.Equals(AnalogTypes.DPad))
            {
                return(CheckInput(player, axis, JoystickType.xbox, atype));
            }
            if (atype.Equals(AnalogTypes.LTRT))
            {
                return(CheckInput(player, axis, JoystickType.xbox, atype));
            }
            #endregion
            return(string.Empty);

        case JoystickType.ouya:
            point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Right)));
            if (point.x != 0f || point.y != 0f)
            {
                return(CheckInput(player, axis, JoystickType.ouya, atype));
            }
            if (atype.Equals(AnalogTypes.DPad))
            {
                return(CheckInput(player, axis, JoystickType.ouya, atype));
            }
            if (atype.Equals(AnalogTypes.LTRT))
            {
                return(CheckInput(player, axis, JoystickType.ouya, atype));
            }
            return(string.Empty);

        default:
            return("Horizontal");
        }
    }
Пример #10
0
        public int GetCurrentPos(AxisTypes axis)
        {
            this.mutex.WaitOne();
            int pos = this.motorInfoMap[axis].CurrrentPos;

            this.mutex.ReleaseMutex();
            return(pos);
        }
Пример #11
0
        public int GetEncoder(AxisTypes axis)
        {
            this.mutex.WaitOne();
            int pos = this.motorInfoMap[axis].Encoder;

            this.mutex.ReleaseMutex();
            return(pos);
        }
Пример #12
0
        public AxisInfoView(AxisChart chart, AxisTypes axisType)
        {
            this.Chart    = chart;
            this.AxisType = axisType;

            this.FillColor = SolidColor.Transparent;
            this.LineColor = SolidColor.Transparent;
            this.FontSize *= 0.9f;
        }
Пример #13
0
        public AxisInfoView(AxisChart chart, AxisTypes axisType, AxisOrientation orientation)
        {
            Chart       = chart;
            AxisType    = axisType;
            Orientation = orientation;

            FillColor = SolidColor.Transparent;
            LineColor = SolidColor.Transparent;
            FontSize *= 0.9f;
        }
Пример #14
0
 public T this[AxisTypes axis]
 {
     get
     {
         return(this.posMap[axis]);
     }
     set
     {
         this.posMap[axis] = value;
     }
 }
Пример #15
0
 public CurveOptions()
 {
     _interpolationMode = InterpolationModes.xLinear;
     _yAxisType         = AxisTypes.Y;
     _visible           = true;
     _color             = Color.Black;
     _lineStyle         = LineStyles.Solid;
     _symbol            = Symbols.None;
     _lineThickness     = 2;
     _shouldShowLLOQ    = true;
     _visibleInLegend   = true;
 }
Пример #16
0
        private void updateAxesForRemovedCurve(AxisTypes yAxisType)
        {
            if (!Curves.Any())
            {
                _axes[AxisTypes.X].Reset();
            }

            if (Curves.All(c => c.yAxisType != yAxisType))
            {
                _axes[yAxisType].Reset();
            }
        }
Пример #17
0
        public float GetAxis(AxisTypes action)
        {
            switch (action)
            {
            case AxisTypes.Grip:
                return(squeeze);

            case AxisTypes.Trigger:
                return(trigger);
            }
            return(0);
        }
Пример #18
0
        public Axis AddNewAxisFor(AxisTypes axisType)
        {
            var newAxis = new Axis(axisType);

            _axes.Add(newAxis);

            if (newAxis.IsYAxis)
            {
                newAxis.Scaling = DefaultYAxisScaling;
            }

            return(newAxis);
        }
Пример #19
0
        public float GetAxis(AxisTypes action)
        {
            TryUpdateButtons();
            switch (action)
            {
            case AxisTypes.Grip:
                return(squeeze);

            case AxisTypes.Trigger:
                return(trigger);
            }
            return(0);
        }
Пример #20
0
 protected CurveBinder(Curve curve, ChartControl chartControl, CurveChart chart, AxisYBase yAxisView, DataMode dataMode)
 {
     _chartControl = chartControl;
     _axisView     = yAxisView;
     _dataMode     = dataMode;
     Curve         = curve;
     _xAxis        = chart.AxisBy(AxisTypes.X);
     _yAxis        = chart.AxisBy(curve.yAxisType);
     _yAxisType    = curve.yAxisType;
     _dataTable    = new DataTable(Curve.Id);
     _series       = new List <Series>();
     _LLOQSeriesId = string.Empty;
     initializeData();
 }
Пример #21
0
        private AxisOptions getAxisOptions(CurveChart chart, AxisTypes yAxisType)
        {
            var legendOptions = new LegendOptions
            {
                LegendPosition  = getLegendPosition(chart.ChartSettings.LegendPosition),
                LegendAlignment = LegendOptions.LegendAlignments.left,
                FontSize        = LegendOptions.FontSizes.scriptsize,
                RoundedCorners  = false
            };

            var axisOptions = new AxisOptions(DefaultConverter.Instance)
            {
                LegendOptions   = legendOptions,
                Title           = chart.Title,
                BackgroundColor = chart.ChartSettings.DiagramBackColor.Name,
                EnlargeLimits   = chart.ChartSettings.SideMarginsEnabled
            };

            foreach (var axis in chart.Axes)
            {
                if (axis.AxisType == AxisTypes.X)
                {
                    axisOptions.XLabel = getAxisLabel(axis);
                    axisOptions.XMax   = axis.Max;
                    axisOptions.XMin   = axis.Min;
                    var unit = axis.Dimension.Unit(axis.UnitName);

                    axisOptions.XMajorGrid = axis.GridLines;
                    axisOptions.XMode      = getAxisMode(axis.Scaling);

                    axisOptions.XAxisPosition = AxisOptions.AxisXLine.box;
                    axisOptions.XAxisArrow    = false;
                }
                else if (axis.AxisType == yAxisType)
                {
                    axisOptions.YLabel = getAxisLabel(axis);
                    axisOptions.YMax   = axis.Max;
                    axisOptions.YMin   = axis.Min;

                    axisOptions.YMajorGrid = axis.GridLines;
                    axisOptions.YMode      = getAxisMode(axis.Scaling);

                    axisOptions.YAxisPosition = AxisOptions.AxisYLine.left;
                    axisOptions.YAxisArrow    = false;
                }
            }

            return(axisOptions);
        }
Пример #22
0
 public Axis(AxisTypes axisType)
 {
     AxisType          = axisType;
     _caption          = string.Empty;
     _scaling          = Scalings.Linear;
     _numberMode       = NumberModes.Normal;
     _dimension        = null;
     _unitName         = string.Empty;
     _gridLines        = false;
     _min              = null;
     _max              = null;
     Visible           = true;
     _defaultLineStyle = defaultLineStyleForAxisType();
     _defaultColor     = Color.White;
     Rules             = new BusinessRuleSet(ValidationRules.AllRules());
 }
Пример #23
0
        private bool isAxisTypeUsed(CurveChart chart, AxisTypes yAxisType)
        {
            if (!chart.HasAxis(yAxisType))
            {
                return(false);
            }

            var yAxis = chart.Axes.FirstOrDefault(x => x.AxisType == yAxisType);

            if (yAxis?.Dimension == null)
            {
                return(false);
            }

            return(isAtLeastOneCurveCompatibleAndVisible(chart, yAxisType, yAxis));
        }
Пример #24
0
    private float SnapFloat(float value, AxisTypes snapAxis)
    {
        if (value == 0)
        {
            return(value);
        }

        if (axisOptions == AxisTypes.Both)
        {
            float angle = Vector2.Angle(input, Vector2.up);
            if (snapAxis == AxisTypes.Horizontal)
            {
                if (angle < ANGLE_VERTICAL_UP || angle > ANGLE_VERTICAL_DOWN)
                {
                    return(0);
                }
                else
                {
                    return((value > 0) ? DIRECTION_UP : DIRECTION_DOWN);
                }
            }
            else if (snapAxis == AxisTypes.Vertical)
            {
                if (angle > ANGLE_HORIZONTAL_UP && angle < ANGLE_HORIZONTAL_DOWN)
                {
                    return(0);
                }
                else
                {
                    return((value > 0) ? DIRECTION_LEFT : DIRECTION_RIGHT);
                }
            }
            return(value);
        }
        else
        {
            if (value > 0)
            {
                return(1);
            }
            if (value < 0)
            {
                return(-1);
            }
        }
        return(0);
    }
Пример #25
0
        private Axis updateAxis(AxisTypes axisType, IDimension dimension, Unit unit)
        {
            if (!_axes.Contains(axisType))
            {
                AddNewAxisFor(axisType);
            }

            var axis = _axes[axisType];

            if (axis.Dimension == null)
            {
                axis.Dimension = dimension;
                axis.UnitName  = unit.Name;
            }

            return(axis);
        }
Пример #26
0
        public void FindMatches()
        {
            foreach (var cell in _board.Cells)
            {
                AxisTypes majorAxis = AxisTypes.Undefined;

                IList <ICell> matchedCellsList = new List <ICell>();

                if (Helper.CellIsEmpty(cell) == false)
                {
                    if (cell.CellState != CellStates.Check)
                    {
                        matchedCellsList = _checkManager.CheckCell(cell);
                        _matchedCellsDictionary.Add(cell, matchedCellsList);
                    }
                }
            }

            StartCoroutine(DestroyMatchedCells(_matchedCellsDictionary));
        }
Пример #27
0
        private float getMinYValue(CurveChart chart, AxisTypes axisType)
        {
            float min = float.MaxValue;

            foreach (var curve in chart.Curves)
            {
                if (curve.yAxisType != axisType)
                {
                    continue;
                }
                if (!curve.Visible)
                {
                    continue;
                }
                var curMin = curve.xData.Values.Min();
                if (min > curMin)
                {
                    min = curMin;
                }
            }
            return(min);
        }
Пример #28
0
        private float getMaxYValue(CurveChart chart, AxisTypes axisType)
        {
            float max = float.MinValue;

            foreach (var curve in chart.Curves)
            {
                if (curve.yAxisType != axisType)
                {
                    continue;
                }
                if (!curve.Visible)
                {
                    continue;
                }
                var curMax = curve.yData.Values.Max();
                if (max < curMax)
                {
                    max = curMax;
                }
            }
            return(max);
        }
Пример #29
0
        public void SetAxis(int index, AxisTypes axisType, int value)
        {
            var device = GetDevice(index);

            if (value < device.LowerRange || value > device.UpperRange)
            {
                throw new Exception(string.Format("Valid axis value {0} to {1}", device.LowerRange, device.UpperRange));
            }

            int newValue = (VirtualJoystick.MaxAnalogDataSourceVal / 2) + 1;

            if (value < 0)
            {
                var ratio = (double)value / device.LowerRange;
                newValue = newValue - (int)(newValue * ratio);
            }
            else if (value > 0)
            {
                var ratio = (double)value / device.UpperRange;
                newValue = (int)(newValue * ratio) + newValue;
            }

            device.Joystick.SetAnalogDataSourceValue((int)axisType, newValue);
        }
Пример #30
0
 public void setAxis(AxisTypes axisType, int value)
 {
     plugin.SetAxis(index, axisType, value);
 }
Пример #31
0
        /// <summary>
        /// Modify YValue for Logarithmic scale
        /// </summary>
        /// <param name="yValue"></param>
        /// <returns></returns>
        internal static Double ConvertYValue2LogarithmicValue(Chart chart, Double yValue, AxisTypes axisType)
        {
            if (chart != null && chart.ChartArea != null)
            {
                if (chart.ChartArea.AxisY != null && chart.ChartArea.AxisY.AxisType == axisType)
                {
                    if (chart.ChartArea.AxisY.Logarithmic)
                    {
                        yValue = Math.Log(yValue, chart.ChartArea.AxisY.LogarithmBase);
                    }
                }
                else if (chart.ChartArea.AxisY2 != null && chart.ChartArea.AxisY2.AxisType == axisType)
                {
                    if (chart.ChartArea.AxisY2.Logarithmic)
                    {
                        yValue = Math.Log(yValue, chart.ChartArea.AxisY2.LogarithmBase);
                    }
                }
            }

            return yValue;
        }
Пример #32
0
        private IList <ICell> CheckLine(AxisTypes axisType, ICell cell)
        {
            if (Helper.CellIsEmpty(cell))
            {
                return(null);
            }

            IList <ICell> sideCells = new List <ICell>();

            int x = cell.TargetX;
            int y = cell.TargetY;

            int boardLimit;
            int axis;

            ICell sideCell = null;

            if (axisType == AxisTypes.Horizontal)
            {
                boardLimit = _board.Width;
                axis       = x;
            }
            else
            {
                boardLimit = _board.Height;
                axis       = y;
            }

            if (axis > 0 && axis < boardLimit)
            {
                for (int i = axis - 1; i >= 0; i--)
                {
                    sideCell = (axisType == AxisTypes.Horizontal)
                        ? _board.Cells[i, y]
                        : _board.Cells[x, i];

                    if (Helper.CellIsEmpty(sideCell))
                    {
                        break;
                    }

                    if (sideCell.CurrentGameObject.CompareTag(StringsAndConst.TAG_POWER))
                    {
                        GameObject powerGameObject = sideCell.CurrentGameObject.transform.GetChild(0).gameObject;

                        if (Helper.CompareColors(cell.CurrentGameObject, powerGameObject))
                        {
                            sideCells.Add(sideCell);
                        }
                    }

                    if (sideCell.CurrentGameObject.CompareTag(cell.CurrentGameObject.tag))
                    {
                        sideCells.Add(sideCell);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (axis >= 0 && axis < boardLimit)
            {
                for (int i = axis + 1; i < boardLimit; i++)
                {
                    sideCell = (axisType == AxisTypes.Horizontal)
                        ? _board.Cells[i, y]
                        : _board.Cells[x, i];

                    if (Helper.CellIsEmpty(sideCell))
                    {
                        break;
                    }

                    if (sideCell.CurrentGameObject.CompareTag(StringsAndConst.TAG_POWER))
                    {
                        GameObject powerGameObject = sideCell.CurrentGameObject.transform.GetChild(0).gameObject;

                        if (Helper.CompareColors(cell.CurrentGameObject, powerGameObject))
                        {
                            sideCells.Add(sideCell);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (sideCell.CurrentGameObject.CompareTag(cell.CurrentGameObject.tag))
                    {
                        sideCells.Add(sideCell);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(sideCells);
        }
 /// <summary>
 /// Builds a string to get the controller by player.
 /// </summary>
 /// <param name="player"></param>
 /// <param name="axis"></param>
 /// <param name="type"></param>
 /// <param name="atype"></param>
 /// <returns></returns>
 public static string GetInput(OuyaSDK.OuyaPlayer player, AxisTypes axis)
 {
     return GetInput(player, axis, AnalogTypes.none);
 }
    /// <summary>
    /// This needs to be setup for each joystick type being supported.  I have not setup the USB controller or the I:Droid:CON  
    /// For the most part you won't need to modify this section.
    /// </summary>
    /// <param name="player"></param>
    /// <param name="axis"></param>
    /// <param name="joystick"></param>
    /// <param name="atype"></param>
    /// <returns></returns>
    private static string CheckInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, JoystickType joystick, AnalogTypes atype)
    {
        //Debug.Log(string.Format("Player:{0} Axis:{1} Joystick:{2} AnalogType:{3}",player,axis,joystick,atype));
        //REF: player1, DPadH, PS3, Dpad

        //Note:  It is your responsibility to make sure that  Unity Inputs are setup correctly or you will get an error on your controller.

        int axisNumber=0;

        switch (joystick)
        {
            case JoystickType.ps3:
                //Get The Joystick name from  Project Settings --> Input for Controllers
                #region PS3 Controller
                if (atype.Equals(AnalogTypes.Left))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ps3");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.Right))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ps3");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.DPad))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ps3");
                    if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                #endregion
                break;

            case JoystickType.xbox:
                #region xbox ( usually 360 / untested with normal xbox )
                if (atype.Equals(AnalogTypes.Left))
                {
                    ControllerType cType = OuyaControllerMapping.getController("xbox360");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.Right))
                {
                    ControllerType cType = OuyaControllerMapping.getController("xbox360");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.DPad))
                {
                    ControllerType cType = OuyaControllerMapping.getController("xbox360");
                    if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.LTRT))
                {
                    ControllerType cType = OuyaControllerMapping.getController("xbox360");
                    axisNumber = cType.triggers;
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                #endregion
                break;

            case JoystickType.ouya:
                #region OUYA - Not Tested until I get a bluetooth dongle
                if (atype.Equals(AnalogTypes.Left))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ouya");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.leftAnalogH; } else { axisNumber = cType.leftAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.Right))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ouya");
                    if (axis.Equals(AxisTypes.Horizontal)) { axisNumber = cType.rightAnalogH; } else { axisNumber = cType.rightAnalogV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                else if (atype.Equals(AnalogTypes.DPad))
                {
                    ControllerType cType = OuyaControllerMapping.getController("ouya");
                    if (axis.Equals(AxisTypes.DPadH)) { axisNumber = cType.dpadH; } else { axisNumber = cType.dpadV; }
                    return "Joy" + (int)player + " Axis " + axisNumber.ToString();
                }
                #endregion
                break;
        }

        //most likely we will never reach here, but If we do Return basic Horizontal Axis
        return "Horizontal";
    }
Пример #35
0
        /// <summary>
        /// Converts Logarithmic YValue to Actual YValue
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="logValue"></param>
        /// <returns></returns>
        internal static Double ConvertLogarithmicValue2ActualValue(Chart chart, Double logValue, AxisTypes axisType)
        {
            if (chart != null && chart.ChartArea != null)
            {
                if (chart.ChartArea.AxisY != null && chart.ChartArea.AxisY.AxisType == axisType)
                {
                    if (chart.ChartArea.AxisY.Logarithmic)
                    {
                        logValue = Math.Pow(chart.ChartArea.AxisY.LogarithmBase, logValue);
                    }
                }
                else if (chart.ChartArea.AxisY2 != null && chart.ChartArea.AxisY2.AxisType == axisType)
                {
                    if (chart.ChartArea.AxisY2.Logarithmic)
                    {
                        logValue = Math.Pow(chart.ChartArea.AxisY2.LogarithmBase, logValue);
                    }
                }
            }

            return logValue;
        }     
    /// <summary>
    /// Builds a string to get the controller by player.
    /// </summary>
    /// <param name="player"></param>
    /// <param name="axis"></param>
    /// <param name="type"></param>
    /// <param name="atype"></param>
    /// <returns></returns>
    public static string GetInput(OuyaSDK.OuyaPlayer player, AxisTypes axis, AnalogTypes atype)
    {
        Vector2 point;
        JoystickType joystickType = GetControllerType(player);
        switch (joystickType)
        {
            case JoystickType.ps3:
                //Note We don't care if the axis is X or Y,  we just want to check for input from normalized.
                #region PS3 Controller
                point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ps3, AnalogTypes.Right)));
                if (point.x != 0f || point.y != 0f)
                {
                    return CheckInput(player, axis, JoystickType.ps3, atype);
                }
                if (atype.Equals(AnalogTypes.DPad)){
                    return CheckInput(player, axis, JoystickType.ps3, atype);
                }
                #endregion
                return string.Empty;

            case JoystickType.xbox:
                #region xbox360
                point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.xbox, AnalogTypes.Right)));
                if (point.x != 0f || point.y != 0f)
                {
                    return CheckInput(player, axis, JoystickType.xbox, atype);
                }
                if (atype.Equals(AnalogTypes.DPad))
                {
                    return CheckInput(player, axis, JoystickType.xbox, atype);
                }
                if (atype.Equals(AnalogTypes.LTRT))
                {
                    return CheckInput(player, axis, JoystickType.xbox, atype);
                }
                #endregion
                return string.Empty;

            case JoystickType.ouya:
                point = new Vector2(Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Left)), Input.GetAxis(CheckInput(player, axis, JoystickType.ouya, AnalogTypes.Right)));
                if (point.x != 0f || point.y != 0f)
                {
                    return CheckInput(player, axis, JoystickType.ouya, atype);
                }
                if (atype.Equals(AnalogTypes.DPad))
                {
                    return CheckInput(player, axis, JoystickType.ouya, atype);
                }
                if (atype.Equals(AnalogTypes.LTRT))
                {
                    return CheckInput(player, axis, JoystickType.ouya, atype);
                }
                return string.Empty;

            default:
                return "Horizontal";
        }
    }
Пример #37
0
 private int GetCoordinate(AxisTypes axis)
 {
     switch (axis)
     {
         case AxisTypes.X:
             return X;
         case AxisTypes.Y:
             return Y;
         case AxisTypes.Z:
             return Z;
         default:
             throw new Exception(axis.ToString() + " is not a valid axis type.");
     }
 }
Пример #38
0
        /// <summary>
        /// Takes an axis and returns a ButtonState depending on whether the axis is pressed or not (useful for xbox triggers for example), and when you need to use an axis/trigger as a binary thing
        /// </summary>
        /// <returns>The axis as button.</returns>
        /// <param name="axisName">Axis name.</param>
        /// <param name="threshold">Threshold value below which the button is off or released.</param>
        /// <param name="currentState">Current state of the axis.</param>
        public static ButtonStates ProcessAxisAsButton(string axisName, float threshold, ButtonStates currentState, AxisTypes AxisType = AxisTypes.Positive)
        {
            float        axisValue = Input.GetAxis(axisName);
            ButtonStates returnState;

            bool comparison = (AxisType == AxisTypes.Positive) ? (axisValue < threshold) : (axisValue > threshold);

            if (comparison)
            {
                if (currentState == ButtonStates.ButtonPressed)
                {
                    returnState = ButtonStates.ButtonUp;
                }
                else
                {
                    returnState = ButtonStates.Off;
                }
            }
            else
            {
                if (currentState == ButtonStates.Off)
                {
                    returnState = ButtonStates.ButtonDown;
                }
                else
                {
                    returnState = ButtonStates.ButtonPressed;
                }
            }
            return(returnState);
        }
Пример #39
0
 private void SetCoordinate(AxisTypes axis, int value)
 {
     switch (axis)
     {
         case AxisTypes.X:
             this.X = value;
             break;
         case AxisTypes.Y:
             this.Y = value;
             break;
         case AxisTypes.Z:
             this.Z = value;
             break;
     }
 }