Ejemplo n.º 1
0
 /// <summary>
 /// Sets up your axis to find it by name later.
 /// </summary>
 private static void setup(Axis axis)
 {
     if (Axis.Find(axis.Name) != null)
     {
         Exception ex = new AxisException("Axis name \"" + axis.Name + "\" is already used");
         Log.Exception(ex);
         throw ex;
     }
     Axes.Add(axis);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets axis value.
        /// </summary>
        /// <param name="name">axis name</param>
        public static float GetValue(string name)
        {
            Axis axis = Find(name);

            if (axis == null)
            {
                Exception ex = new AxisException("Cannot find axis \"" + name + "\"");
                Log.Exception(ex);
                throw ex;
            }
            return(GetValue(axis));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// returns mouse axis value.
        /// </summary>
        public static float Get(MouseAxis a)
        {
            switch (a)
            {
            case MouseAxis.X:
                return(MouseAxesValues.X);

            case MouseAxis.Y:
                return(MouseAxesValues.Y);

            case MouseAxis.Wheel:
                return(MouseAxesValues.Wheel);

            default:
                Exception ex = new AxisException("MouseAxis is null", new NullReferenceException());
                Log.Exception(ex);
                throw ex;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets axis value.
        /// </summary>
        public static float GetValue(Axis axis)
        {
            if (axis == null)
            {
                Exception ex = new AxisException("Axis is null", new NullReferenceException());
                Log.Exception(ex);
                throw ex;
            }
            float value = 0;

            if (Keyboard.KeyPressed(axis.Negative))
            {
                value--;
            }
            if (Keyboard.KeyPressed(axis.Positive))
            {
                value++;
            }

            return(value);
        }