コード例 #1
0
 /// <summary>
 /// Fetches the name of a particular button or directional
 /// </summary>
 /// <param name="device">Device whose name is desired</param>
 /// <returns>Name of the device</returns>
 public string getControlName(InputsEnum device)
 {
     switch (device)
     {
     case InputsEnum.LEFT_DIRECTIONAL:
         return LEFT_DIR_UP.ToString() +
                 LEFT_DIR_LEFT.ToString() +
                 LEFT_DIR_DOWN.ToString() +
                 LEFT_DIR_RIGHT.ToString();
     case InputsEnum.RIGHT_DIRECTIONAL:
         return "Mouse";
     case InputsEnum.CONFIRM_BUTTON:
         return CONFIRM.ToString();
     case InputsEnum.CANCEL_BUTTON:
         return CANCEL.ToString();
     case InputsEnum.BUTTON_1:
         return BUTTON_1.ToString();
     case InputsEnum.BUTTON_2:
         return BUTTON_2.ToString();
     case InputsEnum.BUTTON_3:
         return BUTTON_3.ToString();
     case InputsEnum.BUTTON_4:
         return BUTTON_4.ToString();
     case InputsEnum.LEFT_BUMPER:
         return LEFT_BUMPER.ToString();
     case InputsEnum.RIGHT_BUMPER:
         return RIGHT_BUMPER.ToString();
     case InputsEnum.LEFT_TRIGGER: // backwards on mouse!
         return "Right Click";
     case InputsEnum.RIGHT_TRIGGER:
         return "Left Click";
     default:
         throw new NotImplementedException();
     }
 }
コード例 #2
0
ファイル: PlayerInput.cs プロジェクト: clifordunique/Hunter
    IEnumerator SetLastInputs(InputsEnum key, float delayTime)
    {
        yield return(new WaitForSeconds(delayTime));

        if (lastInputs.Count < lastInputs.Capacity)
        {
            lastInputs.Add(key);
        }
        else
        {
            lastInputs.RemoveAt(0);
            lastInputs.Add(key);
        }
    }
コード例 #3
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Causes an input unit to act released until being physically
 /// released and then pressed/moved/clicked/etc again.
 /// </summary>
 /// <param name="toToggle">The input unit which will act released.</param>
 public void setToggle(InputsEnum toToggle)
 {
     m_toggleStates[(int)toToggle] = true;
 }
コード例 #4
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Causes an input unit to act released for a set number of frames.
 /// </summary>
 /// <param name="toStick">The input unit which will act released.</param>
 /// <param name="numFrames">Duration (in frames) before acting normal.</param>
 public void setStick(InputsEnum toStick, int numFrames)
 {
     if (numFrames >= 0)
     {
         m_stickStates[(int)toStick] = numFrames;
     }
     else
     {
         m_stickStates[(int)toStick] = 0;
     }
 }
コード例 #5
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Sets a directional-type device to a specific value.
 /// </summary>
 /// <param name="device">Directional device to be set</param>
 /// <param name="x">Cartesian X</param>
 /// <param name="y">Cartesian Y</param>
 public void setDirectional(InputsEnum device, float x, float y)
 {
     int index = (int)device;
     if (index < 0 || index > ARRAY_OFFSET)
     {
         throw new InvalidInputSetException();
     }
     if (m_stickStates[index] > 0 ||
         m_toggleStates[index])
     {
         if (x == 0 && y == 0)
         {
             m_toggleStates[index] = false;
         }
         m_directionals[index].X = 0;
         m_directionals[index].Y = 0;
         return;
     }
     m_directionals[index].X = x;
     m_directionals[index].Y = y;
 }
コード例 #6
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Sets a button-type device to a specific value.
 /// </summary>
 /// <param name="device">Button to set</param>
 /// <param name="value">True = pressed, False = depressed</param>
 public void setButton(InputsEnum device, bool value)
 {
     int index = (int)device;
     if (index < ARRAY_OFFSET || index >= (int)InputsEnum.LENGTH)
     {
         throw new InvalidInputSetException();
     }
     if (m_stickStates[index] > 0 ||
         m_toggleStates[index])
     {
         if (!value)
         {
             m_toggleStates[index] = false;
         }
         index -= ARRAY_OFFSET; // normalize to the buttons_ array
         m_buttons[index] = false;
         return;
     }
     index -= ARRAY_OFFSET; // normalize to the buttons_ array
     m_buttons[index] = value;
 }
コード例 #7
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Fetches the name of a particular button or directional
 /// </summary>
 /// <param name="device">Device whose name is desired</param>
 /// <returns>Name of the device</returns>
 public string getControlName(InputsEnum device)
 {
     if (m_controller == null)
         return "Error";
     return m_controller.getControlName(device);
 }
コード例 #8
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Retrieves the value of a button-type device.
 /// </summary>
 /// <param name="button">Button value to retrieve</param>
 /// <returns>Returns true if pressed, false if depressed</returns>
 public bool getButton(InputsEnum button)
 {
     int index = (int)button;
     if (index < ARRAY_OFFSET || index >= (int)InputsEnum.LENGTH)
     {
         throw new InvalidInputSetException();
     }
     index -= ARRAY_OFFSET; // normalize to the buttons_ array
     return m_buttons[index];
 }
コード例 #9
0
ファイル: InputSet.cs プロジェクト: BNHeadrick/Bros
 /// <summary>
 /// Clears the toggle requirement for an input unit.  See setToggle().
 /// </summary>
 /// <param name="toToggle">The input unit to no longer wait for a toggle.</param>
 public void clearToggle(InputsEnum toToggle)
 {
     m_toggleStates[(int)toToggle] = false;
 }
コード例 #10
0
 /// <summary>
 /// Fetches the name of a particular button or directional
 /// </summary>
 /// <param name="device">Device whose name is desired</param>
 /// <returns>Name of the device</returns>
 public string getControlName(InputsEnum device)
 {
     switch (device)
     {
     case InputsEnum.LEFT_DIRECTIONAL:
         return "Left Thumbstick";
     case InputsEnum.RIGHT_DIRECTIONAL:
         return "Right Thumbstick";
     case InputsEnum.CONFIRM_BUTTON:
         return CONFIRM.ToString();
     case InputsEnum.CANCEL_BUTTON:
         return CANCEL.ToString();
     case InputsEnum.BUTTON_1:
         return BUTTON_1.ToString();
     case InputsEnum.BUTTON_2:
         return BUTTON_2.ToString();
     case InputsEnum.BUTTON_3:
         return BUTTON_3.ToString();
     case InputsEnum.BUTTON_4:
         return BUTTON_4.ToString();
     case InputsEnum.LEFT_BUMPER:
         return LEFT_BUMPER.ToString();
     case InputsEnum.RIGHT_BUMPER:
         return RIGHT_BUMPER.ToString();
     case InputsEnum.LEFT_TRIGGER:
         return LEFT_TRIGGER.ToString();
     case InputsEnum.RIGHT_TRIGGER:
         return RIGHT_TRIGGER.ToString();
     default:
         throw new NotImplementedException();
     }
 }